Search in sources :

Example 21 with ObjectFactory

use of org.geotoolkit.ops.xml.v110.ObjectFactory in project RouteConverter by cpesch.

the class GpxPositionExtension method setHeading.

public void setHeading(Double heading) {
    if (wptType.getExtensions() == null)
        wptType.setExtensions(new ObjectFactory().createExtensionsType());
    List<Object> anys = wptType.getExtensions().getAny();
    boolean foundHeading = false;
    for (Object any : anys) {
        if (any instanceof JAXBElement) {
            Object anyValue = ((JAXBElement) any).getValue();
            if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
                slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
                trackPoint.setCourse(formatHeading(heading));
                foundHeading = true;
            }
        } else if (any instanceof Element) {
            Element element = (Element) any;
            if ("course".equalsIgnoreCase(element.getLocalName())) {
                element.setTextContent(formatHeadingAsString(heading));
                foundHeading = true;
            }
        }
    }
    if (!foundHeading) {
        slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
        slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
        trackPointExtensionT.setCourse(formatHeading(heading));
        anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
    }
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) JAXBElement(javax.xml.bind.JAXBElement) ObjectFactory(slash.navigation.gpx.binding11.ObjectFactory)

Example 22 with ObjectFactory

use of org.geotoolkit.ops.xml.v110.ObjectFactory in project RouteConverter by cpesch.

the class GpxPositionExtension method setTemperature.

public void setTemperature(Double temperature) {
    if (wptType.getExtensions() == null)
        wptType.setExtensions(new ObjectFactory().createExtensionsType());
    List<Object> anys = wptType.getExtensions().getAny();
    boolean foundTemperature = false;
    for (Object any : anys) {
        if (any instanceof JAXBElement) {
            Object anyValue = ((JAXBElement) any).getValue();
            if (anyValue instanceof slash.navigation.gpx.garmin3.TrackPointExtensionT) {
                slash.navigation.gpx.garmin3.TrackPointExtensionT trackPoint = (slash.navigation.gpx.garmin3.TrackPointExtensionT) anyValue;
                trackPoint.setTemperature(formatTemperatureAsDouble(temperature));
                foundTemperature = true;
            } else if (anyValue instanceof slash.navigation.gpx.trackpoint1.TrackPointExtensionT) {
                slash.navigation.gpx.trackpoint1.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint1.TrackPointExtensionT) anyValue;
                if (isEmpty(trackPoint.getAtemp()) && isEmpty(temperature))
                    trackPoint.setWtemp(null);
                trackPoint.setAtemp(formatTemperatureAsDouble(temperature));
                foundTemperature = true;
            } else if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
                slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
                if (isEmpty(trackPoint.getAtemp()) && isEmpty(temperature))
                    trackPoint.setWtemp(null);
                trackPoint.setAtemp(formatTemperatureAsDouble(temperature));
                foundTemperature = true;
            }
        } else if (any instanceof Element) {
            Element element = (Element) any;
            if ("temperature".equalsIgnoreCase(element.getLocalName())) {
                element.setTextContent(formatTemperatureAsString(temperature));
                foundTemperature = true;
            }
        }
    }
    // create new TrackPointExtension v2 element if there was no existing value found
    if (!foundTemperature) {
        slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
        slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
        trackPointExtensionT.setAtemp(formatTemperatureAsDouble(temperature));
        anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
    }
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) JAXBElement(javax.xml.bind.JAXBElement) ObjectFactory(slash.navigation.gpx.binding11.ObjectFactory)

Example 23 with ObjectFactory

use of org.geotoolkit.ops.xml.v110.ObjectFactory in project RouteConverter by cpesch.

the class GpxPositionExtension method setSpeed.

public void setSpeed(Double speed) {
    if (wptType.getExtensions() == null)
        wptType.setExtensions(new ObjectFactory().createExtensionsType());
    List<Object> anys = wptType.getExtensions().getAny();
    boolean foundSpeed = false;
    for (Object any : anys) {
        if (any instanceof JAXBElement) {
            Object anyValue = ((JAXBElement) any).getValue();
            if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
                slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
                trackPoint.setSpeed(formatSpeedAsDouble(kmhToMs(speed)));
                foundSpeed = true;
            }
        } else if (any instanceof Element) {
            Element element = (Element) any;
            if ("speed".equalsIgnoreCase(element.getLocalName())) {
                element.setTextContent(formatSpeedAsString(kmhToMs(speed)));
                foundSpeed = true;
            }
        }
    }
    // create new TrackPointExtension v2 element if there was no existing value found
    if (!foundSpeed) {
        slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
        slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
        trackPointExtensionT.setSpeed(formatSpeedAsDouble(kmhToMs(speed)));
        anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
    }
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) JAXBElement(javax.xml.bind.JAXBElement) ObjectFactory(slash.navigation.gpx.binding11.ObjectFactory)

Example 24 with ObjectFactory

use of org.geotoolkit.ops.xml.v110.ObjectFactory in project RouteConverter by cpesch.

the class GpxPositionExtension method setHeartBeat.

public void setHeartBeat(Short heartBeat) {
    if (wptType.getExtensions() == null)
        wptType.setExtensions(new ObjectFactory().createExtensionsType());
    List<Object> anys = wptType.getExtensions().getAny();
    boolean foundHeartBeat = false;
    for (Object any : anys) {
        if (any instanceof JAXBElement) {
            Object anyValue = ((JAXBElement) any).getValue();
            if (anyValue instanceof slash.navigation.gpx.trackpoint1.TrackPointExtensionT) {
                slash.navigation.gpx.trackpoint1.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint1.TrackPointExtensionT) anyValue;
                trackPoint.setHr(heartBeat);
                foundHeartBeat = true;
            } else if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
                slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
                trackPoint.setHr(heartBeat);
                foundHeartBeat = true;
            }
        } else if (any instanceof Element) {
            Element element = (Element) any;
            if ("hr".equalsIgnoreCase(element.getLocalName())) {
                element.setTextContent(formatShortAsString(heartBeat));
                foundHeartBeat = true;
            }
        }
    }
    // create new TrackPointExtension v2 element if there was no existing value found
    if (!foundHeartBeat) {
        slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
        slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
        trackPointExtensionT.setHr(heartBeat);
        anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
    }
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) JAXBElement(javax.xml.bind.JAXBElement) ObjectFactory(slash.navigation.gpx.binding11.ObjectFactory)

Example 25 with ObjectFactory

use of org.geotoolkit.ops.xml.v110.ObjectFactory in project RouteConverter by cpesch.

the class Kml22Format method createKmlType.

private KmlType createKmlType(List<KmlRoute> routes) {
    ObjectFactory objectFactory = new ObjectFactory();
    KmlType kmlType = objectFactory.createKmlType();
    DocumentType documentType = objectFactory.createDocumentType();
    kmlType.setAbstractFeatureGroup(objectFactory.createDocument(documentType));
    documentType.setOpen(TRUE);
    if (hasCharacteristics(routes, Route))
        documentType.getAbstractStyleSelectorGroup().add(objectFactory.createStyle(createLineStyle(ROUTE_LINE_STYLE, getLineWidth(), getRouteLineColor())));
    if (hasCharacteristics(routes, Track)) {
        documentType.getAbstractStyleSelectorGroup().add(objectFactory.createStyle(createLineStyle(TRACK_LINE_STYLE, getLineWidth(), getTrackLineColor())));
        if (isWriteSpeed())
            for (StyleType style : createSpeedTrackColors(getSpeedLineWidth())) documentType.getAbstractStyleSelectorGroup().add(objectFactory.createStyle(style));
    }
    for (KmlRoute route : routes) {
        switch(route.getCharacteristics()) {
            case Waypoints:
                FolderType wayPointsFolder = objectFactory.createFolderType();
                wayPointsFolder.setName(createPlacemarkName(WAYPOINTS, route));
                wayPointsFolder.setDescription(asDescription(route.getDescription()));
                documentType.getAbstractFeatureGroup().add(objectFactory.createFolder(wayPointsFolder));
                List<PlacemarkType> wayPoints = createWayPoints(route, 0, route.getPositionCount());
                for (PlacemarkType wayPoint : wayPoints) wayPointsFolder.getAbstractFeatureGroup().add(objectFactory.createPlacemark(wayPoint));
                break;
            case Route:
                FolderType routeFolder = objectFactory.createFolderType();
                routeFolder.setName(createPlacemarkName(ROUTE, route));
                documentType.getAbstractFeatureGroup().add(objectFactory.createFolder(routeFolder));
                PlacemarkType routePlacemarks = createRoute(route);
                routeFolder.getAbstractFeatureGroup().add(objectFactory.createPlacemark(routePlacemarks));
                if (isWriteMarks())
                    routeFolder.getAbstractFeatureGroup().add(objectFactory.createFolder(createMarks(route, 0, route.getPositionCount())));
                break;
            case Track:
                FolderType trackFolder = objectFactory.createFolderType();
                trackFolder.setName(createPlacemarkName(TRACK, route));
                documentType.getAbstractFeatureGroup().add(objectFactory.createFolder(trackFolder));
                PlacemarkType track = createTrack(route, 0, route.getPositionCount());
                trackFolder.getAbstractFeatureGroup().add(objectFactory.createPlacemark(track));
                if (isWriteSpeed()) {
                    FolderType speed = createSpeed(route, 0, route.getPositionCount());
                    if (speed != null)
                        trackFolder.getAbstractFeatureGroup().add(objectFactory.createFolder(speed));
                }
                if (isWriteMarks())
                    trackFolder.getAbstractFeatureGroup().add(objectFactory.createFolder(createMarks(route, 0, route.getPositionCount())));
                break;
            default:
                throw new IllegalArgumentException("Unknown RouteCharacteristics " + route.getCharacteristics());
        }
    }
    return kmlType;
}
Also used : ObjectFactory(slash.navigation.kml.binding22.ObjectFactory)

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