Add an option to export waypoints in GeoJSON tracks
This commit is contained in:
parent
f829bc6630
commit
af660bf1cf
3 changed files with 98 additions and 66 deletions
|
@ -60,6 +60,9 @@ public final class OsmTrack
|
|||
|
||||
public String name = "unset";
|
||||
|
||||
protected List<MatchedWaypoint> matchedWaypoints;
|
||||
public boolean exportWaypoints = false;
|
||||
|
||||
public void addNode( OsmPathElement node )
|
||||
{
|
||||
nodes.add( 0, node );
|
||||
|
@ -713,7 +716,30 @@ public final class OsmTrack
|
|||
|
||||
sb.append( " ]\n" );
|
||||
sb.append( " }\n" );
|
||||
if ( exportWaypoints )
|
||||
{
|
||||
sb.append( " },\n" );
|
||||
for( int i=1; i<=matchedWaypoints.size() - 2; i++ )
|
||||
{
|
||||
sb.append( " {\n" );
|
||||
sb.append( " \"type\": \"Feature\",\n" );
|
||||
sb.append( " \"properties\": {\n" );
|
||||
sb.append( " \"name\": \"" + matchedWaypoints.get(i).name + "\",\n" );
|
||||
sb.append( " \"type\": \"via\"\n" );
|
||||
sb.append( " },\n" );
|
||||
sb.append( " \"geometry\": {\n" );
|
||||
sb.append( " \"type\": \"Point\",\n" );
|
||||
sb.append( " \"coordinates\": [\n" );
|
||||
sb.append( " " + formatILon(matchedWaypoints.get(i).waypoint.ilon) + ",\n" );
|
||||
sb.append( " " + formatILat(matchedWaypoints.get(i).waypoint.ilat) + "\n" );
|
||||
sb.append( " ]\n" );
|
||||
sb.append( " }\n" );
|
||||
sb.append( " }\n" );
|
||||
}
|
||||
}
|
||||
else {
|
||||
sb.append( " }\n" );
|
||||
}
|
||||
sb.append( " ]\n" );
|
||||
sb.append( "}\n" );
|
||||
|
||||
|
|
|
@ -446,6 +446,7 @@ public class RoutingEngine extends Thread
|
|||
totaltrack.appendTrack( seg );
|
||||
lastTracks[i] = seg;
|
||||
}
|
||||
totaltrack.matchedWaypoints = matchedWaypoints;
|
||||
return totaltrack;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
* alternativeidx = [0|1|2|3] (optional, default 0)
|
||||
* format = [kml|gpx|geojson] (optional, default gpx)
|
||||
* trackname = name used for filename and format specific trackname (optional, default brouter)
|
||||
* exportWaypoints = 1 to export them (optional, default is no export)
|
||||
*
|
||||
* Example URLs:
|
||||
* {@code http://localhost:17777/brouter?lonlats=8.799297,49.565883|8.811764,49.563606&nogos=&profile=trekking&alternativeidx=0&format=gpx}
|
||||
|
@ -118,6 +119,10 @@ public class ServerHandler extends RequestHandler {
|
|||
if (trackName != null) {
|
||||
track.name = trackName;
|
||||
}
|
||||
String exportWaypointsStr = params.get( "exportWaypoints" );
|
||||
if (exportWaypointsStr != null && Integer.parseInt(exportWaypointsStr) != 0) {
|
||||
track.exportWaypoints = true;
|
||||
}
|
||||
|
||||
if (format == null || "gpx".equals(format))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue