Search in sources :

Example 6 with ComparisonOpsType

use of org.geotoolkit.ogc.xml.v110.ComparisonOpsType in project geotoolkit by Geomatys.

the class OGC100Test method testFilterComparisonPropertyIsGreaterThanOrEqual.

@Test
public void testFilterComparisonPropertyIsGreaterThanOrEqual() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISGREATEROREQUAL);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
    ValueReference left = (ValueReference) prop.getOperand1();
    Literal right = (Literal) prop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
    PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
    LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(valueF, rg.getContent().get(0).toString().trim());
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISGREATEROREQUAL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v100.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) 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 7 with ComparisonOpsType

use of org.geotoolkit.ogc.xml.v110.ComparisonOpsType in project geotoolkit by Geomatys.

the class OGC100Test method testFilterComparisonPropertyIsBetween.

// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR COMPARISON FILTERS //////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testFilterComparisonPropertyIsBetween() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISBETWEEN);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BetweenComparisonOperator prop = (BetweenComparisonOperator) filter;
    ValueReference center = (ValueReference) prop.getExpression();
    Literal lower = (Literal) prop.getLowerBoundary();
    Literal upper = (Literal) prop.getUpperBoundary();
    assertEquals(center.getXPath(), valueStr);
    assertEquals(((Number) lower.apply(null)).floatValue(), 455f, DELTA);
    assertEquals(((Number) upper.apply(null)).floatValue(), 457f, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    PropertyIsBetweenType pibt = (PropertyIsBetweenType) cot;
    PropertyNameType pnt = (PropertyNameType) pibt.getExpression().getValue();
    LiteralType low = (LiteralType) pibt.getLowerBoundary().getExpression().getValue();
    LiteralType up = (LiteralType) pibt.getUpperBoundary().getExpression().getValue();
    assertEquals(pnt.getContent(), valueStr);
    numberEquals(455, low.getContent().get(0));
    numberEquals(457, up.getContent().get(0));
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISBETWEEN);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v100.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(org.geotoolkit.ogc.xml.v100.FilterType) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.Literal) PropertyIsBetweenType(org.geotoolkit.ogc.xml.v100.PropertyIsBetweenType) Unmarshaller(javax.xml.bind.Unmarshaller) BetweenComparisonOperator(org.opengis.filter.BetweenComparisonOperator) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Example 8 with ComparisonOpsType

use of org.geotoolkit.ogc.xml.v110.ComparisonOpsType in project geotoolkit by Geomatys.

the class OGC100Test method testFilterComparisonPropertyIsLessThan.

@Test
public void testFilterComparisonPropertyIsLessThan() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISLESS);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
    ValueReference left = (ValueReference) prop.getOperand1();
    Literal right = (Literal) prop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
    PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
    LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(valueF, rg.getContent().get(0).toString().trim());
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISLESS);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v100.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) 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 9 with ComparisonOpsType

use of org.geotoolkit.ogc.xml.v110.ComparisonOpsType in project geotoolkit by Geomatys.

the class OGC110Test method testFilterComparisonPropertyIsLessThanOrEqual.

@Test
public void testFilterComparisonPropertyIsLessThanOrEqual() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISLESSOREQUAL);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
    ValueReference left = (ValueReference) prop.getOperand1();
    Literal right = (Literal) prop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
    PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
    LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(valueF, rg.getContent().get(0));
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISLESSOREQUAL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v110.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) 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)

Example 10 with ComparisonOpsType

use of org.geotoolkit.ogc.xml.v110.ComparisonOpsType in project geotoolkit by Geomatys.

the class OGC110Test method testFilterComparisonPropertyIsBetween.

// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR COMPARISON FILTERS //////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testFilterComparisonPropertyIsBetween() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISBETWEEN);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BetweenComparisonOperator prop = (BetweenComparisonOperator) filter;
    ValueReference center = (ValueReference) prop.getExpression();
    Literal lower = (Literal) prop.getLowerBoundary();
    Literal upper = (Literal) prop.getUpperBoundary();
    assertEquals(center.getXPath(), valueStr);
    assertEquals(((Number) lower.apply(null)).floatValue(), 455f, DELTA);
    assertEquals(((Number) upper.apply(null)).floatValue(), 457f, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    PropertyIsBetweenType pibt = (PropertyIsBetweenType) cot;
    PropertyNameType pnt = (PropertyNameType) pibt.getExpressionType().getValue();
    LiteralType low = (LiteralType) pibt.getLowerBoundary().getExpression().getValue();
    LiteralType up = (LiteralType) pibt.getUpperBoundary().getExpression().getValue();
    assertEquals(valueStr, pnt.getContent());
    numberEquals(455, low.getContent().get(0));
    numberEquals(457, up.getContent().get(0));
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISBETWEEN);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v110.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.Literal) PropertyIsBetweenType(org.geotoolkit.ogc.xml.v110.PropertyIsBetweenType) Unmarshaller(javax.xml.bind.Unmarshaller) BetweenComparisonOperator(org.opengis.filter.BetweenComparisonOperator) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) Test(org.junit.Test)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)23 Filter (org.opengis.filter.Filter)20 ValueReference (org.opengis.filter.ValueReference)19 Marshaller (javax.xml.bind.Marshaller)18 Unmarshaller (javax.xml.bind.Unmarshaller)18 Test (org.junit.Test)18 Literal (org.opengis.filter.Literal)15 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)13 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)11 ComparisonOpsType (org.geotoolkit.ogc.xml.v110.ComparisonOpsType)11 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)10 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)10 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)9 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)9 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)9 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)8 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)6 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)6 LikeOperator (org.opengis.filter.LikeOperator)3 NullOperator (org.opengis.filter.NullOperator)3