Search in sources :

Example 31 with UnsupportedEncoderInputException

use of org.n52.svalbard.encode.exception.UnsupportedEncoderInputException in project arctic-sea by 52North.

the class SensorMLEncoderv20 method encode.

@Override
public XmlObject encode(Object objectToEncode, EncodingContext additionalValues) throws EncodingException {
    XmlObject encodedObject = null;
    try {
        if (objectToEncode instanceof AbstractSensorML) {
            AbstractSensorML description = (AbstractSensorML) objectToEncode;
            if (description.isSetXml()) {
                encodedObject = XmlObject.Factory.parse(((AbstractSensorML) objectToEncode).getXml());
                addValuesToXmlObject(encodedObject, (AbstractSensorML) objectToEncode);
                encodedObject = checkForAdditionalValues(encodedObject, additionalValues);
            } else {
                encodedObject = encodeDescription(description, additionalValues);
            }
        } else {
            throw new UnsupportedEncoderInputException(this, objectToEncode);
        }
    } catch (XmlException xmle) {
        throw new EncodingException(xmle);
    }
    // check if all gml:id are unique
    XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
    XmlHelper.validateDocument(encodedObject, EncodingException::new);
    return encodedObject;
}
Also used : AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)29 XmlObject (org.apache.xmlbeans.XmlObject)16 EncodingException (org.n52.svalbard.encode.exception.EncodingException)12 XmlException (org.apache.xmlbeans.XmlException)5 Geometry (org.locationtech.jts.geom.Geometry)3 LineString (org.locationtech.jts.geom.LineString)3 Point (org.locationtech.jts.geom.Point)3 Polygon (org.locationtech.jts.geom.Polygon)3 GeometryPropertyType (net.opengis.gml.x32.GeometryPropertyType)2 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)2 OmObservation (org.n52.shetland.ogc.om.OmObservation)2 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)2 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)2 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)2 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)2 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)2 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)2 SweField (org.n52.shetland.ogc.swe.SweField)2 EnvelopeOrGeometry (org.n52.shetland.util.EnvelopeOrGeometry)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1