use of net.opengis.fes.x20.DistanceBufferType in project ddf by codice.
the class TestWfsFilterDelegate method testBeyondFilter.
@Test
public void testBeyondFilter() throws JAXBException, SAXException, IOException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Beyond.toString());
FilterType filter = delegate.beyond(Metacard.ANY_GEO, POLYGON, DISTANCE);
assertTrue(filter.isSetSpatialOps());
assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
assertXMLEqual(MockWfsServer.getBeyondXmlFilter(), getXmlFromMarshaller(filter));
}
use of net.opengis.fes.x20.DistanceBufferType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalNotOfSpatial.
@Test
public void testLogicalNotOfSpatial() throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType spatialFilter1 = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
//Perform Test
FilterType filter = delegate.not(spatialFilter1);
//Verify
assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicOpType.getSpatialOps().getValue();
assertThat(Double.toString(spatialOpsType1.getDistance().getValue()), is(Double.valueOf(1000).toString()));
}
use of net.opengis.fes.x20.DistanceBufferType in project ddf by codice.
the class TestWfsFilterDelegate method testDWithinFilterPolygon.
@Test
public void testDWithinFilterPolygon() throws SAXException, IOException, JAXBException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.DWithin.toString());
FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POLYGON, DISTANCE);
assertFalse(filter.isSetLogicOps());
assertTrue(filter.isSetSpatialOps());
assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
assertXMLEqual(MockWfsServer.getDWithinXmlFilter(), getXmlFromMarshaller(filter));
}
use of net.opengis.fes.x20.DistanceBufferType in project web-feature-service by 3dcitydb.
the class SpatialFilterBuilder method buildSpatialOperator.
public Predicate buildSpatialOperator(JAXBElement<?> spatialOpsElement, FeatureType featureType, NamespaceFilter namespaceFilter, String handle) throws WFSException {
if (!spatialOpsElement.getName().getNamespaceURI().equals(Constants.FES_NAMESPACE_URI))
throw new WFSException(WFSExceptionCode.OPTION_NOT_SUPPORTED, "Only spatial operators associated with the namespace " + Constants.FES_NAMESPACE_URI + " are supported.", handle);
// check whether the operator is advertised
if (!wfsConfig.getFilterCapabilities().getSpatialCapabilities().containsSpatialOperator(SpatialOperatorName.fromValue(spatialOpsElement.getName().getLocalPart())))
throw new WFSException(WFSExceptionCode.OPTION_NOT_SUPPORTED, "The spatial operator '" + spatialOpsElement.getName() + "' is not advertised.", handle);
Object operator = spatialOpsElement.getValue();
Predicate predicate = null;
if (operator instanceof BBOXType)
predicate = buildBBOXOperator((BBOXType) operator, spatialOpsElement.getName(), featureType, namespaceFilter, handle);
else if (operator instanceof BinarySpatialOpType)
predicate = buildBinaryOperator((BinarySpatialOpType) operator, spatialOpsElement.getName(), featureType, namespaceFilter, handle);
else if (operator instanceof DistanceBufferType)
predicate = buildDistanceOperator((DistanceBufferType) operator, spatialOpsElement.getName(), featureType, namespaceFilter, handle);
return predicate;
}
use of net.opengis.fes.x20.DistanceBufferType in project arctic-sea by 52North.
the class FesDecoderv20 method parseSpatialFilterType.
/**
* Parses the spatial filter of a request.
*
* @param xbSpatialOpsType
* 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 parseSpatialFilterType(SpatialOpsType xbSpatialOpsType) throws DecodingException {
SpatialFilter spatialFilter = new SpatialFilter();
try {
String localName = XmlHelper.getLocalName(xbSpatialOpsType);
spatialFilter.setOperator(FilterConstants.SpatialOperator.valueOf(localName));
if (xbSpatialOpsType instanceof BBOXType) {
BBOXType xbBBOX = (BBOXType) xbSpatialOpsType;
if (isValueReferenceExpression(xbBBOX.getExpression())) {
spatialFilter.setValueReference(parseValueReference(xbBBOX.getExpression()));
}
parseGeometry(xbSpatialOpsType, spatialFilter);
} else if (xbSpatialOpsType instanceof BinarySpatialOpType) {
BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) xbSpatialOpsType;
if (isValueReferenceExpression(binarySpatialOpType.getExpression())) {
spatialFilter.setValueReference(parseValueReference(binarySpatialOpType.getExpression()));
}
parseGeometry(xbSpatialOpsType, spatialFilter);
} else if (xbSpatialOpsType instanceof DistanceBufferType) {
DistanceBufferType distanceBufferType = (DistanceBufferType) xbSpatialOpsType;
if (isValueReferenceExpression(distanceBufferType.getExpression())) {
spatialFilter.setValueReference(parseValueReference(distanceBufferType.getExpression()));
}
if (distanceBufferType.getDistance() != null) {
spatialFilter.setDistance(new FesMeasureType(distanceBufferType.getDistance().getDoubleValue(), distanceBufferType.getDistance().getUom()));
}
parseGeometry(xbSpatialOpsType, spatialFilter);
} else {
throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter is not supported by this SOS!");
}
} catch (XmlException xmle) {
throw new DecodingException("Error while parsing spatial filter!", xmle);
}
return spatialFilter;
}
Aggregations