Search in sources :

Example 96 with PropertyNameType

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

the class OGC110Test method testExpSub.

@Test
public void testExpSub() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_SUB);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_SUB);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_SUB);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v110.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) Test(org.junit.Test)

Example 97 with PropertyNameType

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

the class OGC110Test method testExpMul.

@Test
public void testExpMul() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_MUL);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_MUL);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_MUL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v110.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) Test(org.junit.Test)

Example 98 with PropertyNameType

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

the class OGC110Test method testFilterComparisonPropertyIsEqualTo.

@Test
public void testFilterComparisonPropertyIsEqualTo() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISEQUAL);
    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_ISEQUAL);
    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 99 with PropertyNameType

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

the class OGC110Test method testFilterComparisonPropertyIsNotEqualTo.

@Test
public void testFilterComparisonPropertyIsNotEqualTo() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISNOTEQUAL);
    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_ISNOTEQUAL);
    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 100 with PropertyNameType

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

the class OGC100toGTTransformer method visitSpatialOp.

/**
 * Transform a SLD spatial Filter v1.0 in GT filter.
 */
public Filter visitSpatialOp(final JAXBElement<? extends org.geotoolkit.ogc.xml.v100.SpatialOpsType> jax) {
    final org.geotoolkit.ogc.xml.v100.SpatialOpsType ops = jax.getValue();
    final String OpName = jax.getName().getLocalPart();
    if (ops instanceof org.geotoolkit.ogc.xml.v100.BinarySpatialOpType) {
        final org.geotoolkit.ogc.xml.v100.BinarySpatialOpType binary = (org.geotoolkit.ogc.xml.v100.BinarySpatialOpType) ops;
        final JAXBElement<? extends org.geotoolkit.gml.xml.v212.AbstractGeometryType> geom = binary.getGeometry();
        final org.geotoolkit.ogc.xml.v100.PropertyNameType pnt = binary.getPropertyName();
        final Expression left = filterFactory.property(pnt.getContent());
        final Expression right = visit(geom);
        if (OGCJAXBStatics.FILTER_SPATIAL_CONTAINS.equalsIgnoreCase(OpName)) {
            return filterFactory.contains(left, right);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_CROSSES.equalsIgnoreCase(OpName)) {
            return filterFactory.crosses(left, right);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_DISJOINT.equalsIgnoreCase(OpName)) {
            return filterFactory.disjoint(left, right);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_EQUALS.equalsIgnoreCase(OpName)) {
            return filterFactory.equals(left, right);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_INTERSECTS.equalsIgnoreCase(OpName)) {
            return filterFactory.intersects(left, right);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_OVERLAPS.equalsIgnoreCase(OpName)) {
            return filterFactory.overlaps(left, right);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_TOUCHES.equalsIgnoreCase(OpName)) {
            return filterFactory.touches(left, right);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_WITHIN.equalsIgnoreCase(OpName)) {
            return filterFactory.within(left, right);
        }
        throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
    } else if (ops instanceof org.geotoolkit.ogc.xml.v100.DistanceBufferType) {
        final org.geotoolkit.ogc.xml.v100.DistanceBufferType dstOp = (org.geotoolkit.ogc.xml.v100.DistanceBufferType) ops;
        final org.geotoolkit.ogc.xml.v100.DistanceType dt = dstOp.getDistanceType();
        final JAXBElement<? extends org.geotoolkit.gml.xml.v212.AbstractGeometryType> geom = dstOp.getAbstractGeometry();
        final org.geotoolkit.ogc.xml.v100.PropertyNameType pnt = dstOp.getPropertyName();
        final Expression geom1 = filterFactory.property(pnt.getContent());
        final Expression geom2 = visit(geom);
        final double distance = Double.valueOf(dt.getContent());
        final String units = dt.getUnits();
        if (OGCJAXBStatics.FILTER_SPATIAL_DWITHIN.equalsIgnoreCase(OpName)) {
            return filterFactory.dwithin(geom1, geom2, distance, units);
        } else if (OGCJAXBStatics.FILTER_SPATIAL_BEYOND.equalsIgnoreCase(OpName)) {
            return filterFactory.beyond(geom1, geom2, distance, units);
        }
        throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
    } else if (ops instanceof org.geotoolkit.ogc.xml.v100.BBOXType) {
        final org.geotoolkit.ogc.xml.v100.BBOXType binary = (org.geotoolkit.ogc.xml.v100.BBOXType) ops;
        final org.geotoolkit.gml.xml.v212.BoxType box = binary.getBox();
        final org.geotoolkit.ogc.xml.v100.PropertyNameType pnt = binary.getPropertyNameType();
        final Expression geom = filterFactory.property(pnt.getContent());
        final double minx = box.getCoord().get(0).getX();
        final double maxx = box.getCoord().get(1).getX();
        final double miny = box.getCoord().get(0).getY();
        final double maxy = box.getCoord().get(1).getY();
        final String srs = box.getSrsName();
        if (OGCJAXBStatics.FILTER_SPATIAL_BBOX.equalsIgnoreCase(OpName)) {
            return filterFactory.bbox(geom, minx, miny, maxx, maxy, srs);
        }
        throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
    }
    throw new IllegalArgumentException("Unknowed filter element" + jax);
}
Also used : PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) JAXBElement(javax.xml.bind.JAXBElement) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Expression(org.opengis.filter.Expression)

Aggregations

PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)62 JAXBElement (javax.xml.bind.JAXBElement)47 Test (org.junit.Test)39 Unmarshaller (javax.xml.bind.Unmarshaller)38 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)38 Marshaller (javax.xml.bind.Marshaller)37 ValueReference (org.opengis.filter.ValueReference)37 Literal (org.opengis.filter.Literal)31 Filter (org.opengis.filter.Filter)27 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)20 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)20 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)17 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)16 PropertyNameType (net.opengis.filter.v_1_1_0.PropertyNameType)13 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)12 Expression (org.opengis.filter.Expression)12 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)10 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)9 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)9 ComparisonOpsType (org.geotoolkit.ogc.xml.v110.ComparisonOpsType)9