use of org.n52.shetland.ogc.filter.Filter 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;
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class FesDecoderv20 method parseBinaryLogicalFilter.
/**
* parses a single binary logic filter of the requests and returns service
* binary logic filter
*
* @param binaryLogicOpType
* XmlObject representing the binary logic filter
* @return Service representation of binary logic filter
* @throws DecodingException
* if creation of the BinaryLogicFilter failed or filter size is
* less than two
*/
private BinaryLogicFilter parseBinaryLogicalFilter(BinaryLogicOpType binaryLogicOpType) throws DecodingException {
BinaryLogicFilter binaryLogicFilter = null;
String localName = XmlHelper.getLocalName(binaryLogicOpType);
if (localName.equals(BinaryLogicOperator.And.name())) {
binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.And);
} else if (localName.equals(BinaryLogicOperator.Or.name())) {
binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.Or);
} else {
throw new UnsupportedDecoderXmlInputException(this, binaryLogicOpType);
}
Set<Filter<?>> filters = getFilterPredicates(binaryLogicOpType);
if (filters.size() < 2) {
throw new DecodingException("The binary logic filter requires minimla two filter predicates!");
}
binaryLogicFilter.addFilterPredicates(filters);
return binaryLogicFilter;
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class FesDecoderv20 method parsePropertyIsLikeFilter.
/**
* Parse XML propertyIsLike element
*
* @param comparisonOpsType
* XML propertyIsLike element
* @return SOS comparison filter
* @throws DecodingException
* If an error occurs of the filter is not supported!
*/
private ComparisonFilter parsePropertyIsLikeFilter(PropertyIsLikeType comparisonOpsType) throws DecodingException {
ComparisonFilter comparisonFilter = new ComparisonFilter();
comparisonFilter.setOperator(ComparisonOperator.PropertyIsLike);
comparisonFilter.setEscapeString(comparisonOpsType.getEscapeChar());
comparisonFilter.setSingleChar(comparisonOpsType.getSingleChar());
comparisonFilter.setWildCard(comparisonOpsType.getWildCard());
parseExpressions(comparisonOpsType.getExpressionArray(), comparisonFilter);
return comparisonFilter;
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class SosV1GetCapabilitiesResponseEncoder method setSpatialFilterCapabilities.
/**
* Sets the SpatialFilterCapabilities.
*
* !!! Modify method addicted to your implementation !!!
*
* @param spatialCapabilities SpatialCapabilities.
* @param sosFilterCaps the SOS filter capabilities
*/
protected void setSpatialFilterCapabilities(SpatialCapabilitiesType spatialCapabilities, org.n52.shetland.ogc.filter.FilterCapabilities sosFilterCaps) {
// set GeometryOperands
if (!sosFilterCaps.getSpatialOperands().isEmpty()) {
sosFilterCaps.getSpatialOperands().forEach(spatialCapabilities.addNewGeometryOperands()::addGeometryOperand);
}
// set SpatialOperators
if (!sosFilterCaps.getSpatialOperators().isEmpty()) {
SpatialOperatorsType spatialOps = spatialCapabilities.addNewSpatialOperators();
Set<SpatialOperator> keys = sosFilterCaps.getSpatialOperators().keySet();
keys.forEach(spatialOperator -> {
SpatialOperatorType operator = spatialOps.addNewSpatialOperator();
operator.setName(getEnum4SpatialOperator(spatialOperator));
GeometryOperandsType bboxGeomOps = operator.addNewGeometryOperands();
sosFilterCaps.getSpatialOperators().get(spatialOperator).forEach(bboxGeomOps::addGeometryOperand);
});
}
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class FesEncoderv20Test method should_return_correct_schema_location.
@Test
public final void should_return_correct_schema_location() {
assertThat(fesEncoder.getSchemaLocations().size(), is(1));
final SchemaLocation schemLoc = fesEncoder.getSchemaLocations().iterator().next();
assertThat(schemLoc.getNamespace(), is("http://www.opengis.net/fes/2.0"));
assertThat(schemLoc.getSchemaFileUrl(), is("http://schemas.opengis.net/filter/2.0/filterAll.xsd"));
}
Aggregations