use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project geo-platform by geosdi.
the class AreaSearchRequestFilter method createFilterAreaPredicate.
/**
* @param areaSearchType
* @param bBox
* @return {@link List<JAXBElement<?>}
*/
private List<JAXBElement<?>> createFilterAreaPredicate(AreaSearchType areaSearchType, BBox bBox) {
List<JAXBElement<?>> areaPredicate = new ArrayList(2);
BinarySpatialOpType binarySpatial = new BinarySpatialOpType();
PropertyNameType propertyNameType = new PropertyNameType();
propertyNameType.setContent(Arrays.<Object>asList(BOUNDING_BOX));
binarySpatial.setPropertyName(propertyNameType);
EnvelopeType envelope = this.createEnvelope(bBox);
binarySpatial.setEnvelope(gmlFactory.createEnvelope(envelope));
switch(areaSearchType) {
case ENCLOSES:
areaPredicate.add(filterFactory.createContains(binarySpatial));
break;
case IS:
areaPredicate.add(filterFactory.createEquals(binarySpatial));
break;
case OUTSIDE:
// Workaround for GeoNetwork bug: DISJOINT = NOT(INTERSECTS)
UnaryLogicOpType unary = new UnaryLogicOpType();
unary.setSpatialOps(filterFactory.createIntersects(binarySpatial));
areaPredicate.add(filterFactory.createNot(unary));
// areaPredicate.add(filterFactory.createDisjoint(binarySpatial));
break;
case OVERLAP:
areaPredicate.add(filterFactory.createIntersects(binarySpatial));
break;
}
return areaPredicate;
}
use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project geo-platform by geosdi.
the class NotOperatorHandler method processQueryRestrictions.
/**
* @param filter
* @param queryRestrictionDTOs
*/
@Override
protected void processQueryRestrictions(FilterType filter, List<QueryRestrictionDTO> queryRestrictionDTOs) {
logger.debug("################### {} Processing............\n", getFilterName());
List<JAXBElement<?>> elements = super.buildJAXBElementList(queryRestrictionDTOs);
logger.debug("##################{} builds : {} " + (elements.size() > 1 ? "elements" : "element") + "\n", getFilterName(), elements.size());
UnaryLogicOpType unaryLogicOpType = ((elements.size() == 1) ? createComparisonOps(elements.get(0), filter) : createLogicOps(elements, filter));
filter.setLogicOps(filterFactory.createNot(unaryLogicOpType));
}
use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project geotoolkit by Geomatys.
the class OGC100Test method testFilterLogicalNot.
@Test
public void testFilterLogicalNot() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_LOG_NOT);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
LogicalOperator prop = (LogicalOperator) filter;
BinaryComparisonOperator subfilter = (BinaryComparisonOperator) prop.getOperands().get(0);
ValueReference left = (ValueReference) subfilter.getOperand1();
Literal right = (Literal) subfilter.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getLogicOps());
LogicOpsType cot = ft.getLogicOps().getValue();
assertEquals(ft.getLogicOps().getName().getLocalPart(), OGCJAXBStatics.FILTER_LOGIC_NOT);
UnaryLogicOpType pibt = (UnaryLogicOpType) cot;
BinaryComparisonOpType leftoptype = (BinaryComparisonOpType) pibt.getComparisonOps().getValue();
PropertyNameType lf = (PropertyNameType) leftoptype.getExpression().get(0).getValue();
LiteralType rg = (LiteralType) leftoptype.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(valueF, rg.getContent().get(0));
MARSHALLER.marshal(ft.getLogicOps(), TEST_FILE_FIL_LOG_NOT);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project ddf by codice.
the class WfsFilterDelegateTest method testDisjointAsNotIntersects.
@Test
public void testDisjointAsNotIntersects() throws SAXException, IOException, JAXBException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.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 BinarySpatialOpType);
assertXMLEqual(MockWfsServer.getNotIntersectsXmlFilter(), getXmlFromMarshaller(filter));
}
use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project ddf by codice.
the class CswFilterDelegateTest method testPropertyIsLikeNot.
@Test
public void testPropertyIsLikeNot() throws JAXBException, SAXException, IOException {
FilterType propertyIsLikeFilter = cswFilterDelegateLatLon.propertyIsLike(propertyName, likeLiteral, isCaseSensitive);
FilterType filter = cswFilterDelegateLatLon.not(propertyIsLikeFilter);
assertThat(filter, notNullValue());
assertThat(filter.getLogicOps().getName(), is(NOT_LOGIC_OPS_NAME));
UnaryLogicOpType ulot = (UnaryLogicOpType) filter.getLogicOps().getValue();
assertThat(ulot, notNullValue());
}
Aggregations