Skip to content
Snippets Groups Projects
Commit b5335e00 authored by yolas01's avatar yolas01
Browse files

Merge branch 'fix-return-coordinates' into 'main'

fix-return-coordinates

See merge request !25
parents b1657469 e41631b0
No related branches found
No related tags found
1 merge request!25fix-return-coordinates
...@@ -2,6 +2,7 @@ package de.fuberlin.navigator.routingserver.utility; ...@@ -2,6 +2,7 @@ package de.fuberlin.navigator.routingserver.utility;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
...@@ -263,6 +264,23 @@ public class ApplyShortestPath { ...@@ -263,6 +264,23 @@ public class ApplyShortestPath {
Segment segment = roadnetwork.getSegmentsMap().get(edge.getId()); Segment segment = roadnetwork.getSegmentsMap().get(edge.getId());
List<Coordinates> geometryList= segment.getGeometryList(); List<Coordinates> geometryList= segment.getGeometryList();
// handle reversed edges (the edges that are added if the street is no oneway)
// find right geometryList order by calculating distance between last element of coordinateList and geometryList
Point last = coordinateList.get(coordinateList.size() - 1);
Coordinates firstGeometry = geometryList.get(0);
Coordinates lastGeometry = geometryList.get(geometryList.size() -1);
int distanceToFirst = GeoUtils.haversine((float)last.getLat(), (float)last.getLon(), firstGeometry.getLat(), firstGeometry.getLon());
int distanceToLast = GeoUtils.haversine((float)last.getLat(), (float)last.getLon(), lastGeometry.getLat(), lastGeometry.getLon());
if(distanceToLast < distanceToFirst){
//reverse geometryList
List<Coordinates> tempList = new ArrayList<Coordinates>(geometryList);
Collections.reverse(tempList);
geometryList = tempList;
}
for(Coordinates coordinates : geometryList){ for(Coordinates coordinates : geometryList){
coordinateList.add(new Point(coordinates.getLat(), coordinates.getLon())); coordinateList.add(new Point(coordinates.getLat(), coordinates.getLon()));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment