Search in sources :

Example 41 with AbstractFeature

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

the class AbstractAqdResponseEncoder method processObservation.

protected void processObservation(OmObservation observation, TimePeriod timePeriod, TimeInstant resultTime, FeatureCollection featureCollection, AbstractEReportingHeader eReportingHeader, int counter) {
    if (observation.isSetPhenomenonTime()) {
        // generate gml:id
        observation.setGmlId(getObservationId(counter));
        // add xlink:href to eReportingHeader.content
        eReportingHeader.addContent((AbstractFeature) new OmObservation().setIdentifier(new CodeWithAuthority(getObservationXlink(observation.getGmlId()))));
        timePeriod.extendToContain(observation.getPhenomenonTime());
        observation.setResultTime(resultTime);
        featureCollection.addMember(observation);
    }
}
Also used : OmObservation(org.n52.shetland.ogc.om.OmObservation) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 42 with AbstractFeature

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

the class AbstractOmV20XmlStreamWriter method writeFeatureOfIntererst.

/**
 * Write om:featureOfInterest encoded or as xlink:href to stream
 *
 * @throws XMLStreamException
 *             If an error occurs when writing to stream
 * @throws EncodingException
 *             If an error occurs when creating elements to be written
 */
protected void writeFeatureOfIntererst() throws XMLStreamException, EncodingException {
    Optional<String> namespace = getDefaultFeatureEncodingNamespace();
    AbstractFeature foi = getElement().getObservationConstellation().getFeatureOfInterest();
    if (namespace.isPresent()) {
        EncodingContext codingContext = EncodingContext.of(XmlEncoderFlags.ENCODE_NAMESPACE, namespace.get());
        Encoder<XmlObject, AbstractFeature> encoder = getEncoder(GmlConstants.NS_GML_32, foi);
        writeXmlObject(encoder.encode(foi, codingContext), OmConstants.QN_OM_20_FEATURE_OF_INTEREST);
    } else {
        empty(OmConstants.QN_OM_20_FEATURE_OF_INTEREST);
        addXlinkHrefAttr(foi.getIdentifier());
        if (foi.isSetName() && foi.getFirstName().isSetValue()) {
            addXlinkTitleAttr(foi.getFirstName().getValue());
        }
    }
}
Also used : EncodingContext(org.n52.svalbard.encode.EncodingContext) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject)

Example 43 with AbstractFeature

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

Example 44 with AbstractFeature

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

the class SosDecoderv20 method checkReferencedElements.

private void checkReferencedElements(final List<OmObservation> observations, final Map<String, Time> phenomenonTimes, final Map<String, TimeInstant> resultTimes, final Map<String, AbstractFeature> features) throws DecodingException {
    for (final OmObservation observation : observations) {
        // phenomenonTime
        final Time phenomenonTime = observation.getPhenomenonTime();
        if (phenomenonTime.isReferenced()) {
            observation.getValue().setPhenomenonTime(phenomenonTimes.get(phenomenonTime.getGmlId()));
        }
        // resultTime
        final TimeInstant resultTime = observation.getResultTime();
        if (resultTime.isReferenced()) {
            if (resultTimes.containsKey(resultTime.getGmlId())) {
                observation.setResultTime(resultTimes.get(resultTime.getGmlId()));
            } else if (phenomenonTimes.containsKey(resultTime.getGmlId())) {
                final Time iTime = phenomenonTimes.get(resultTime.getGmlId());
                if (iTime instanceof TimeInstant) {
                    observation.setResultTime((TimeInstant) iTime);
                } else if (iTime instanceof TimePeriod) {
                    final TimePeriod timePeriod = (TimePeriod) iTime;
                    observation.setResultTime(new TimeInstant(timePeriod.getEnd()));
                } else {
                    throw new DecodingException("observation.resultTime", "The time value type is not supported");
                }
            }
        }
        // featureOfInterest
        final AbstractFeature featureOfInterest = observation.getObservationConstellation().getFeatureOfInterest();
        if (featureOfInterest.isReferenced()) {
            observation.getObservationConstellation().setFeatureOfInterest(features.get(featureOfInterest.getGmlId()));
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Time(org.n52.shetland.ogc.gml.time.Time) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 45 with AbstractFeature

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

the class GmlDecoderv321 method parseFeatureCollectionType.

private FeatureCollection parseFeatureCollectionType(FeatureCollectionType featureCollectionType) throws DecodingException {
    final FeatureCollection feaColl = new FeatureCollection();
    for (FeaturePropertyType feaPropType : featureCollectionType.getFeatureMemberArray()) {
        Object decoded = decodeXmlElement(feaPropType);
        feaColl.addMember((AbstractFeature) decoded);
    }
    return feaColl;
}
Also used : FeatureCollection(org.n52.shetland.ogc.om.features.FeatureCollection) XmlObject(org.apache.xmlbeans.XmlObject) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

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