use of net.opengis.fes.x20.BBOXType in project ddf by codice.
the class TestWfsFilterDelegate method testIntersectsAsBoundingBox.
@Test
public void testIntersectsAsBoundingBox() throws SAXException, IOException, JAXBException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.toString());
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertNotNull(filter);
assertTrue(filter.getSpatialOps().getValue() instanceof BBOXType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getBboxXmlFilter(), getXmlFromMarshaller(filter));
}
use of net.opengis.fes.x20.BBOXType in project ddf by codice.
the class WfsFilterDelegate method buildBBoxType.
private JAXBElement<BBOXType> buildBBoxType(String propertyName, String wkt) {
BBOXType bboxType = new BBOXType();
JAXBElement<BoxType> box = createBoxType(wkt);
bboxType.setBox(box.getValue());
bboxType.setPropertyName(createPropertyNameType(propertyName).getValue());
return filterObjectFactory.createBBOX(bboxType);
}
use of net.opengis.fes.x20.BBOXType 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 {
if (xbSpatialOpsType instanceof BBOXType) {
spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
BBOXType xbBBOX = (BBOXType) xbSpatialOpsType;
if (isValueReferenceExpression(xbBBOX.getExpression())) {
spatialFilter.setValueReference(parseValueReference(xbBBOX.getExpression()));
}
XmlCursor geometryCursor = xbSpatialOpsType.newCursor();
if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE_32)) {
Object sosGeometry = decodeXmlObject(Factory.parse(geometryCursor.getDomNode()));
if (sosGeometry instanceof Geometry) {
spatialFilter.setGeometry((Geometry) sosGeometry);
} else if (sosGeometry instanceof ReferencedEnvelope) {
spatialFilter.setGeometry((ReferencedEnvelope) sosGeometry);
} else {
throw new UnsupportedDecoderXmlInputException(this, xbSpatialOpsType);
}
} else {
throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter operand is not supported by this SOS!");
}
geometryCursor.dispose();
} 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;
}
use of net.opengis.fes.x20.BBOXType in project arctic-sea by 52North.
the class FesEncoderv20 method encodeSpatialFilter.
private XmlObject encodeSpatialFilter(SpatialFilter spatialFilter) throws EncodingException {
final BBOXDocument bboxDoc = BBOXDocument.Factory.newInstance(getXmlOptions());
final BBOXType bbox = bboxDoc.addNewBBOX();
if (spatialFilter.hasValueReference()) {
bbox.set(encodeReferenceValue(spatialFilter.getValueReference()));
}
// TODO check if srid is needed, then add as HelperValue
bbox.setExpression(encodeExpression(spatialFilter.getGeometry()));
return bbox;
}
use of net.opengis.fes.x20.BBOXType in project arctic-sea by 52North.
the class FesEncoderv20Test method should_return_BBoxType_for_spatialFilter.
// @Test
// deactivated until test fails on build server.
public final void should_return_BBoxType_for_spatialFilter() throws EncodingException {
final SpatialFilter filter = new SpatialFilter();
filter.setOperator(SpatialOperator.BBOX);
filter.setGeometry(new GeometryFactory().toGeometry(new Envelope(1, 2, 3, 4)));
filter.setValueReference("valueReference");
final XmlObject encode = fesEncoder.encode(filter);
assertThat(encode, is(instanceOf(BBOXType.class)));
final BBOXType xbBBox = (BBOXType) encode;
assertThat(xbBBox.isSetExpression(), is(TRUE));
}
Aggregations