Merge pull request #1094 from gberaudo/fixes

Several fixes: remove dead code, fix Int->String conversion for INT_MIN, remove duplicated coordinate from encoded polyline.
This commit is contained in:
Dennis Luxen 2014-06-26 11:54:45 +02:00
commit 4c0b315c07
8 changed files with 46 additions and 33 deletions

View File

@ -79,8 +79,10 @@ JSON::String PolylineCompressor::printEncodedString(const std::vector<SegmentInf
FixedPointCoordinate last_coordinate = polyline[0].location;
delta_numbers.emplace_back(last_coordinate.lat);
delta_numbers.emplace_back(last_coordinate.lon);
for (const auto &segment : polyline)
// iterate after skipping the first, already handled, segment
for (auto it = ++polyline.cbegin(); it != polyline.cend(); ++it)
{
const auto &segment = *it;
if (segment.necessary)
{
int lat_diff = segment.location.lat - last_coordinate.lat;

View File

@ -85,11 +85,6 @@ JSON::Value DescriptionFactory::AppendEncodedPolylineString(const bool return_en
return polyline_compressor.printUnencodedString(path_description);
}
JSON::Value DescriptionFactory::AppendUnencodedPolylineString() const
{
return polyline_compressor.printUnencodedString(path_description);
}
void DescriptionFactory::BuildRouteSummary(const double distance, const unsigned time)
{
summary.source_name_id = start_phantom.name_id;

View File

@ -77,7 +77,6 @@ class DescriptionFactory
// I know, declaring this public is considered bad. I'm lazy
std::vector<SegmentInformation> path_description;
DescriptionFactory();
JSON::Value AppendUnencodedPolylineString() const;
void AppendSegment(const FixedPointCoordinate &coordinate, const PathData &data);
void BuildRouteSummary(const double distance, const unsigned time);
void SetStartSegment(const PhantomNode &start_phantom, const bool traversed_in_reverse);

View File

@ -212,7 +212,10 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
BOOST_ASSERT_MSG(0 != number_of_chars, "name file broken");
m_names_char_list.resize(number_of_chars + 1); //+1 gives sentinel element
name_stream.read((char *)&m_names_char_list[0], number_of_chars * sizeof(char));
BOOST_ASSERT_MSG(0 != m_names_char_list.size(), "could not load any names");
if (0 == m_names_char_list.size())
{
SimpleLogger().Write(logWARNING) << "list of street names is empty";
}
name_stream.close();
}

View File

@ -40,18 +40,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// precision: position after decimal point
// length: maximum number of digits including comma and decimals
// work with negative values to prevent overflowing when taking -value
template <int length, int precision> static inline char *printInt(char *buffer, int value)
{
bool minus = false;
if (value < 0)
bool minus = true;
if (value > 0)
{
minus = true;
minus = false;
value = -value;
}
buffer += length - 1;
for (int i = 0; i < precision; i++)
{
*buffer = '0' + (value % 10);
*buffer = '0' - (value % 10);
value /= 10;
buffer--;
}
@ -59,7 +60,7 @@ template <int length, int precision> static inline char *printInt(char *buffer,
buffer--;
for (int i = precision + 1; i < length; i++)
{
*buffer = '0' + (value % 10);
*buffer = '0' - (value % 10);
value /= 10;
if (value == 0)
break;

View File

@ -77,6 +77,9 @@ When /^I route I should get$/ do |table|
if table.headers.include? 'end'
got['end'] = instructions ? json['route_summary']['end_point'] : nil
end
if table.headers.include? 'geometry'
got['geometry'] = json['route_geometry']
end
if table.headers.include? 'route'
got['route'] = (instructions || '').strip
if table.headers.include?('distance')

View File

@ -43,26 +43,6 @@ def request_route waypoints, params={}
request_path "viaroute", waypoints, defaults.merge(params)
end
def parse_response response
if response.code == "200" && response.body.empty? == false
json = JSON.parse response.body
if json['status'] == 0
route = way_list json['route_instructions']
if route.empty?
"Empty route: #{json['route_instructions']}"
else
"Route: #{route}"
end
elsif json['status'] == 207
"No route"
else
"Status: #{json['status']}"
end
else
"HTTP: #{response.code}"
end
end
def got_route? response
if response.code == "200" && !response.body.empty?
json = JSON.parse response.body

View File

@ -0,0 +1,30 @@
@routing
Feature: Retrieve geometry
Background: Use some profile
Given the profile "testbot"
@geometry
Scenario: Route retrieving geometry
Given the node locations
| node | lat | lon |
| a | 1.0 | 1.5 |
| b | 2.0 | 2.5 |
| c | 3.0 | 3.5 |
| d | 4.0 | 4.5 |
And the ways
| nodes |
| ab |
| bc |
| cd |
When I route I should get
| from | to | route | geometry |
| a | c | ab,bc | _c`\|@_upzA_c`\|@_c`\|@_c`\|@_c`\|@ |
| b | d | bc,cd | _gayB_yqwC_c`\|@_c`\|@_c`\|@_c`\|@ |
# Mind the \ before the pipes
# polycodec.rb decode2 '_c`|@_upzA_c`|@_c`|@_c`|@_c`|@' [[1.0, 1.5], [2.0, 2.5], [3.0, 3.5]]
# polycodec.rb decode2 '_gayB_yqwC_c`|@_c`|@_c`|@_c`|@' [[2.0, 2.5], [3.0, 3.5], [4.0, 4.5]]