Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7657d3

Browse files
navigate fix: zero legs (#3237)
1 parentb654a5d commita7657d3

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ local.properties
4242
**/node_modules
4343
.DS_Store
4444
/graph-cache
45-
package-lock.json
45+
package-lock.json
46+
.vscode/

‎navigation/src/main/java/com/graphhopper/navigation/NavigateResponseConverter.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ private static void putRouteInformation(ObjectNode pathJson, ResponsePath path,
121121
if (isDepartInstruction) {
122122
maneuverType =ManeuverType.DEPART;
123123
fixDepartIntersectionDetail(intersectionDetails,i);
124+
// if the depart is on a REACHED_VIA or FINISH node, add the summary
125+
if (instruction.getSign() ==Instruction.REACHED_VIA ||instruction.getSign() ==Instruction.FINISH) {
126+
putLegInformation(legJson,path,routeNr,time,distance);
127+
}
124128
}else {
125129
switch (instruction.getSign()) {
126130
caseInstruction.REACHED_VIA,Instruction.FINISH:

‎navigation/src/test/java/com/graphhopper/navigation/NavigateResponseConverterTest.java‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,36 @@ public void testMultipleWaypoints() {
614614
assertEquals(route.get("distance").asDouble(),distance,1);
615615
}
616616

617+
618+
@Test
619+
publicvoidtestMultipleWaypointsAndLastDuplicate() {
620+
621+
GHRequestrequest =newGHRequest();
622+
request.addPoint(newGHPoint(42.505144,1.526113));
623+
request.addPoint(newGHPoint(42.50529,1.527218));
624+
request.addPoint(newGHPoint(42.50529,1.527218));
625+
request.setProfile(profile).setPathDetails(Collections.singletonList("intersection"));
626+
627+
GHResponsersp =hopper.route(request);
628+
629+
ObjectNodejson =NavigateResponseConverter.convertFromGHResponse(rsp,trMap,Locale.ENGLISH,distanceConfig);
630+
631+
// Check that all waypoints are there and in the right order
632+
JsonNodewaypointsJson =json.get("waypoints");
633+
assertEquals(3,waypointsJson.size());
634+
635+
// Check that there are 2 legs
636+
JsonNoderoute =json.get("routes").get(0);
637+
JsonNodelegs =route.get("legs");
638+
assertEquals(2,legs.size());
639+
640+
// check last leg
641+
JsonNodeleg =legs.get(1);
642+
643+
JsonNodesummary =leg.get("summary");
644+
assertNotNull(summary);
645+
}
646+
617647
@Test
618648
publicvoidtestError() {
619649
GHResponsersp =hopper.route(newGHRequest(42.554851,111.536198,42.510071,1.548128).setProfile(profile));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp