Search in sources :

Example 6 with ReferenceType

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

the class OmDecoderv20 method getResult.

private ObservationValue<?> getResult(OMObservationType omObservation) throws DecodingException {
    XmlObject xbResult = omObservation.getResult();
    if (xbResult.schemaType() == XmlAnyTypeImpl.type) {
        // Template observation for InsertResultTemplate operation
        if (!xbResult.getDomNode().hasChildNodes()) {
            return new SingleObservationValue<>(new NilTemplateValue());
        } else {
            try {
                xbResult = XmlObject.Factory.parse(xbResult.xmlText().trim());
            } catch (XmlException e) {
                LOGGER.error("Error while parsing NamedValueValue", e);
            }
        }
    }
    if (xbResult.schemaType() == XmlBoolean.type) {
        // TruthObservation
        XmlBoolean xbBoolean = (XmlBoolean) xbResult;
        BooleanValue booleanValue = new BooleanValue(xbBoolean.getBooleanValue());
        return new SingleObservationValue<>(booleanValue);
    } else if (xbResult.schemaType() == XmlInteger.type) {
        // CountObservation
        XmlInteger xbInteger = (XmlInteger) xbResult;
        CountValue countValue = new CountValue(Integer.parseInt(xbInteger.getBigIntegerValue().toString()));
        return new SingleObservationValue<>(countValue);
    } else if (xbResult.schemaType() == XmlString.type) {
        // TextObservation
        XmlString xbString = (XmlString) xbResult;
        TextValue stringValue = new TextValue(xbString.getStringValue());
        return new SingleObservationValue<>(stringValue);
    } else {
        // result elements with other encoding like SWE_ARRAY_OBSERVATION
        Object decodedObject = decodeXmlObject(xbResult);
        if (decodedObject instanceof ObservationValue) {
            return (ObservationValue<?>) decodedObject;
        } else if (decodedObject instanceof GmlMeasureType) {
            GmlMeasureType measureType = (GmlMeasureType) decodedObject;
            QuantityValue quantitiyValue = new QuantityValue(measureType.getValue(), measureType.getUnit());
            return new SingleObservationValue<>(quantitiyValue);
        } else if (decodedObject instanceof ReferenceType) {
            if (omObservation.isSetType() && omObservation.getType().isSetHref() && omObservation.getType().getHref().equals(OmConstants.OBS_TYPE_REFERENCE_OBSERVATION)) {
                return new SingleObservationValue<>(new ReferenceValue((ReferenceType) decodedObject));
            }
            return new SingleObservationValue<>(new CategoryValue(((ReferenceType) decodedObject).getHref()));
        } else if (decodedObject instanceof Geometry) {
            return new SingleObservationValue<>(new GeometryValue((Geometry) decodedObject));
        } else if (decodedObject instanceof AbstractGeometry) {
            SingleObservationValue<Geometry> result = new SingleObservationValue<>();
            result.setValue(new GeometryValue(((AbstractGeometry) decodedObject).getGeometry()));
            return result;
        } else if (decodedObject instanceof SweDataArray) {
            return new SingleObservationValue<>(new SweDataArrayValue((SweDataArray) decodedObject));
        } else if (decodedObject instanceof SweDataRecord) {
            return new SingleObservationValue<>(new ComplexValue((SweDataRecord) decodedObject));
        }
        throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested result type '{}' is not supported by this service!", decodedObject.getClass().getSimpleName());
    }
}
Also used : AbstractGeometry(org.n52.shetland.ogc.gml.AbstractGeometry) XmlBoolean(org.apache.xmlbeans.XmlBoolean) ReferenceValue(org.n52.shetland.ogc.om.values.ReferenceValue) XmlInteger(org.apache.xmlbeans.XmlInteger) DecodingException(org.n52.svalbard.decode.exception.DecodingException) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) SweDataArrayValue(org.n52.shetland.ogc.om.values.SweDataArrayValue) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) CountValue(org.n52.shetland.ogc.om.values.CountValue) BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) XmlString(org.apache.xmlbeans.XmlString) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) Geometry(org.locationtech.jts.geom.Geometry) AbstractGeometry(org.n52.shetland.ogc.gml.AbstractGeometry) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) XmlException(org.apache.xmlbeans.XmlException) TextValue(org.n52.shetland.ogc.om.values.TextValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) ObservationValue(org.n52.shetland.ogc.om.ObservationValue) NilTemplateValue(org.n52.shetland.ogc.om.values.NilTemplateValue) GmlMeasureType(org.n52.shetland.ogc.gml.GmlMeasureType)

Example 7 with ReferenceType

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

the class RelatedOfferingTypeDecoder method parseRelatedOffering.

private OfferingContext parseRelatedOffering(RelatedOffering relatedOffering) throws DecodingException {
    ReferenceType role = decodeXmlElement(relatedOffering.getOfferingContext().getRole());
    ReferenceType relOff = decodeXmlElement(relatedOffering.getOfferingContext().getRelatedOffering());
    return new OfferingContext(role, relOff);
}
Also used : ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) OfferingContext(org.n52.shetland.ogc.sos.ro.OfferingContext)

Example 8 with ReferenceType

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

the class WmlObservationProcessDecoderv20Test method getReferencedNamedValue.

private NamedValue<ReferenceType> getReferencedNamedValue() {
    NamedValue<ReferenceType> nv = new NamedValue<ReferenceType>();
    nv.setName(getNameValueOfferingName());
    nv.setValue(new ReferenceValue(new ReferenceType(REF_OFFERING)));
    return nv;
}
Also used : ReferenceValue(org.n52.shetland.ogc.om.values.ReferenceValue) NamedValue(org.n52.shetland.ogc.om.NamedValue) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType)

Example 9 with ReferenceType

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

the class WmlTVPEncoderv20Test method shouldEncodeInterpolationType.

@Test
public void shouldEncodeInterpolationType() throws EncodingException, XmlException {
    final InterpolationType type = WaterMLConstants.InterpolationType.MinPrec;
    mv.setDefaultPointMetadata(new DefaultPointMetadata().setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));
    XmlObject encodedElement = encoder.encode(mv);
    TVPDefaultMetadataPropertyType defaultPointMetadata = ((MeasurementTimeseriesDocument) encodedElement).getTimeseries().getDefaultPointMetadataArray(0);
    DefaultTVPMeasurementMetadataDocument tvpMeasurementMetadataDocument = DefaultTVPMeasurementMetadataDocument.Factory.parse(defaultPointMetadata.xmlText());
    ReferenceType interpolationType = tvpMeasurementMetadataDocument.getDefaultTVPMeasurementMetadata().getInterpolationType();
    Assert.assertThat(interpolationType.getHref(), Is.is("http://www.opengis.net/def/waterml/2.0/interpolationType/MinPrec"));
    Assert.assertThat(interpolationType.getTitle(), Is.is("MinPrec"));
}
Also used : DefaultPointMetadata(org.n52.shetland.ogc.om.series.wml.DefaultPointMetadata) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata) XmlObject(org.apache.xmlbeans.XmlObject) DefaultTVPMeasurementMetadataDocument(net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument) InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType) ReferenceType(net.opengis.gml.x32.ReferenceType) Test(org.junit.Test)

Example 10 with ReferenceType

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

the class ObservationDecoder method parseNamedValue.

private NamedValue<?> parseNamedValue(JsonNode parameter) throws DecodingException {
    JsonNode namedValue = parameter.path(JSONConstants.NAMED_VALUE);
    NamedValue<?> nv = parseNamedValueValue(namedValue.path(JSONConstants.VALUE));
    ReferenceType referenceType = new ReferenceType(namedValue.path(JSONConstants.NAME).asText());
    nv.setName(referenceType);
    return nv;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType)

Aggregations

ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)11 Geometry (org.locationtech.jts.geom.Geometry)4 GeometryValue (org.n52.shetland.ogc.om.values.GeometryValue)4 XmlObject (org.apache.xmlbeans.XmlObject)3 Test (org.junit.Test)3 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)3 DataAvailability (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)3 ReferenceType (net.opengis.gml.x32.ReferenceType)2 NamedValue (org.n52.shetland.ogc.om.NamedValue)2 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)2 ReferenceValue (org.n52.shetland.ogc.om.values.ReferenceValue)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 NamedValueType (net.opengis.om.x20.NamedValueType)1 DataAvailabilityMemberType (net.opengis.sosgda.x10.DataAvailabilityMemberType)1 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)1 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)1 XmlBoolean (org.apache.xmlbeans.XmlBoolean)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlInteger (org.apache.xmlbeans.XmlInteger)1