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;
}
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;
}
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));
}
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;
}
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")));
}
Aggregations