Search in sources :

Example 1 with FeaturePropertyType

use of net.opengis.gml.x32.FeaturePropertyType in project arctic-sea by 52North.

the class OmEncoderv20 method addFeature.

private void addFeature(OMObservationType xbObservationTemplate, Nillable<AbstractFeature> featureOfInterest) throws EncodingException {
    FeaturePropertyType xbFeatureOfInterest = xbObservationTemplate.addNewFeatureOfInterest();
    if (featureOfInterest.isNil() || featureOfInterest.isAbsent()) {
        xbFeatureOfInterest.setNilReason(NIL_REASON_TEMPLATE);
    } else {
        XmlObject xbEncodedFeature = encodeObjectToXmlPropertyType(featureOfInterest.get().getDefaultElementEncoding(), featureOfInterest.get(), EncodingContext.empty());
        xbFeatureOfInterest.set(xbEncodedFeature);
    }
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Example 2 with FeaturePropertyType

use of net.opengis.gml.x32.FeaturePropertyType in project arctic-sea by 52North.

the class GmlEncoderv321 method createFeature.

private XmlObject createFeature(AbstractFeature feature, EncodingContext ctx) throws EncodingException {
    FeaturePropertyType featurePropertyType = FeaturePropertyType.Factory.newInstance(getXmlOptions());
    if (isNotSamplingFeature(feature) || ctx.has(XmlBeansEncodingFlags.REFERENCED)) {
        featurePropertyType.setHref(feature.getIdentifierCodeWithAuthority().getValue());
        return featurePropertyType;
    } else {
        AbstractSamplingFeature samplingFeature = (AbstractSamplingFeature) feature;
        if (samplingFeature.isSetGmlID()) {
            featurePropertyType.setHref("#" + samplingFeature.getGmlId());
            return featurePropertyType;
        } else {
            if (ctx.has(XmlBeansEncodingFlags.ENCODE) && !ctx.getBoolean(XmlBeansEncodingFlags.ENCODE) || !samplingFeature.isEncode()) {
                featurePropertyType.setHref(feature.getIdentifierCodeWithAuthority().getValue());
                if (feature instanceof SamplingFeature && samplingFeature.isSetName()) {
                    featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
                }
                return featurePropertyType;
            }
            if (!samplingFeature.isSetGeometry()) {
                featurePropertyType.setHref(samplingFeature.getIdentifierCodeWithAuthority().getValue());
                if (samplingFeature.isSetName()) {
                    featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
                }
                return featurePropertyType;
            }
            if (samplingFeature.isSetUrl()) {
                featurePropertyType.setHref(samplingFeature.getUrl());
                if (samplingFeature.isSetName()) {
                    featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
                }
                return featurePropertyType;
            } else {
                String namespace = ctx.getString(XmlEncoderFlags.ENCODE_NAMESPACE).orElseGet(() -> OMHelper.getNamespaceForFeatureType(samplingFeature.getFeatureType()));
                XmlObject encodedXmlObject = encodeObjectToXml(namespace, samplingFeature);
                if (encodedXmlObject != null) {
                    return encodedXmlObject;
                } else {
                    if (feature.isSetXml()) {
                        try {
                            // XmlDescription? <-- XmlCursor
                            return XmlObject.Factory.parse(feature.getXml());
                        } catch (XmlException xmle) {
                            throw new EncodingException("Error while encoding featurePropertyType!", xmle);
                        }
                    } else {
                        featurePropertyType.setHref(feature.getIdentifierCodeWithAuthority().getValue());
                        if (samplingFeature.isSetName()) {
                            featurePropertyType.setTitle(feature.getFirstName().getValue());
                        }
                        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) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) XmlObject(org.apache.xmlbeans.XmlObject) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Example 3 with FeaturePropertyType

use of net.opengis.gml.x32.FeaturePropertyType in project arctic-sea by 52North.

the class GmlEncoderv321 method createFeatureCollection.

private XmlObject createFeatureCollection(FeatureCollection element, EncodingContext ctx) throws EncodingException {
    FeatureCollectionDocument featureCollectionDoc = FeatureCollectionDocument.Factory.newInstance(getXmlOptions());
    FeatureCollectionType featureCollection = featureCollectionDoc.addNewFeatureCollection();
    featureCollection.setId(element.getGmlId());
    EncodingContext context = ctx.with(XmlBeansEncodingFlags.PROPERTY_TYPE).without(XmlBeansEncodingFlags.DOCUMENT);
    if (element.isSetMembers()) {
        for (AbstractFeature abstractFeature : element.getMembers().values()) {
            featureCollection.addNewFeatureMember().set(createFeaturePropertyType(abstractFeature, context));
        }
    }
    if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
        return featureCollectionDoc;
    }
    FeaturePropertyType featurePropertyType = FeaturePropertyType.Factory.newInstance(getXmlOptions());
    featurePropertyType.addNewAbstractFeature().set(featureCollection);
    return XmlHelper.substituteElement(featurePropertyType.getAbstractFeature(), featurePropertyType);
// return featureCollection;
}
Also used : FeatureCollectionType(net.opengis.gml.x32.FeatureCollectionType) FeatureCollectionDocument(net.opengis.gml.x32.FeatureCollectionDocument) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Example 4 with FeaturePropertyType

use of net.opengis.gml.x32.FeaturePropertyType in project arctic-sea by 52North.

the class SwesDecoderv20 method parseRelatedFeature.

private List<SwesFeatureRelationship> parseRelatedFeature(final RelatedFeature[] relatedFeatureArray) throws DecodingException {
    List<SwesFeatureRelationship> sosRelatedFeatures = new ArrayList<>(relatedFeatureArray.length);
    for (final RelatedFeature relatedFeature : relatedFeatureArray) {
        final SwesFeatureRelationship sosFeatureRelationship = new SwesFeatureRelationship();
        final FeaturePropertyType fpt = relatedFeature.getFeatureRelationship().getTarget();
        if (fpt.getHref() != null && !fpt.getHref().isEmpty()) {
            final String identifier = fpt.getHref();
            final AbstractSamplingFeature feature = new SamplingFeature(new CodeWithAuthority(identifier));
            if (fpt.getTitle() != null && !fpt.getTitle().isEmpty()) {
                feature.setName(Lists.newArrayList(new CodeType(fpt.getTitle())));
            }
            if (checkForRequestUrl(fpt.getHref())) {
                feature.setUrl(fpt.getHref());
            }
            feature.setFeatureType(OGCConstants.UNKNOWN);
            sosFeatureRelationship.setFeature(feature);
        } else {
            final Object decodedObject = decodeXmlElement(fpt);
            if (decodedObject instanceof AbstractSamplingFeature) {
                sosFeatureRelationship.setFeature((AbstractSamplingFeature) decodedObject);
            } else {
                throw new DecoderResponseUnsupportedException(fpt.xmlText(), decodedObject);
            }
        }
        sosFeatureRelationship.setRole(relatedFeature.getFeatureRelationship().getRole());
        sosRelatedFeatures.add(sosFeatureRelationship);
    }
    return sosRelatedFeatures;
}
Also used : DecoderResponseUnsupportedException(org.n52.svalbard.decode.exception.DecoderResponseUnsupportedException) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) RelatedFeature(net.opengis.swes.x20.InsertSensorType.RelatedFeature) ArrayList(java.util.ArrayList) CodeType(org.n52.shetland.ogc.gml.CodeType) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) SwesFeatureRelationship(org.n52.shetland.ogc.swes.SwesFeatureRelationship) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Example 5 with FeaturePropertyType

use of net.opengis.gml.x32.FeaturePropertyType in project arctic-sea by 52North.

the class SensorMLDecoderV20 method parseFeatureOfInterest.

private void parseFeatureOfInterest(FeaturesOfInterest featuresOfInterest, AbstractProcessV20 abstractProcess) throws DecodingException {
    if (CollectionHelper.isNotNullOrEmpty(featuresOfInterest.getFeatureList().getFeatureArray())) {
        SmlFeatureOfInterest smlFeatureOfInterest = new SmlFeatureOfInterest();
        for (FeaturePropertyType fpt : featuresOfInterest.getFeatureList().getFeatureArray()) {
            Object o = decodeXmlElement(fpt);
            if (o instanceof AbstractFeature) {
                smlFeatureOfInterest.addFeatureOfInterest((AbstractFeature) o);
            }
        }
        abstractProcess.setSmlFeatureOfInterest(smlFeatureOfInterest);
    }
}
Also used : SmlFeatureOfInterest(org.n52.shetland.ogc.sensorML.v20.SmlFeatureOfInterest) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) DescribedObject(org.n52.shetland.ogc.sensorML.v20.DescribedObject) XmlObject(org.apache.xmlbeans.XmlObject) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Aggregations

FeaturePropertyType (net.opengis.gml.x32.FeaturePropertyType)6 XmlObject (org.apache.xmlbeans.XmlObject)5 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)2 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)2 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)2 ArrayList (java.util.ArrayList)1 FeatureCollectionDocument (net.opengis.gml.x32.FeatureCollectionDocument)1 FeatureCollectionType (net.opengis.gml.x32.FeatureCollectionType)1 RelatedFeature (net.opengis.swes.x20.InsertSensorType.RelatedFeature)1 XmlException (org.apache.xmlbeans.XmlException)1 LineString (org.locationtech.jts.geom.LineString)1 MultiLineString (org.locationtech.jts.geom.MultiLineString)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)1 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)1 DescribedObject (org.n52.shetland.ogc.sensorML.v20.DescribedObject)1 SmlFeatureOfInterest (org.n52.shetland.ogc.sensorML.v20.SmlFeatureOfInterest)1 SwesFeatureRelationship (org.n52.shetland.ogc.swes.SwesFeatureRelationship)1 DecoderResponseUnsupportedException (org.n52.svalbard.decode.exception.DecoderResponseUnsupportedException)1