Search in sources :

Example 11 with ReferenceType

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

the class PointObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue<?>) {
        super.setValue(value);
    } else if (value.getValue() instanceof CvDiscretePointCoverage) {
        super.setValue(value);
    } else {
        CvDiscretePointCoverage cvDiscretePointCoverage = new CvDiscretePointCoverage(getObservationID());
        cvDiscretePointCoverage.setRangeType(new ReferenceType(getObservationConstellation().getObservablePropertyIdentifier()));
        cvDiscretePointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
        Geometry geometry = null;
        String domainExtent = "";
        if (isSetSpatialFilteringProfileParameter() && getSpatialFilteringProfileParameter().getValue() instanceof GeometryValue) {
            GeometryValue geometryValue = (GeometryValue) getSpatialFilteringProfileParameter().getValue();
            geometry = getSpatialFilteringProfileParameter().getValue().getValue();
            domainExtent = geometryValue.getGmlId();
        } else if (checkForFeatureGeometry(this)) {
            geometry = getGeometryFromFeature(this);
            domainExtent = getObservationConstellation().getFeatureOfInterest().getGmlId();
        }
        if (geometry != null) {
            cvDiscretePointCoverage.setDomainExtent("#" + geometry.getGeometryType() + "_" + domainExtent);
            Point point = null;
            if (geometry instanceof Point) {
                point = (Point) geometry;
            } else {
                point = geometry.getCentroid();
            }
            cvDiscretePointCoverage.setValue(new PointValuePair(point, value.getValue()));
        }
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), cvDiscretePointCoverage));
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) CvDiscretePointCoverage(org.n52.shetland.ogc.om.values.CvDiscretePointCoverage) AbstractObservationValue(org.n52.shetland.ogc.om.AbstractObservationValue) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) Point(org.locationtech.jts.geom.Point) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Example 12 with ReferenceType

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

the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.

private Collection<DataAvailability> parseDataAvalabilities(net.opengis.sosgda.x20.GetDataAvailabilityResponseType response) throws DecodingException {
    List<DataAvailability> availabilities = Lists.newArrayList();
    if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
        Map<String, TimePeriod> periods = Maps.newHashMap();
        for (net.opengis.sosgda.x20.DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
            ReferenceType procedure = decodeXmlElement(damt.getProcedure());
            ReferenceType offering = decodeXmlElement(damt.getOffering());
            ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
            ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
            TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
            DataAvailability dataAvailability = new DataAvailability(procedure, observedProperty, featureOfInterest, offering, phenomenonTime);
            FormatDescriptor formatDescriptor = createFormatDescriptor(damt.getFormatDescriptor());
            if (formatDescriptor != null) {
                dataAvailability.setFormatDescriptor(formatDescriptor);
            }
            availabilities.add(dataAvailability);
        }
    }
    return availabilities;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) ProcedureDescriptionFormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ProcedureDescriptionFormatDescriptor) ObservationFormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ObservationFormatDescriptor) FormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.FormatDescriptor) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType)

Example 13 with ReferenceType

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

the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.

private Collection<DataAvailability> parseDataAvalabilities(GetDataAvailabilityResponseType response) throws DecodingException {
    List<DataAvailability> availabilities = Lists.newArrayList();
    if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
        Map<String, TimePeriod> periods = Maps.newHashMap();
        for (DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
            ReferenceType procedure = decodeXmlElement(damt.getProcedure());
            ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
            ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
            TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
            availabilities.add(new DataAvailability(procedure, observedProperty, featureOfInterest, null, phenomenonTime));
        }
    }
    return availabilities;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) DataAvailabilityMemberType(net.opengis.sosgda.x10.DataAvailabilityMemberType)

Example 14 with ReferenceType

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

the class GetDataAvailabilityXmlEncoderTest method test.

@Test
public void test() throws EncodingException {
    GetDataAvailabilityResponse response = new GetDataAvailabilityResponse("SOS", "2.0.0");
    response.setNamespace(GetDataAvailabilityConstants.NS_GDA);
    DateTime begin = DateTime.now().withZone(DateTimeZone.UTC);
    DateTime end = begin.plusHours(1).withZone(DateTimeZone.UTC);
    TimePeriod timePeriod = new TimePeriod(begin, end);
    ReferenceType procedure = new ReferenceType("procedure");
    ReferenceType observedProperty = new ReferenceType("observedProperty");
    ReferenceType featureOfInterest = new ReferenceType("featureOfInterest");
    ReferenceType offering = new ReferenceType("offering");
    int count = 100;
    response.addDataAvailability(new DataAvailability(procedure, observedProperty, featureOfInterest, offering, timePeriod, count));
    XmlObject encoded = encoder.encode(response);
    System.out.println(encoded.xmlText());
    errors.checkThat(encoded.xmlText(), is(String.format("<gda:GetDataAvailabilityResponse xsi:schemaLocation=\"http://www.opengis.net/sosgda/1.0 http://waterml2.org/schemas/gda/1.0/gda.xsd\" " + "xmlns:gda=\"http://www.opengis.net/sosgda/1.0\" " + "xmlns:gml=\"http://www.opengis.net/gml/3.2\" " + "xmlns:swe=\"http://www.opengis.net/swe/2.0\" " + "xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + "  <gda:dataAvailabilityMember gml:id=\"dam_1\">\n" + "    <gda:procedure xlink:href=\"procedure\" xlink:title=\"procedure\"/>\n" + "    <gda:observedProperty xlink:href=\"observedProperty\" xlink:title=\"observedProperty\"/>\n" + "    <gda:featureOfInterest xlink:href=\"featureOfInterest\" xlink:title=\"featureOfInterest\"/>\n" + "    <gda:phenomenonTime>\n" + "      <gml:TimePeriod gml:id=\"tp_1\">\n" + "        <gml:beginPosition>%s</gml:beginPosition>\n" + "        <gml:endPosition>%s</gml:endPosition>\n" + "      </gml:TimePeriod>\n" + "    </gda:phenomenonTime>\n" + "    <gda:count>100</gda:count>\n" + "    <gda:extension>\n" + "      <swe:Text definition=\"offering\">\n" + "        <swe:value>offering</swe:value>\n" + "      </swe:Text>\n" + "    </gda:extension>\n" + "  </gda:dataAvailabilityMember>\n" + "</gda:GetDataAvailabilityResponse>", begin.toString(ISODateTimeFormat.dateTime()), end.toString(ISODateTimeFormat.dateTime()))));
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) GetDataAvailabilityResponse(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse) XmlObject(org.apache.xmlbeans.XmlObject) DateTime(org.joda.time.DateTime) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) Test(org.junit.Test)

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