Search in sources :

Example 6 with AbstractSamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.

the class SamplingEncoderv20 method addSampledFeatures.

protected void addSampledFeatures(SFSamplingFeatureType sfsft, AbstractSamplingFeature sampFeat) throws EncodingException {
    if (sampFeat.isSetSampledFeatures()) {
        for (AbstractFeature sampledFeature : sampFeat.getSampledFeatures()) {
            XmlObject encodeObjectToXml = encodeObjectToXml(GmlConstants.NS_GML_32, sampledFeature, new EncodingContext().with(XmlBeansEncodingFlags.REFERENCED));
            sfsft.addNewSampledFeature().set(encodeObjectToXml);
        }
    } else {
        sfsft.addNewSampledFeature().setHref(OGCConstants.UNKNOWN);
    }
}
Also used : AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject)

Example 7 with AbstractSamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.

the class SamplingEncoderv20 method encodeShape.

private void encodeShape(ShapeType xbShape, AbstractSamplingFeature sampFeat) throws EncodingException {
    Encoder<XmlObject, Geometry> encoder = getEncoder(GmlConstants.NS_GML_32, sampFeat.getGeometry());
    if (encoder != null) {
        XmlObject xmlObject = encoder.encode(sampFeat.getGeometry(), EncodingContext.of(XmlBeansEncodingFlags.GMLID, sampFeat.getGmlId()));
        if (xbShape.isSetAbstractGeometry()) {
            xbShape.getAbstractGeometry().set(xmlObject);
        } else {
            xbShape.addNewAbstractGeometry().set(xmlObject);
        }
        XmlHelper.substituteElement(xbShape.getAbstractGeometry(), xmlObject);
    } else {
        throw new EncodingException("Error while encoding geometry for feature, needed encoder is missing!");
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlObject(org.apache.xmlbeans.XmlObject)

Example 8 with AbstractSamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.

the class SamplingEncoderv20 method createFeature.

@Override
protected XmlObject createFeature(FeaturePropertyType featurePropertyType, AbstractFeature abstractFeature, EncodingContext context) throws EncodingException {
    if (abstractFeature instanceof AbstractSamplingFeature) {
        final AbstractSamplingFeature samplingFeature = (AbstractSamplingFeature) abstractFeature;
        String namespace;
        if (context.has(XmlEncoderFlags.ENCODE_NAMESPACE) && context.get(XmlEncoderFlags.ENCODE_NAMESPACE).isPresent() && context.get(XmlEncoderFlags.ENCODE_NAMESPACE).get() instanceof String) {
            namespace = (String) context.get(XmlEncoderFlags.ENCODE_NAMESPACE).get();
        } else {
            namespace = OMHelper.getNamespaceForFeatureType(samplingFeature.getFeatureType());
        }
        final XmlObject encodedXmlObject = encodeObjectToXml(namespace, samplingFeature);
        if (encodedXmlObject != null) {
            return encodedXmlObject;
        } else {
            if (samplingFeature.isSetXml()) {
                try {
                    // XmlDescription? <-- XmlCursor
                    return XmlObject.Factory.parse(samplingFeature.getXml());
                } catch (final XmlException xmle) {
                    throw new EncodingException("Error while encoding featurePropertyType!", xmle);
                }
            } else {
                featurePropertyType.setHref(samplingFeature.getIdentifierCodeWithAuthority().getValue());
                if (samplingFeature.isSetName()) {
                    featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
                }
                return featurePropertyType;
            }
        }
    }
    return featurePropertyType;
}
Also used : AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString)

Example 9 with AbstractSamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.

the class SamplingEncoderv20 method setMetaDataProperty.

protected void setMetaDataProperty(SFSamplingFeatureType sfssft, AbstractSamplingFeature sampFeat) throws EncodingException {
    if (sampFeat.isSetMetaDataProperty()) {
        for (AbstractMetaData abstractMetaData : sampFeat.getMetaDataProperty()) {
            XmlObject encodeObject = encodeObjectToXml(GmlConstants.NS_GML_32, abstractMetaData);
            XmlObject substituteElement = XmlHelper.substituteElement(sfssft.addNewMetaDataProperty().addNewAbstractMetaData(), encodeObject);
            substituteElement.set(encodeObject);
        }
    }
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) AbstractMetaData(org.n52.shetland.ogc.gml.AbstractMetaData)

Example 10 with AbstractSamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.

the class GetFeatureOfInterestXmlStreamWriter method writeGetFeatureOfInterestResponseDoc.

private void writeGetFeatureOfInterestResponseDoc() throws XMLStreamException, EncodingException {
    start(Sos2StreamingConstants.QN_GET_FEATURE_OF_INTEREST_RESPONSE);
    namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
    namespace(Sos2Constants.NS_SOS_PREFIX, Sos2Constants.NS_SOS_20);
    // write schemaLocation
    schemaLocation(getSchemaLocation());
    AbstractFeature feature = getElement().getAbstractFeature();
    if (feature instanceof FeatureCollection) {
        for (AbstractFeature f : (FeatureCollection) feature) {
            writeFeatureMember(f);
        }
    } else if (feature instanceof AbstractSamplingFeature) {
        writeFeatureMember(feature);
    }
    end(Sos2StreamingConstants.QN_GET_FEATURE_OF_INTEREST_RESPONSE);
}
Also used : AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) FeatureCollection(org.n52.shetland.ogc.om.features.FeatureCollection) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature)

Aggregations

AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)14 XmlObject (org.apache.xmlbeans.XmlObject)11 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)8 XmlException (org.apache.xmlbeans.XmlException)5 Geometry (org.locationtech.jts.geom.Geometry)5 LineString (org.locationtech.jts.geom.LineString)5 EncodingException (org.n52.svalbard.encode.exception.EncodingException)5 Point (org.locationtech.jts.geom.Point)4 CodeType (org.n52.shetland.ogc.gml.CodeType)4 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)3 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)3 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)3 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)3 ArrayList (java.util.ArrayList)2 FeaturePropertyType (net.opengis.gml.x32.FeaturePropertyType)2 Coordinate (org.locationtech.jts.geom.Coordinate)2 MultiLineString (org.locationtech.jts.geom.MultiLineString)2 AbstractMetaData (org.n52.shetland.ogc.gml.AbstractMetaData)2 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2 TimeLocationValueTriple (org.n52.shetland.ogc.om.TimeLocationValueTriple)2