Remove duplicated point in polyline encoded data
First point was outputted twice. Add test case.
This commit is contained in:
parent
bee18dba54
commit
6ee2d1103e
@ -79,8 +79,10 @@ JSON::String PolylineCompressor::printEncodedString(const std::vector<SegmentInf
|
|||||||
FixedPointCoordinate last_coordinate = polyline[0].location;
|
FixedPointCoordinate last_coordinate = polyline[0].location;
|
||||||
delta_numbers.emplace_back(last_coordinate.lat);
|
delta_numbers.emplace_back(last_coordinate.lat);
|
||||||
delta_numbers.emplace_back(last_coordinate.lon);
|
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)
|
if (segment.necessary)
|
||||||
{
|
{
|
||||||
int lat_diff = segment.location.lat - last_coordinate.lat;
|
int lat_diff = segment.location.lat - last_coordinate.lat;
|
||||||
|
@ -77,6 +77,9 @@ When /^I route I should get$/ do |table|
|
|||||||
if table.headers.include? 'end'
|
if table.headers.include? 'end'
|
||||||
got['end'] = instructions ? json['route_summary']['end_point'] : nil
|
got['end'] = instructions ? json['route_summary']['end_point'] : nil
|
||||||
end
|
end
|
||||||
|
if table.headers.include? 'geometry'
|
||||||
|
got['geometry'] = json['route_geometry']
|
||||||
|
end
|
||||||
if table.headers.include? 'route'
|
if table.headers.include? 'route'
|
||||||
got['route'] = (instructions || '').strip
|
got['route'] = (instructions || '').strip
|
||||||
if table.headers.include?('distance')
|
if table.headers.include?('distance')
|
||||||
|
30
features/testbot/geometry.feature
Normal file
30
features/testbot/geometry.feature
Normal 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]]
|
Loading…
Reference in New Issue
Block a user