use of org.n52.shetland.ogc.filter.SpatialFilter in project arctic-sea by 52North.
the class SpatialFilterDecoder method decodeJSON.
@Override
public SpatialFilter decodeJSON(JsonNode node, boolean validate) throws DecodingException {
if (node == null || node.isNull() || node.isMissingNode()) {
return null;
}
if (validate) {
JSONValidator.getInstance().validateAndThrow(node, SchemaConstants.Common.SPATIAL_FILTER);
}
if (node.isObject()) {
final String oName = node.fields().next().getKey();
final SOp o = SOp.valueOf(oName);
JsonNode value = node.path(oName).path(JSONConstants.VALUE);
JsonNode ref = node.path(oName).path(JSONConstants.REF);
return new SpatialFilter(o.getOp(), decodeGeometry(value), ref.textValue());
} else {
return null;
}
}
use of org.n52.shetland.ogc.filter.SpatialFilter in project arctic-sea by 52North.
the class ODataFesParserTest method testFeatureOfInterestShapeGeoIntersectsPolygon.
@Test
public void testFeatureOfInterestShapeGeoIntersectsPolygon() throws Exception {
Filter<?> filter = parser.decode(String.format("geo.intersects(featureOfInterest/shape,'SRID=%s;%s')", polygon.getSRID(), wktGeometry));
assertThat(filter, is(instanceOf(SpatialFilter.class)));
SpatialFilter sf = (SpatialFilter) filter;
errors.checkThat(sf.getSrid(), is(4326));
errors.checkThat(sf.getGeometry().isEnvelope(), is(false));
errors.checkThat(sf.getGeometry().isGeometry(), is(true));
errors.checkThat(sf.getGeometry().getGeometry().get(), is(instanceOf(Polygon.class)));
errors.checkThat(sf.getValueReference(), is("om:featureOfInterest/*/sams:shape"));
}
use of org.n52.shetland.ogc.filter.SpatialFilter in project arctic-sea by 52North.
the class ODataFesParserTest method testSamplingGeometryGeoIntersectsPolygon.
@Test
public void testSamplingGeometryGeoIntersectsPolygon() throws Exception {
Filter<?> filter = parser.decode(String.format("geo.intersects(samplingGeometry,'SRID=%s;%s')", polygon.getSRID(), wktGeometry));
assertThat(filter, is(instanceOf(SpatialFilter.class)));
SpatialFilter sf = (SpatialFilter) filter;
errors.checkThat(sf.getSrid(), is(4326));
errors.checkThat(sf.getGeometry().isEnvelope(), is(false));
errors.checkThat(sf.getGeometry().isGeometry(), is(true));
errors.checkThat(sf.getGeometry().getGeometry().get(), is(instanceOf(Polygon.class)));
errors.checkThat(sf.getValueReference(), is("http://www.opengis.net/req/omxml/2.0/data/samplingGeometry"));
}
use of org.n52.shetland.ogc.filter.SpatialFilter in project arctic-sea by 52North.
the class OgcDecoderv100 method parseBBOXFilterType.
/**
* Parses the spatial filter of a request.
*
* @param xbBBOX XmlBean representing the feature of interest parameter of the request
*
* @return Returns SpatialFilter created from the passed foi request parameter
*
* @throws DecodingException * if creation of the SpatialFilter failed
*/
private SpatialFilter parseBBOXFilterType(BBOXTypeImpl xbBBOX) throws DecodingException {
SpatialFilter spatialFilter = new SpatialFilter();
// FIXME local workaround for SOSHelper check value reference
String valueRef = "om:featureOfInterest/sams:SF_SpatialSamplingFeature/sams:shape";
try {
spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
XmlCursor geometryCursor = xbBBOX.newCursor();
if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE)) {
Object sosGeometry = decodeXmlElement(XmlObject.Factory.parse(geometryCursor.getDomNode()));
// }
if (sosGeometry instanceof Geometry) {
spatialFilter.setGeometry((Geometry) sosGeometry);
spatialFilter.setValueReference(valueRef);
}
} else {
throw unsupportedSpatialFilterOperand();
}
geometryCursor.dispose();
} catch (XmlException xmle) {
throw errorParsingSpatialFilter(xmle);
}
return spatialFilter;
}
Aggregations