Search in sources :

Example 31 with UnaryLogicOpType

use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project geo-platform by geosdi.

the class NotOperatorHandler method createComparisonOps.

/**
 * @param element
 * @return {@link UnaryLogicOpType}
 */
protected UnaryLogicOpType createComparisonOps(@Nonnull(when = NEVER) JAXBElement element, @Nonnull(when = NEVER) FilterType filter) {
    checkArgument(element != null, "The Parameter element must not be null.");
    checkArgument(filter != null, "The Parameter filter must not be null.");
    if (filter.isSetSpatialOps()) {
        List<JAXBElement<?>> elements = new ArrayList<>(2);
        elements.add(filter.getSpatialOps());
        filter.setSpatialOps(null);
        elements.add(element);
        UnaryLogicOpType unaryLogicOpType = new UnaryLogicOpType();
        BinaryLogicOpType and = new BinaryLogicOpType();
        and.setComparisonOpsOrSpatialOpsOrLogicOps(elements);
        unaryLogicOpType.setLogicOps(filterFactory.createAnd(and));
        return unaryLogicOpType;
    } else {
        UnaryLogicOpType unaryLogicOpType = new UnaryLogicOpType();
        unaryLogicOpType.setComparisonOps(element);
        return unaryLogicOpType;
    }
}
Also used : UnaryLogicOpType(org.geosdi.geoplatform.xml.filter.v110.UnaryLogicOpType) BinaryLogicOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryLogicOpType) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement)

Example 32 with UnaryLogicOpType

use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project geotoolkit by Geomatys.

the class OGC110Test method testFilterLogicalNot.

@Test
public void testFilterLogicalNot() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    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.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) LogicOpsType(org.geotoolkit.ogc.xml.v110.LogicOpsType) UnaryLogicOpType(org.geotoolkit.ogc.xml.v110.UnaryLogicOpType) FilterType(org.geotoolkit.ogc.xml.v110.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.v110.BinaryComparisonOpType) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) 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