Search in sources :

Example 11 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class GetObservationRequestDecoder method decodeRequest.

@Override
public GetObservationRequest decodeRequest(JsonNode node) throws DecodingException {
    GetObservationRequest r = new GetObservationRequest();
    r.setFeatureIdentifiers(parseStringOrStringList(node.path(JSONConstants.FEATURE_OF_INTEREST)));
    r.setObservedProperties(parseStringOrStringList(node.path(JSONConstants.OBSERVED_PROPERTY)));
    r.setOfferings(parseStringOrStringList(node.path(JSONConstants.OFFERING)));
    r.setProcedures(parseStringOrStringList(node.path(JSONConstants.PROCEDURE)));
    r.setResponseFormat(node.path(JSONConstants.RESPONSE_FORMAT).textValue());
    r.setResponseMode(node.path(JSONConstants.RESPONSE_MODE).textValue());
    r.setResultModel(node.path(JSONConstants.RESULT_MODEL).textValue());
    r.setResultFilter(parseComparisonFilter(node.path(JSONConstants.RESULT_FILTER)));
    r.setSpatialFilter(parseSpatialFilter(node.path(JSONConstants.SPATIAL_FILTER)));
    r.setTemporalFilters(parseTemporalFilters(node.path(JSONConstants.TEMPORAL_FILTER)));
    // TODO whats that for?
    r.setRequestString(Json.print(node));
    return r;
}
Also used : GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest)

Example 12 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class SosDecoderv100 method parseGetObservation.

/**
 * parses the XmlBean representing the getObservation request and creates a
 * SoSGetObservation request
 *
 * @param getObsDoc
 *            XmlBean created from the incoming request stream
 * @return Returns SosGetObservationRequest representing the request
 *
 * @throws DecodingException
 *             * If parsing the XmlBean failed
 */
private OwsServiceRequest parseGetObservation(GetObservationDocument getObsDoc) throws DecodingException {
    GetObservationRequest getObsRequest = new GetObservationRequest();
    GetObservation getObs = getObsDoc.getGetObservation();
    getObsRequest.setService(getObs.getService());
    getObsRequest.setVersion(getObs.getVersion());
    getObsRequest.setOfferings(Arrays.asList(getObs.getOffering()));
    getObsRequest.setObservedProperties(Arrays.asList(getObs.getObservedPropertyArray()));
    getObsRequest.setProcedures(Arrays.asList(getObs.getProcedureArray()));
    getObsRequest.setTemporalFilters(parseTemporalFilters4GetObservation(getObs.getEventTimeArray()));
    getObsRequest.setSrsName(getObs.getSrsName());
    if (getObs.isSetFeatureOfInterest()) {
        FeatureOfInterest featureOfInterest = getObs.getFeatureOfInterest();
        if (featureOfInterest.isSetSpatialOps()) {
            Object filter = decodeXmlElement(featureOfInterest.getSpatialOps());
            if (filter instanceof SpatialFilter) {
                getObsRequest.setSpatialFilter((SpatialFilter) filter);
            }
        } else if (featureOfInterest.getObjectIDArray() != null) {
            Set<String> featureIdentifiers = Sets.newHashSet();
            for (String string : featureOfInterest.getObjectIDArray()) {
                featureIdentifiers.add(string);
            }
            getObsRequest.setFeatureIdentifiers(Lists.newArrayList(featureIdentifiers));
        }
    }
    // TODO implement result filtering
    if (getObs.isSetResult()) {
        throw new NotYetSupportedDecodingException("Result filtering");
    }
    // return error message
    if (getObs.isSetResponseFormat()) {
        getObsRequest.setResponseFormat(decodeResponseFormat(getObs.getResponseFormat()));
    } else {
        getObsRequest.setResponseFormat(OmConstants.CONTENT_TYPE_OM.toString());
    }
    if (getObs.isSetResultModel()) {
        getObsRequest.setResultModel(OMHelper.getObservationTypeFor(getObs.getResultModel()));
    }
    return getObsRequest;
}
Also used : GetObservation(net.opengis.sos.x10.GetObservationDocument.GetObservation) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) Set(java.util.Set) GetFeatureOfInterest(net.opengis.sos.x10.GetFeatureOfInterestDocument.GetFeatureOfInterest) FeatureOfInterest(net.opengis.sos.x10.GetObservationDocument.GetObservation.FeatureOfInterest) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) XmlObject(org.apache.xmlbeans.XmlObject) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) NotYetSupportedDecodingException(org.n52.svalbard.decode.exception.NotYetSupportedDecodingException)

Example 13 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class SosDecoderv20Test method should_decode_boolean_swesExtensions.

@Test
public void should_decode_boolean_swesExtensions() throws XmlException, OwsExceptionReport, DecodingException {
    final GetObservationDocument doc = GetObservationDocument.Factory.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sos:GetObservation service=\"SOS\" version=\"2.0.0\"\n" + "    xmlns:sos=\"http://www.opengis.net/sos/2.0\"\n" + "    xmlns:swe=\"http://www.opengis.net/swe/2.0\"\n" + "    xmlns:swes=\"http://www.opengis.net/swes/2.0\">\n" + "    <swes:extension>\n" + "        <swe:Boolean definition=\"MergeObservationsIntoDataArray\">\n" + "            <swe:value>true</swe:value>\n" + "        </swe:Boolean>\n" + "    </swes:extension>\n" + "</sos:GetObservation>");
    final OwsServiceCommunicationObject decodedObject = decoder.decode(doc);
    assertThat(decodedObject, instanceOf(GetObservationRequest.class));
    final GetObservationRequest request = (GetObservationRequest) decodedObject;
    assertThat(request.getBooleanExtension("MergeObservationsIntoDataArray"), is(TRUE));
}
Also used : OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) GetObservationDocument(net.opengis.sos.x20.GetObservationDocument) Test(org.junit.Test)

Example 14 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class GetObservationRequest method setResultFilter.

public GetObservationRequest setResultFilter(ComparisonFilter filter) {
    this.resultFilter = filter;
    addExtension(new ResultFilter(filter));
    return this;
}
Also used : ResultFilter(org.n52.shetland.ogc.sos.ResultFilter)

Example 15 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class GetObservationRequestDecoderTest method hasObservedProperty.

@Test
public void hasObservedProperty() throws IOException, DecodingException {
    final GetObservationRequest req = loadSingle();
    assertThat(req.getObservedProperties(), is(notNullValue()));
    assertThat(req.getObservedProperties(), hasSize(1));
    assertThat(req.getObservedProperties().get(0), is(notNullValue()));
    assertThat(req.getObservedProperties().get(0), is(equalTo("observedProperty1")));
}
Also used : GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) Test(org.junit.Test)

Aggregations

GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)22 Test (org.junit.Test)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)3 GetObservationDocument (net.opengis.sos.x20.GetObservationDocument)2 DateTime (org.joda.time.DateTime)2 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)2 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 TRUE (java.lang.Boolean.TRUE)1 Arrays (java.util.Arrays)1 Set (java.util.Set)1 GetFeatureOfInterest (net.opengis.sos.x10.GetFeatureOfInterestDocument.GetFeatureOfInterest)1 GetObservation (net.opengis.sos.x10.GetObservationDocument.GetObservation)1 FeatureOfInterest (net.opengis.sos.x10.GetObservationDocument.GetObservation.FeatureOfInterest)1 GetObservationType (net.opengis.sos.x20.GetObservationType)1 InsertResultTemplateDocument (net.opengis.sos.x20.InsertResultTemplateDocument)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 XmlOptions (org.apache.xmlbeans.XmlOptions)1