Search in sources :

Example 46 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.

the class Kml22Format method createRoute.

private PlacemarkType createRoute(KmlRoute route) {
    ObjectFactory objectFactory = new ObjectFactory();
    PlacemarkType placemarkType = objectFactory.createPlacemarkType();
    // deactivated to preserve route name in folder name
    // placemarkType.setName(ROUTE);
    // placemarkType.setDescription(asDescription(route.getDescription()));
    placemarkType.setStyleUrl("#" + ROUTE_LINE_STYLE);
    MultiGeometryType multiGeometryType = objectFactory.createMultiGeometryType();
    placemarkType.setAbstractGeometryGroup(objectFactory.createMultiGeometry(multiGeometryType));
    LineStringType lineStringType = objectFactory.createLineStringType();
    multiGeometryType.getAbstractGeometryGroup().add(objectFactory.createLineString(lineStringType));
    List<String> coordinates = lineStringType.getCoordinates();
    for (KmlPosition position : route.getPositions()) {
        coordinates.add(createCoordinates(position, false));
    }
    return placemarkType;
}
Also used : ObjectFactory(slash.navigation.kml.binding22.ObjectFactory) NavigationConversion.formatPositionAsString(slash.navigation.common.NavigationConversion.formatPositionAsString)

Example 47 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.

the class Gpx10Format method createTrack.

private List<Gpx.Trk> createTrack(GpxRoute route, int startIndex, int endIndex) {
    ObjectFactory objectFactory = new ObjectFactory();
    List<Gpx.Trk> trks = new ArrayList<>();
    Gpx.Trk trk = route.getOrigin(Gpx.Trk.class);
    if (trk != null && reuseReadObjectsForWriting)
        trk.getTrkseg().clear();
    else
        trk = objectFactory.createGpxTrk();
    if (isWriteMetaData()) {
        trk.setName(asRouteName(route.getName()));
        trk.setDesc(asDescription(route.getDescription()));
    }
    trks.add(trk);
    Gpx.Trk.Trkseg trkseg = objectFactory.createGpxTrkTrkseg();
    List<GpxPosition> positions = route.getPositions();
    for (int i = startIndex; i < endIndex; i++) {
        GpxPosition position = positions.get(i);
        BigDecimal latitude = formatPosition(position.getLatitude());
        BigDecimal longitude = formatPosition(position.getLongitude());
        if (latitude == null || longitude == null)
            continue;
        Gpx.Trk.Trkseg.Trkpt trkpt = position.getOrigin(Gpx.Trk.Trkseg.Trkpt.class);
        if (trkpt == null || !reuseReadObjectsForWriting)
            trkpt = objectFactory.createGpxTrkTrksegTrkpt();
        trkpt.setLat(latitude);
        trkpt.setLon(longitude);
        trkpt.setTime(isWriteTime() ? formatXMLTime(position.getTime()) : null);
        trkpt.setEle(isWriteElevation() ? formatElevation(position.getElevation()) : null);
        trkpt.setCourse(isWriteHeading() ? formatHeading(position.getHeading()) : null);
        trkpt.setSpeed(isWriteSpeed() && position.getSpeed() != null ? formatSpeed(kmhToMs(position.getSpeed())) : null);
        trkpt.setName(isWriteName() ? splitNameAndDesc ? asName(position.getDescription()) : trim(position.getDescription()) : null);
        trkpt.setDesc(isWriteName() && splitNameAndDesc ? asDesc(position.getDescription(), trkpt.getDesc()) : null);
        trkpt.setHdop(isWriteAccuracy() && position.getHdop() != null ? formatAccuracy(position.getHdop()) : null);
        trkpt.setPdop(isWriteAccuracy() && position.getPdop() != null ? formatAccuracy(position.getPdop()) : null);
        trkpt.setVdop(isWriteAccuracy() && position.getVdop() != null ? formatAccuracy(position.getVdop()) : null);
        trkpt.setSat(isWriteAccuracy() && position.getSatellites() != null ? formatInt(position.getSatellites()) : null);
        trkseg.getTrkpt().add(trkpt);
    }
    trk.getTrkseg().add(trkseg);
    return trks;
}
Also used : ArrayList(java.util.ArrayList) Gpx(slash.navigation.gpx.binding10.Gpx) BigDecimal(java.math.BigDecimal) ObjectFactory(slash.navigation.gpx.binding10.ObjectFactory)

Example 48 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.

the class Gpx10Format method createWayPoints.

private List<Gpx.Wpt> createWayPoints(GpxRoute route, int startIndex, int endIndex) {
    ObjectFactory objectFactory = new ObjectFactory();
    List<Gpx.Wpt> wpts = new ArrayList<>();
    List<GpxPosition> positions = route.getPositions();
    for (int i = startIndex; i < endIndex; i++) {
        GpxPosition position = positions.get(i);
        BigDecimal latitude = formatPosition(position.getLatitude());
        BigDecimal longitude = formatPosition(position.getLongitude());
        if (latitude == null || longitude == null)
            continue;
        Gpx.Wpt wpt = position.getOrigin(Gpx.Wpt.class);
        if (wpt == null || !reuseReadObjectsForWriting)
            wpt = objectFactory.createGpxWpt();
        wpt.setLat(latitude);
        wpt.setLon(longitude);
        wpt.setTime(isWriteTime() ? formatXMLTime(position.getTime()) : null);
        wpt.setEle(isWriteElevation() ? formatElevation(position.getElevation()) : null);
        wpt.setCourse(isWriteHeading() ? formatHeading(position.getHeading()) : null);
        wpt.setSpeed(isWriteSpeed() && position.getSpeed() != null ? formatSpeed(kmhToMs(position.getSpeed())) : null);
        if (isWriteSpeed() && reuseReadObjectsForWriting)
            wpt.setCmt(formatSpeedDescription(wpt.getCmt(), position.getSpeed()));
        if (isWriteHeading() && reuseReadObjectsForWriting)
            wpt.setCmt(addHeading(wpt.getCmt(), position.getHeading()));
        wpt.setName(isWriteName() ? splitNameAndDesc ? asName(position.getDescription()) : trim(position.getDescription()) : null);
        wpt.setDesc(isWriteName() && splitNameAndDesc ? asDesc(position.getDescription(), wpt.getDesc()) : null);
        wpt.setHdop(isWriteAccuracy() && position.getHdop() != null ? formatAccuracy(position.getHdop()) : null);
        wpt.setPdop(isWriteAccuracy() && position.getPdop() != null ? formatAccuracy(position.getPdop()) : null);
        wpt.setVdop(isWriteAccuracy() && position.getVdop() != null ? formatAccuracy(position.getVdop()) : null);
        wpt.setSat(isWriteAccuracy() && position.getSatellites() != null ? formatInt(position.getSatellites()) : null);
        wpts.add(wpt);
    }
    return wpts;
}
Also used : ObjectFactory(slash.navigation.gpx.binding10.ObjectFactory) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) Gpx(slash.navigation.gpx.binding10.Gpx)

Example 49 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory 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 50 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.

the class GoPal3RouteFormat method createGoPal.

private Tour createGoPal(GoPalRoute route, int startIndex, int endIndex) {
    ObjectFactory objectFactory = new ObjectFactory();
    Tour tour = objectFactory.createTour();
    tour.setOptions(createOptions(route));
    for (int i = startIndex; i < endIndex; i++) {
        GoPalPosition position = route.getPosition(i);
        Tour.Dest dest = objectFactory.createTourDest();
        if (position.getX() != null)
            dest.setLongitude(position.getX());
        if (position.getY() != null)
            dest.setLatitude(position.getY());
        dest.setCity(position.getCity());
        if (position.getCountry() != null)
            dest.setCountry(position.getCountry());
        if (position.getHouseNumber() != null)
            dest.setHouse(position.getHouseNumber());
        dest.setStreet(position.getStreet());
        dest.setZip(position.getZipCode());
        if (i == startIndex)
            dest.setStartPos((short) 1);
        tour.getDest().add(dest);
    }
    return tour;
}
Also used : ObjectFactory(slash.navigation.gopal.binding3.ObjectFactory) Tour(slash.navigation.gopal.binding3.Tour)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)35 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)26 Marshaller (javax.xml.bind.Marshaller)24 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)20 StringWriter (java.io.StringWriter)19 JAXBContext (javax.xml.bind.JAXBContext)19 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)18 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 ObjectFactory (no.seres.xsd.nav.inntektsmelding_m._20181211.ObjectFactory)16 QName (javax.xml.namespace.QName)15 BigInteger (java.math.BigInteger)13 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)13 XStream (com.thoughtworks.xstream.XStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)12 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)12 ObjectFactory (slash.navigation.kml.binding22.ObjectFactory)12 ObjectFactory (com.opensymphony.xwork2.ObjectFactory)11 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)11