use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.
the class WfsFilterDelegate method buildBBoxType.
private JAXBElement<BBOXType> buildBBoxType(String propertyName, String wkt) {
BBOXType bboxType = new BBOXType();
bboxType.setPropertyName(createPropertyNameType(propertyName).getValue());
EnvelopeType envelopeType = gmlObjectFactory.createEnvelopeType();
Envelope envelope = createEnvelopeFromWkt(wkt);
List<Double> lowerCornerCoordinates = coordinateStrategy.lowerCorner(envelope);
List<Double> upperCornerCoordinates = coordinateStrategy.upperCorner(envelope);
DirectPositionType lowerCorner = new DirectPositionType();
lowerCorner.setValue(lowerCornerCoordinates);
envelopeType.setLowerCorner(lowerCorner);
DirectPositionType upperCorner = new DirectPositionType();
upperCorner.setValue(upperCornerCoordinates);
envelopeType.setUpperCorner(upperCorner);
bboxType.setEnvelope(gmlObjectFactory.createEnvelope(envelopeType));
return filterObjectFactory.createBBOX(bboxType);
}
use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.
the class WfsFilterDelegateTest 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 org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.
the class WfsFilterDelegateTest method testDisjointAsNotBBox.
@Test
public void testDisjointAsNotBBox() throws SAXException, IOException, JAXBException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.toString());
FilterType filter = delegate.disjoint(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getLogicOps().getValue() instanceof UnaryLogicOpType);
UnaryLogicOpType type = (UnaryLogicOpType) filter.getLogicOps().getValue();
assertTrue(type.getSpatialOps().getValue() instanceof BBOXType);
assertXMLEqual(MockWfsServer.getNotBboxXmlFilter(), getXmlFromMarshaller(filter));
}
use of org.geotoolkit.ogc.xml.v110.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 {
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;
}
use of org.geotoolkit.ogc.xml.v110.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;
}
Aggregations