Search in sources :

Example 1 with SFSpatialSamplingFeatureType

use of net.opengis.samplingSpatial.x20.SFSpatialSamplingFeatureType in project arctic-sea by 52North.

the class SamplingDecoderv20 method getXmlDescription.

private String getXmlDescription(final SFSpatialSamplingFeatureType spatialSamplingFeature) {
    final SFSpatialSamplingFeatureDocument featureDoc = SFSpatialSamplingFeatureDocument.Factory.newInstance(getXmlOptions());
    featureDoc.setSFSpatialSamplingFeature(spatialSamplingFeature);
    return featureDoc.xmlText(getXmlOptions());
}
Also used : SFSpatialSamplingFeatureDocument(net.opengis.samplingSpatial.x20.SFSpatialSamplingFeatureDocument)

Example 2 with SFSpatialSamplingFeatureType

use of net.opengis.samplingSpatial.x20.SFSpatialSamplingFeatureType in project arctic-sea by 52North.

the class SamplingEncoderv20 method createFeature.

protected XmlObject createFeature(final AbstractFeature absFeature) throws EncodingException {
    if (absFeature instanceof AbstractSamplingFeature) {
        final AbstractSamplingFeature sampFeat = (AbstractSamplingFeature) absFeature;
        final SFSpatialSamplingFeatureDocument xbSampFeatDoc = SFSpatialSamplingFeatureDocument.Factory.newInstance(getXmlOptions());
        if (sampFeat.isSetXml()) {
            try {
                final XmlObject feature = XmlObject.Factory.parse(sampFeat.getXml(), getXmlOptions());
                if (XmlHelper.getNamespace(feature).equals(SfConstants.NS_SAMS)) {
                    XmlHelper.updateGmlIDs(feature.getDomNode().getFirstChild(), absFeature.getGmlId(), null);
                    if (feature instanceof SFSpatialSamplingFeatureType) {
                        xbSampFeatDoc.setSFSpatialSamplingFeature((SFSpatialSamplingFeatureType) feature);
                        encodeShape(xbSampFeatDoc.getSFSpatialSamplingFeature().getShape(), sampFeat);
                        addNameDescription(xbSampFeatDoc.getSFSpatialSamplingFeature(), sampFeat);
                        return xbSampFeatDoc;
                    }
                    encodeShape(((SFSpatialSamplingFeatureDocument) feature).getSFSpatialSamplingFeature().getShape(), sampFeat);
                    addNameDescription(((SFSpatialSamplingFeatureDocument) feature).getSFSpatialSamplingFeature(), sampFeat);
                    sampFeat.wasEncoded();
                    return feature;
                } else {
                    return encodeObjectToXml(XmlHelper.getNamespace(feature), absFeature);
                }
            } catch (final XmlException xmle) {
                throw new EncodingException("Error while encoding GetFeatureOfInterest response, invalid samplingFeature description!", xmle);
            }
        }
        final SFSpatialSamplingFeatureType xbSampFeature = xbSampFeatDoc.addNewSFSpatialSamplingFeature();
        // TODO: CHECK for all fields set gml:id
        addId(xbSampFeature, sampFeat);
        addIdentifier(xbSampFeature, sampFeat);
        // set type
        addFeatureType(xbSampFeature, sampFeat);
        // set type
        addNameDescription(xbSampFeature, sampFeat);
        setMetaDataProperty(xbSampFeature, sampFeat);
        // set sampledFeatures
        // TODO: CHECK
        addSampledFeatures(xbSampFeature, sampFeat);
        addParameter(xbSampFeature, sampFeat);
        // set position
        encodeShape(xbSampFeature.addNewShape(), sampFeat);
        sampFeat.wasEncoded();
        return xbSampFeatDoc;
    }
    throw new UnsupportedEncoderInputException(this, absFeature);
}
Also used : SFSpatialSamplingFeatureDocument(net.opengis.samplingSpatial.x20.SFSpatialSamplingFeatureDocument) 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) SFSpatialSamplingFeatureType(net.opengis.samplingSpatial.x20.SFSpatialSamplingFeatureType) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

SFSpatialSamplingFeatureDocument (net.opengis.samplingSpatial.x20.SFSpatialSamplingFeatureDocument)2 SFSpatialSamplingFeatureType (net.opengis.samplingSpatial.x20.SFSpatialSamplingFeatureType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1