Search in sources :

Example 1 with Gpx

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());
}
Also used : Gpx(slash.navigation.gpx.binding10.Gpx) Test(org.junit.Test)

Example 2 with Gpx

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);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Gpx(slash.navigation.gpx.binding10.Gpx)

Example 3 with Gpx

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;
}
Also used : Gpx(slash.navigation.gpx.binding10.Gpx)

Example 4 with 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;
}
Also used : ObjectFactory(slash.navigation.gpx.binding10.ObjectFactory) Gpx(slash.navigation.gpx.binding10.Gpx)

Example 5 with 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());
}
Also used : Gpx(slash.navigation.gpx.binding10.Gpx) Test(org.junit.Test)

Aggregations

Gpx (slash.navigation.gpx.binding10.Gpx)8 Test (org.junit.Test)3 ObjectFactory (slash.navigation.gpx.binding10.ObjectFactory)2 InputStreamReader (java.io.InputStreamReader)1 RouteCharacteristics (slash.navigation.base.RouteCharacteristics)1