Search in sources :

Example 16 with UnaryLogicOpType

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;
}
Also used : UnaryLogicOpType(org.geosdi.geoplatform.xml.filter.v110.UnaryLogicOpType) EnvelopeType(org.geosdi.geoplatform.xml.gml.v311.EnvelopeType) ArrayList(java.util.ArrayList) BinarySpatialOpType(org.geosdi.geoplatform.xml.filter.v110.BinarySpatialOpType) JAXBElement(javax.xml.bind.JAXBElement) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 17 with UnaryLogicOpType

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));
}
Also used : UnaryLogicOpType(org.geosdi.geoplatform.xml.filter.v110.UnaryLogicOpType) JAXBElement(javax.xml.bind.JAXBElement)

Example 18 with 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);
}
Also used : Marshaller(javax.xml.bind.Marshaller) LogicalOperator(org.opengis.filter.LogicalOperator) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) LogicOpsType(org.geotoolkit.ogc.xml.v100.LogicOpsType) UnaryLogicOpType(org.geotoolkit.ogc.xml.v100.UnaryLogicOpType) FilterType(org.geotoolkit.ogc.xml.v100.FilterType) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) BinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator) BinaryComparisonOpType(org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Example 19 with UnaryLogicOpType

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));
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) BinarySpatialOpType(net.opengis.filter.v_2_0_0.BinarySpatialOpType) Test(org.junit.Test)

Example 20 with UnaryLogicOpType

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());
}
Also used : UnaryLogicOpType(net.opengis.filter.v_1_1_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_1_1_0.FilterType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)24 FilterType (net.opengis.filter.v_2_0_0.FilterType)17 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)17 FilterType (net.opengis.filter.v_1_1_0.FilterType)8 UnaryLogicOpType (net.opengis.filter.v_1_1_0.UnaryLogicOpType)8 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)6 JAXBElement (javax.xml.bind.JAXBElement)5 ArrayList (java.util.ArrayList)4 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)4 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)4 UnaryLogicOpType (org.geosdi.geoplatform.xml.filter.v110.UnaryLogicOpType)4 Marshaller (javax.xml.bind.Marshaller)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 BBOXType (net.opengis.filter.v_2_0_0.BBOXType)2 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)2 BinaryLogicOpType (org.geosdi.geoplatform.xml.filter.v110.BinaryLogicOpType)2 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)2 Filter (org.opengis.filter.Filter)2 Literal (org.opengis.filter.Literal)2 LogicalOperator (org.opengis.filter.LogicalOperator)2