/** * Creates the standard GPX string out of the points according to the schema found here: * https://graphhopper.com/public/schema/gpx-1.1.xsd * <p> * * @return string to be stored as gpx file */ public String createGPX(String version) { return createGPX("GraphHopper", new Date().getTime(), version); }
@Test public void testCreateGPX() { InstructionAnnotation ea = InstructionAnnotation.EMPTY; InstructionList instructions = new InstructionList(usTR); PointList pl = new PointList(); pl.add(49.942576, 11.580384); pl.add(49.941858, 11.582422); instructions.add(new Instruction(Instruction.CONTINUE_ON_STREET, "temp", ea, pl).setDistance(240).setTime(15000)); pl = new PointList(); pl.add(49.941575, 11.583501); instructions.add(new Instruction(Instruction.TURN_LEFT, "temp2", ea, pl).setDistance(25).setTime(4000)); pl = new PointList(); pl.add(49.941389, 11.584311); instructions.add(new Instruction(Instruction.TURN_LEFT, "temp2", ea, pl).setDistance(25).setTime(3000)); instructions.add(new FinishInstruction(49.941029, 11.584514, 0)); List<GPXEntry> result = instructions.createGPXList(); assertEquals(5, result.size()); assertEquals(0, result.get(0).getTime()); assertEquals(10391, result.get(1).getTime()); assertEquals(15000, result.get(2).getTime()); assertEquals(19000, result.get(3).getTime()); assertEquals(22000, result.get(4).getTime()); verifyGPX(instructions.createGPX(Constants.VERSION)); }
private static Response.ResponseBuilder gpxSuccessResponseBuilder(GHResponse ghRsp, String timeString, String trackName, boolean enableElevation, boolean withRoute, boolean withTrack, boolean withWayPoints, String version) { if (ghRsp.getAll().size() > 1) { throw new IllegalArgumentException("Alternatives are currently not yet supported for GPX"); } long time = timeString != null ? Long.parseLong(timeString) : System.currentTimeMillis(); return Response.ok(ghRsp.getBest().getInstructions().createGPX(trackName, time, enableElevation, withRoute, withTrack, withWayPoints, version), "application/gpx+xml"). header("Content-Disposition", "attachment;filename=" + "GraphHopper.gpx"); }
assertEquals(9.9, wayList.get(2).getFirstLon(), 1e-3); String gpxStr = wayList.createGPX("test", 0, Constants.VERSION); verifyGPX(gpxStr);
public String createGPX(String trackName, long startTimeMillis, String version) { boolean includeElevation = size() > 0 && get(0).getPoints().is3D(); return createGPX(trackName, startTimeMillis, includeElevation, true, true, true, version); }
@Test public void testCreateGPXWithEle() { final List<GPXEntry> fakeList = new ArrayList<>(); fakeList.add(new GPXEntry(12, 13, 0)); fakeList.add(new GPXEntry(12.5, 13, 1000)); InstructionList il = new InstructionList(usTR) { @Override public List<GPXEntry> createGPXList() { return fakeList; } }; String gpxStr = il.createGPX("test", 0, Constants.VERSION); verifyGPX(gpxStr); assertFalse(gpxStr, gpxStr.contains("NaN")); assertFalse(gpxStr, gpxStr.contains("<ele>")); fakeList.clear(); fakeList.add(new GPXEntry(12, 13, 11, 0)); fakeList.add(new GPXEntry(12.5, 13, 10, 1000)); gpxStr = il.createGPX("test", 0, true, true, true, true, Constants.VERSION); assertTrue(gpxStr, gpxStr.contains("<ele>11.0</ele>")); assertFalse(gpxStr, gpxStr.contains("NaN")); }
@Test public void testCreateGPXCorrectFormattingSmallNumbers() { InstructionList instructions = new InstructionList(usTR); PointList pl = new PointList(); pl.add(0.000001, 0.000001); pl.add(-0.000123, -0.000125); Instruction instruction = new Instruction(0, "do it", null, pl); instructions.add(instruction); instructions.add(new FinishInstruction(0.000852, 0.000852, 0)); String gpxStr = instructions.createGPX("test", 0, true, true, true, true, Constants.VERSION); assertFalse(gpxStr, gpxStr.contains("E-")); assertTrue(gpxStr, gpxStr.contains("0.000001")); assertTrue(gpxStr, gpxStr.contains("-0.000125")); verifyGPX(gpxStr); }
@Test public void testCreateGPXIncludesRoundaboutExitNumber() { InstructionList instructions = new InstructionList(usTR); PointList pl = new PointList(); pl.add(52.555423473315, 13.43890086052345); pl.add(52.555550691982, 13.43946393816465); pl.add(52.555619423589, 13.43886994061328); RoundaboutInstruction instr = new RoundaboutInstruction(Instruction.USE_ROUNDABOUT, "streetname", InstructionAnnotation.EMPTY, pl) .setRadian(2.058006514284998d) .setExitNumber(3) .setExited(); instructions.add(instr); instructions.add(new FinishInstruction(52.555619423589, 13.43886994061328, 0)); String gpxStr = instructions.createGPX("test", 0, true, true, false, false, Constants.VERSION); assertTrue(gpxStr, gpxStr.contains("<gh:exit_number>3</gh:exit_number>")); verifyGPX(gpxStr); }
/** * Creates the standard GPX string out of the points according to the schema found here: * https://graphhopper.com/public/schema/gpx-1.1.xsd * <p> * @return string to be stored as gpx file */ public String createGPX() { return createGPX("GraphHopper", new Date().getTime()); }
/** * Creates the standard GPX string out of the points according to the schema found here: * https://graphhopper.com/public/schema/gpx-1.1.xsd * <p> * * @return string to be stored as gpx file */ public String createGPX(String version) { return createGPX("GraphHopper", new Date().getTime(), version); }
/** * Creates the standard GPX string out of the points according to the schema found here: * https://graphhopper.com/public/schema/gpx-1.1.xsd * <p> * * @return string to be stored as gpx file */ public String createGPX() { return createGPX("GraphHopper", new Date().getTime()); }
public static void write(Path path, String gpxFile, Translation translation) { BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(gpxFile)); writer.append(path.calcInstructions(translation).createGPX()); } catch (IOException ex) { throw new IllegalStateException(ex); } finally { Helper.close(writer); } } }
public String createGPX( String trackName, long startTimeMillis ) { boolean includeElevation = getSize() > 0 ? get(0).getPoints().is3D() : false; return createGPX(trackName, startTimeMillis, includeElevation, true, true, true); }
public String createGPX(String trackName, long startTimeMillis) { boolean includeElevation = getSize() > 0 ? get(0).getPoints().is3D() : false; return createGPX(trackName, startTimeMillis, includeElevation, true, true, true); }
public String createGPX(String trackName, long startTimeMillis, String version) { boolean includeElevation = size() > 0 && get(0).getPoints().is3D(); return createGPX(trackName, startTimeMillis, includeElevation, true, true, true, version); }
time = measurements.get(0).getTime(); return Response.ok(rsp.getBest().getInstructions().createGPX(gpx.trk.get(0).name != null ? gpx.trk.get(0).name : "", time, enableElevation, withRoute, withTrack, false, Constants.VERSION), "application/gpx+xml"). header("X-GH-Took", "" + Math.round(took * 1000)). build();
time = measurements.get(0).getTime(); writer.append(pathWrapper.getInstructions().createGPX(gpx.trk.get(0).name != null ? gpx.trk.get(0).name : "", time, hopper.hasElevation(), withRoute, true, false, Constants.VERSION));