use of slash.navigation.gpx.binding10.Gpx in project RouteConverter by cpesch.
the class GpxFormatIT method testReader.
@Test
public void testReader() throws FileNotFoundException, JAXBException {
Reader reader = new FileReader(TEST_PATH + "from10.gpx");
Gpx gpx = (Gpx) GpxUtil.newUnmarshaller10().unmarshal(reader);
assertNotNull(gpx);
assertNotNull(gpx.getWpt());
assertEquals(3, gpx.getWpt().size());
assertNotNull(gpx.getRte());
assertEquals(3, gpx.getRte().size());
assertNotNull(gpx.getTrk());
assertEquals(3, gpx.getRte().size());
}
use of slash.navigation.gpx.binding10.Gpx in project RouteConverter by cpesch.
the class GarbleGpx10Format method read.
public void read(InputStream source, ParserContext<GpxRoute> context) throws IOException {
try (InputStreamReader reader = new InputStreamReader(source)) {
Gpx gpx = unmarshal10(reader);
process(gpx, context);
}
}
use of slash.navigation.gpx.binding10.Gpx in project RouteConverter by cpesch.
the class Gpx10Format method recycleGpx.
private Gpx recycleGpx(GpxRoute route) {
Gpx gpx = route.getOrigin(Gpx.class);
if (gpx != null) {
gpx.getRte().clear();
gpx.getTrk().clear();
gpx.getWpt().clear();
}
return gpx;
}
use of slash.navigation.gpx.binding10.Gpx in project RouteConverter by cpesch.
the class Gpx10Format method createGpx.
private Gpx createGpx(List<GpxRoute> routes) {
ObjectFactory objectFactory = new ObjectFactory();
Gpx gpx = null;
for (GpxRoute route : routes) {
gpx = recycleGpx(route);
if (gpx != null)
break;
}
if (gpx == null || !reuseReadObjectsForWriting)
gpx = objectFactory.createGpx();
gpx.setCreator(getCreator());
gpx.setVersion(VERSION);
if (isWriteMetaData())
gpx.setTime(formatXMLTime(now()));
for (GpxRoute route : routes) {
switch(route.getCharacteristics()) {
case Waypoints:
createMetaData(route, gpx);
gpx.getWpt().addAll(createWayPoints(route, 0, route.getPositionCount()));
break;
case Route:
gpx.getRte().addAll(createRoute(route, 0, route.getPositionCount()));
break;
case Track:
gpx.getTrk().addAll(createTrack(route, 0, route.getPositionCount()));
break;
default:
throw new IllegalArgumentException("Unknown RouteCharacteristics " + route.getCharacteristics());
}
}
return gpx;
}
use of slash.navigation.gpx.binding10.Gpx in project RouteConverter by cpesch.
the class GpxFormatIT method testInputStream.
@Test
public void testInputStream() throws FileNotFoundException, JAXBException {
InputStream in = new FileInputStream(TEST_PATH + "from10.gpx");
Gpx gpx = (Gpx) GpxUtil.newUnmarshaller10().unmarshal(in);
assertNotNull(gpx);
assertNotNull(gpx.getWpt());
assertEquals(3, gpx.getWpt().size());
assertNotNull(gpx.getRte());
assertEquals(3, gpx.getRte().size());
assertNotNull(gpx.getTrk());
assertEquals(3, gpx.getRte().size());
}
Aggregations