Search in sources :

Example 46 with AbstractFeature

use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.

the class SamplingEncoderv100 method createFeatureCollection.

private XmlObject createFeatureCollection(FeatureCollection sosFeatureCollection) throws EncodingException {
    SamplingFeatureCollectionDocument xbSampFeatCollDoc = SamplingFeatureCollectionDocument.Factory.newInstance(getXmlOptions());
    SamplingFeatureCollectionType xbSampFeatColl = xbSampFeatCollDoc.addNewSamplingFeatureCollection();
    xbSampFeatColl.setId("sfc_" + Long.toString(new DateTime().getMillis()));
    for (AbstractFeature sosAbstractFeature : sosFeatureCollection.getMembers().values()) {
        SamplingFeaturePropertyType xbFeatMember = xbSampFeatColl.addNewMember();
        xbFeatMember.set(createFeature(sosAbstractFeature));
    }
    return xbSampFeatCollDoc;
}
Also used : SamplingFeatureCollectionType(net.opengis.sampling.x10.SamplingFeatureCollectionType) SamplingFeaturePropertyType(net.opengis.sampling.x10.SamplingFeaturePropertyType) SamplingFeatureCollectionDocument(net.opengis.sampling.x10.SamplingFeatureCollectionDocument) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) DateTime(org.joda.time.DateTime)

Example 47 with AbstractFeature

use of org.n52.shetland.ogc.gml.AbstractFeature 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

AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)33 XmlObject (org.apache.xmlbeans.XmlObject)23 XmlException (org.apache.xmlbeans.XmlException)10 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)10 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)9 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)9 OmObservation (org.n52.shetland.ogc.om.OmObservation)8 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)8 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)8 Test (org.junit.Test)6 LineString (org.locationtech.jts.geom.LineString)6 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)6 EncodingException (org.n52.svalbard.encode.exception.EncodingException)6 FeaturePropertyType (net.opengis.gml.x32.FeaturePropertyType)4 CodeType (org.n52.shetland.ogc.gml.CodeType)4 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)4 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)4 DateTime (org.joda.time.DateTime)3 Time (org.n52.shetland.ogc.gml.time.Time)3