Search in sources :

Example 41 with PropertyNameType

use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geotoolkit by Geomatys.

the class OGC110Test method testFilterComparisonPropertyIsGreaterThanOrEqual.

@Test
public void testFilterComparisonPropertyIsGreaterThanOrEqual() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    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));
    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.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 42 with PropertyNameType

use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geotoolkit by Geomatys.

the class OGC110Test method testFilterComparisonPropertyIsNull.

@Test
public void testFilterComparisonPropertyIsNull() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISNULL);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    NullOperator prop = (NullOperator) filter;
    ValueReference center = (ValueReference) prop.getExpressions().get(0);
    assertEquals(center.getXPath(), valueStr);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    PropertyIsNullType pibt = (PropertyIsNullType) cot;
    PropertyNameType pnt = (PropertyNameType) pibt.getPropertyName();
    assertEquals(pnt.getContent(), valueStr);
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISNULL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) PropertyIsNullType(org.geotoolkit.ogc.xml.v110.PropertyIsNullType) Filter(org.opengis.filter.Filter) ComparisonOpsType(org.geotoolkit.ogc.xml.v110.ComparisonOpsType) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) NullOperator(org.opengis.filter.NullOperator) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) Test(org.junit.Test)

Example 43 with PropertyNameType

use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geotoolkit by Geomatys.

the class FilterToOGC110Converter method visit.

public JAXBElement<?> visit(final Filter filter) {
    if (filter.equals(Filter.include())) {
        return null;
    }
    if (filter.equals(Filter.exclude())) {
        return null;
    }
    final CodeList<?> type = filter.getOperatorType();
    if (filter instanceof BetweenComparisonOperator) {
        final BetweenComparisonOperator pib = (BetweenComparisonOperator) filter;
        final LowerBoundaryType lbt = ogc_factory.createLowerBoundaryType();
        lbt.setExpression(extract(pib.getLowerBoundary()));
        final UpperBoundaryType ubt = ogc_factory.createUpperBoundaryType();
        ubt.setExpression(extract(pib.getUpperBoundary()));
        final PropertyIsBetweenType bot = new PropertyIsBetweenType(extract(pib.getExpression()), lbt, ubt);
        return ogc_factory.createPropertyIsBetween(bot);
    } else if (type == ComparisonOperatorName.PROPERTY_IS_EQUAL_TO) {
        final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
        final PropertyIsEqualToType bot = ogc_factory.createPropertyIsEqualToType();
        bot.getExpression().add(extract(pit.getOperand1()));
        bot.getExpression().add(extract(pit.getOperand2()));
        return ogc_factory.createPropertyIsEqualTo(bot);
    } else if (type == ComparisonOperatorName.PROPERTY_IS_GREATER_THAN) {
        final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
        final PropertyIsGreaterThanType bot = ogc_factory.createPropertyIsGreaterThanType();
        bot.getExpression().add(extract(pit.getOperand1()));
        bot.getExpression().add(extract(pit.getOperand2()));
        return ogc_factory.createPropertyIsGreaterThan(bot);
    } else if (type == ComparisonOperatorName.PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO) {
        final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
        final PropertyIsGreaterThanOrEqualToType bot = ogc_factory.createPropertyIsGreaterThanOrEqualToType();
        bot.getExpression().add(extract(pit.getOperand1()));
        bot.getExpression().add(extract(pit.getOperand2()));
        return ogc_factory.createPropertyIsGreaterThanOrEqualTo(bot);
    } else if (type == ComparisonOperatorName.PROPERTY_IS_LESS_THAN) {
        final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
        final PropertyIsLessThanType bot = ogc_factory.createPropertyIsLessThanType();
        bot.getExpression().add(extract(pit.getOperand1()));
        bot.getExpression().add(extract(pit.getOperand2()));
        return ogc_factory.createPropertyIsLessThan(bot);
    } else if (type == ComparisonOperatorName.PROPERTY_IS_LESS_THAN_OR_EQUAL_TO) {
        final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
        final PropertyIsLessThanOrEqualToType bot = ogc_factory.createPropertyIsLessThanOrEqualToType();
        bot.getExpression().add(extract(pit.getOperand1()));
        bot.getExpression().add(extract(pit.getOperand2()));
        return ogc_factory.createPropertyIsLessThanOrEqualTo(bot);
    } else if (filter instanceof LikeOperator) {
        final LikeOperator pis = (LikeOperator) filter;
        final List<Expression> expressions = filter.getExpressions();
        final PropertyIsLikeType bot = ogc_factory.createPropertyIsLikeType();
        bot.setEscapeChar(String.valueOf(pis.getEscapeChar()));
        final LiteralType lt = ogc_factory.createLiteralType();
        lt.setContent(((Literal) expressions.get(1)).getValue());
        bot.setLiteral(lt.getStringValue());
        final Expression expression = expressions.get(0);
        if (!(expression instanceof ValueReference)) {
            throw new IllegalArgumentException("LikeOperator can support ValueReference only, but was a " + expression);
        }
        final PropertyNameType pnt = (PropertyNameType) extract(expression).getValue();
        bot.setPropertyName(pnt);
        bot.setSingleChar(String.valueOf(pis.getSingleChar()));
        bot.setWildCard(String.valueOf(pis.getWildCard()));
        return ogc_factory.createPropertyIsLike(bot);
    } else if (type == ComparisonOperatorName.PROPERTY_IS_NOT_EQUAL_TO) {
        final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
        final PropertyIsNotEqualToType bot = ogc_factory.createPropertyIsNotEqualToType();
        bot.getExpression().add(extract(pit.getOperand1()));
        bot.getExpression().add(extract(pit.getOperand2()));
        return ogc_factory.createPropertyIsNotEqualTo(bot);
    } else if (filter instanceof NullOperator) {
        final NullOperator pis = (NullOperator) filter;
        final PropertyIsNullType bot = ogc_factory.createPropertyIsNullType();
        final Object obj = extract((Expression) pis.getExpressions().get(0)).getValue();
        bot.setPropertyName((PropertyNameType) obj);
        return ogc_factory.createPropertyIsNull(bot);
    } else if (type == LogicalOperatorName.AND) {
        final LogicalOperator and = (LogicalOperator) filter;
        final List<JAXBElement> children = new ArrayList<>();
        for (final Filter f : (List<Filter>) and.getOperands()) {
            final JAXBElement<? extends LogicOpsType> ele = (JAXBElement<? extends LogicOpsType>) visit(f);
            if (ele != null) {
                children.add(ele);
            }
        }
        return ogc_factory.createAnd(new AndType(children.toArray()));
    } else if (type == LogicalOperatorName.OR) {
        final LogicalOperator or = (LogicalOperator) filter;
        final List<JAXBElement> children = new ArrayList<>();
        for (final Filter f : (List<Filter>) or.getOperands()) {
            final JAXBElement<? extends LogicOpsType> ele = (JAXBElement<? extends LogicOpsType>) visit(f);
            if (ele != null) {
                children.add(ele);
            }
        }
        return ogc_factory.createOr(new OrType(children.toArray()));
    } else if (type == LogicalOperatorName.NOT) {
        final LogicalOperator not = (LogicalOperator) filter;
        JAXBElement<?> sf = visit((Filter) not.getOperands().get(0));
        return ogc_factory.createNot(new NotType(sf.getValue()));
    } else if (filter instanceof ResourceId) {
        throw new IllegalArgumentException("Not parsed yet : " + filter);
    } else if (type == SpatialOperatorName.BBOX) {
        final BBOX bbox = BBOX.wrap((BinarySpatialOperator) filter);
        final Expression left = bbox.getOperand1();
        final Expression right = bbox.getOperand2();
        final String property;
        final double minx;
        final double maxx;
        final double miny;
        final double maxy;
        String srs;
        if (left instanceof ValueReference) {
            property = ((ValueReference) left).getXPath();
            final Object objGeom = ((Literal) right).getValue();
            if (objGeom instanceof org.opengis.geometry.Envelope) {
                final org.opengis.geometry.Envelope env = (org.opengis.geometry.Envelope) objGeom;
                minx = env.getMinimum(0);
                maxx = env.getMaximum(0);
                miny = env.getMinimum(1);
                maxy = env.getMaximum(1);
                try {
                    srs = IdentifiedObjects.lookupURN(env.getCoordinateReferenceSystem(), null);
                    if (srs == null) {
                        srs = ReferencingUtilities.lookupIdentifier(env.getCoordinateReferenceSystem(), true);
                    }
                } catch (FactoryException ex) {
                    throw new IllegalArgumentException("invalid bbox element : " + filter + " " + ex.getMessage(), ex);
                }
            } else if (objGeom instanceof Geometry) {
                final Geometry geom = (Geometry) objGeom;
                final Envelope env = geom.getEnvelopeInternal();
                minx = env.getMinX();
                maxx = env.getMaxX();
                miny = env.getMinY();
                maxy = env.getMaxY();
                srs = SRIDGenerator.toSRS(geom.getSRID(), SRIDGenerator.Version.V1);
            } else {
                throw new IllegalArgumentException("invalide bbox element : " + filter);
            }
        } else if (right instanceof ValueReference) {
            property = ((ValueReference) right).getXPath();
            final Object objGeom = ((Literal) left).getValue();
            if (objGeom instanceof org.opengis.geometry.Envelope) {
                final org.opengis.geometry.Envelope env = (org.opengis.geometry.Envelope) objGeom;
                minx = env.getMinimum(0);
                maxx = env.getMaximum(0);
                miny = env.getMinimum(1);
                maxy = env.getMaximum(1);
                try {
                    srs = IdentifiedObjects.lookupURN(env.getCoordinateReferenceSystem(), null);
                } catch (FactoryException ex) {
                    throw new IllegalArgumentException("invalide bbox element : " + filter + " " + ex.getMessage(), ex);
                }
            } else if (objGeom instanceof Geometry) {
                final Geometry geom = (Geometry) objGeom;
                final Envelope env = geom.getEnvelopeInternal();
                minx = env.getMinX();
                maxx = env.getMaxX();
                miny = env.getMinY();
                maxy = env.getMaxY();
                srs = SRIDGenerator.toSRS(geom.getSRID(), SRIDGenerator.Version.V1);
            } else {
                throw new IllegalArgumentException("invalide bbox element : " + filter);
            }
        } else {
            throw new IllegalArgumentException("invalide bbox element : " + filter);
        }
        final BBOXType bbtype = new BBOXType(property, minx, miny, maxx, maxy, srs);
        return ogc_factory.createBBOX(bbtype);
    } else if (filter instanceof ResourceId) {
        // todo OGC filter can not handle ID when we are inside another filter type
        // so here we make a small tric to change an id filter in a serie of propertyequal filter
        // this is not really legal but we dont have the choice here
        // we should propose an evolution of ogc filter do consider id filter as a comparison filter
        final ValueReference n = FF.property(AttributeConvention.IDENTIFIER);
        String ident = ((ResourceId) filter).getIdentifier();
        return visit(FF.equal(n, FF.literal(ident)));
    } else if (filter instanceof SpatialOperator) {
        final BinarySpatialOperator spatialOp = (BinarySpatialOperator) filter;
        Expression exp1 = spatialOp.getOperand1();
        Expression exp2 = spatialOp.getOperand2();
        if (!(exp1 instanceof ValueReference)) {
            // flip order
            final Expression ex = exp1;
            exp1 = exp2;
            exp2 = ex;
        }
        if (!(exp1 instanceof ValueReference)) {
            throw new IllegalArgumentException("Filter can not be transformed in wml filter, " + "expression are not of the requiered type ");
        }
        final JAXBElement<PropertyNameType> pnt = (JAXBElement<PropertyNameType>) extract(exp1);
        final JAXBElement<EnvelopeType> jaxEnv;
        final JAXBElement<? extends AbstractGeometryType> jaxGeom;
        final Object geom = ((Literal) exp2).getValue();
        if (geom instanceof Geometry) {
            final Geometry jts = (Geometry) geom;
            final String srid = SRIDGenerator.toSRS(jts.getSRID(), SRIDGenerator.Version.V1);
            CoordinateReferenceSystem crs;
            try {
                crs = CRS.forCode(srid);
            } catch (Exception ex) {
                Logger.getLogger("org.geotoolkit.sld.xml").log(Level.WARNING, null, ex);
                crs = null;
            }
            final AbstractGeometryType gt = GMLUtilities.getGMLFromISO(JTSUtils.toISO(jts, crs));
            // TODO use gml method to return any JAXBElement
            if (gt instanceof PointType) {
                jaxGeom = gml_factory.createPoint((PointType) gt);
            } else if (gt instanceof CurveType) {
                jaxGeom = gml_factory.createCurve((CurveType) gt);
            } else if (gt instanceof LineStringType) {
                jaxGeom = gml_factory.createLineString((LineStringType) gt);
            } else if (gt instanceof PolygonType) {
                jaxGeom = gml_factory.createPolygon((PolygonType) gt);
            } else if (gt instanceof MultiPolygonType) {
                jaxGeom = gml_factory.createMultiPolygon((MultiPolygonType) gt);
            } else if (gt instanceof MultiLineStringType) {
                jaxGeom = gml_factory.createMultiLineString((MultiLineStringType) gt);
            } else if (gt instanceof MultiCurveType) {
                jaxGeom = gml_factory.createMultiLineString((MultiLineStringType) gt);
            } else if (gt instanceof MultiPointType) {
                jaxGeom = gml_factory.createMultiLineString((MultiLineStringType) gt);
            } else if (gt instanceof MultiGeometryType) {
                jaxGeom = gml_factory.createMultiGeometry((MultiGeometryType) gt);
            } else if (gt instanceof PolyhedralSurfaceType) {
                jaxGeom = gml_factory.createPolyhedralSurface((PolyhedralSurfaceType) gt);
            } else if (gt != null) {
                throw new IllegalArgumentException("unexpected Geometry type:" + gt.getClass().getName());
            } else {
                jaxGeom = null;
            }
            jaxEnv = null;
        } else if (geom instanceof org.opengis.geometry.Geometry) {
            final AbstractGeometryType gt = GMLUtilities.getGMLFromISO((org.opengis.geometry.Geometry) geom);
            // TODO use gml method to return any JAXBElement
            if (gt instanceof PointType) {
                jaxGeom = gml_factory.createPoint((PointType) gt);
            } else if (gt instanceof CurveType) {
                jaxGeom = gml_factory.createCurve((CurveType) gt);
            } else if (gt instanceof LineStringType) {
                jaxGeom = gml_factory.createLineString((LineStringType) gt);
            } else if (gt instanceof PolygonType) {
                jaxGeom = gml_factory.createPolygon((PolygonType) gt);
            } else if (gt instanceof MultiPolygonType) {
                jaxGeom = gml_factory.createMultiPolygon((MultiPolygonType) gt);
            } else if (gt instanceof MultiLineStringType) {
                jaxGeom = gml_factory.createMultiLineString((MultiLineStringType) gt);
            } else if (gt instanceof MultiCurveType) {
                jaxGeom = gml_factory.createMultiLineString((MultiLineStringType) gt);
            } else if (gt instanceof MultiPointType) {
                jaxGeom = gml_factory.createMultiLineString((MultiLineStringType) gt);
            } else if (gt instanceof MultiGeometryType) {
                jaxGeom = gml_factory.createMultiGeometry((MultiGeometryType) gt);
            } else if (gt instanceof PolyhedralSurfaceType) {
                jaxGeom = gml_factory.createPolyhedralSurface((PolyhedralSurfaceType) gt);
            } else if (gt != null) {
                throw new IllegalArgumentException("unexpected Geometry type:" + gt.getClass().getName());
            } else {
                jaxGeom = null;
            }
            jaxEnv = null;
        } else if (geom instanceof org.opengis.geometry.Envelope) {
            final org.opengis.geometry.Envelope genv = (org.opengis.geometry.Envelope) geom;
            EnvelopeType ee = gml_factory.createEnvelopeType();
            try {
                ee.setSrsName(IdentifiedObjects.lookupURN(genv.getCoordinateReferenceSystem(), null));
            } catch (FactoryException ex) {
                Logger.getLogger("org.geotoolkit.sld.xml").log(Level.WARNING, null, ex);
            }
            ee.setLowerCorner(new DirectPositionType(genv.getLowerCorner()));
            ee.setUpperCorner(new DirectPositionType(genv.getUpperCorner()));
            jaxGeom = null;
            jaxEnv = gml_factory.createEnvelope(ee);
        } else {
            throw new IllegalArgumentException("Type is not geometric or envelope.");
        }
        if (type == DistanceOperatorName.BEYOND) {
            final BeyondType jaxelement = ogc_factory.createBeyondType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setPropertyName(pnt.getValue());
            return ogc_factory.createBeyond(jaxelement);
        } else if (type == SpatialOperatorName.CONTAINS) {
            final ContainsType jaxelement = ogc_factory.createContainsType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createContains(jaxelement);
        } else if (type == SpatialOperatorName.CROSSES) {
            final CrossesType jaxelement = ogc_factory.createCrossesType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createCrosses(jaxelement);
        } else if (type == DistanceOperatorName.WITHIN) {
            final DWithinType jaxelement = ogc_factory.createDWithinType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setPropertyName(pnt.getValue());
            return ogc_factory.createDWithin(jaxelement);
        } else if (type == SpatialOperatorName.DISJOINT) {
            final DisjointType jaxelement = ogc_factory.createDisjointType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createDisjoint(jaxelement);
        } else if (type == SpatialOperatorName.EQUALS) {
            final EqualsType jaxelement = ogc_factory.createEqualsType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createEquals(jaxelement);
        } else if (type == SpatialOperatorName.INTERSECTS) {
            final IntersectsType jaxelement = ogc_factory.createIntersectsType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createIntersects(jaxelement);
        } else if (type == SpatialOperatorName.OVERLAPS) {
            final OverlapsType jaxelement = new OverlapsType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createOverlaps(jaxelement);
        } else if (type == SpatialOperatorName.TOUCHES) {
            final TouchesType jaxelement = ogc_factory.createTouchesType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createTouches(jaxelement);
        } else if (type == SpatialOperatorName.WITHIN) {
            final WithinType jaxelement = ogc_factory.createWithinType();
            jaxelement.setAbstractGeometry(jaxGeom);
            jaxelement.setEnvelope(jaxEnv);
            jaxelement.setPropertyName(pnt);
            return ogc_factory.createWithin(jaxelement);
        } else {
            throw new IllegalArgumentException("Unknowed filter element : " + filter + " class :" + filter.getClass());
        }
    } else {
        throw new IllegalArgumentException("Unknowed filter element : " + filter + " class :" + filter.getClass());
    }
}
Also used : OverlapsType(org.geotoolkit.ogc.xml.v110.OverlapsType) FactoryException(org.opengis.util.FactoryException) MultiCurveType(org.geotoolkit.gml.xml.v311.MultiCurveType) BeyondType(org.geotoolkit.ogc.xml.v110.BeyondType) ArrayList(java.util.ArrayList) MultiGeometryType(org.geotoolkit.gml.xml.v311.MultiGeometryType) CrossesType(org.geotoolkit.ogc.xml.v110.CrossesType) DWithinType(org.geotoolkit.ogc.xml.v110.DWithinType) NotType(org.geotoolkit.ogc.xml.v110.NotType) Literal(org.opengis.filter.Literal) DisjointType(org.geotoolkit.ogc.xml.v110.DisjointType) MultiLineStringType(org.geotoolkit.gml.xml.v311.MultiLineStringType) CodeList(org.opengis.util.CodeList) List(java.util.List) ArrayList(java.util.ArrayList) PropertyIsBetweenType(org.geotoolkit.ogc.xml.v110.PropertyIsBetweenType) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) BetweenComparisonOperator(org.opengis.filter.BetweenComparisonOperator) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) DWithinType(org.geotoolkit.ogc.xml.v110.DWithinType) WithinType(org.geotoolkit.ogc.xml.v110.WithinType) AbstractGeometryType(org.geotoolkit.gml.xml.v311.AbstractGeometryType) PropertyIsGreaterThanType(org.geotoolkit.ogc.xml.v110.PropertyIsGreaterThanType) LogicalOperator(org.opengis.filter.LogicalOperator) PolygonType(org.geotoolkit.gml.xml.v311.PolygonType) MultiPolygonType(org.geotoolkit.gml.xml.v311.MultiPolygonType) JAXBElement(javax.xml.bind.JAXBElement) IntersectsType(org.geotoolkit.ogc.xml.v110.IntersectsType) LineStringType(org.geotoolkit.gml.xml.v311.LineStringType) MultiLineStringType(org.geotoolkit.gml.xml.v311.MultiLineStringType) PropertyIsGreaterThanOrEqualToType(org.geotoolkit.ogc.xml.v110.PropertyIsGreaterThanOrEqualToType) MultiPointType(org.geotoolkit.gml.xml.v311.MultiPointType) LogicOpsType(org.geotoolkit.ogc.xml.v110.LogicOpsType) UpperBoundaryType(org.geotoolkit.ogc.xml.v110.UpperBoundaryType) PropertyIsNotEqualToType(org.geotoolkit.ogc.xml.v110.PropertyIsNotEqualToType) ContainsType(org.geotoolkit.ogc.xml.v110.ContainsType) BBOXType(org.geotoolkit.ogc.xml.v110.BBOXType) LikeOperator(org.opengis.filter.LikeOperator) BinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator) PolyhedralSurfaceType(org.geotoolkit.gml.xml.v311.PolyhedralSurfaceType) PropertyIsLikeType(org.geotoolkit.ogc.xml.v110.PropertyIsLikeType) PropertyIsLessThanType(org.geotoolkit.ogc.xml.v110.PropertyIsLessThanType) AndType(org.geotoolkit.ogc.xml.v110.AndType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) CurveType(org.geotoolkit.gml.xml.v311.CurveType) MultiCurveType(org.geotoolkit.gml.xml.v311.MultiCurveType) PropertyIsLessThanOrEqualToType(org.geotoolkit.ogc.xml.v110.PropertyIsLessThanOrEqualToType) Envelope(org.locationtech.jts.geom.Envelope) PropertyIsNullType(org.geotoolkit.ogc.xml.v110.PropertyIsNullType) EqualsType(org.geotoolkit.ogc.xml.v110.EqualsType) BinarySpatialOperator(org.opengis.filter.BinarySpatialOperator) OrType(org.geotoolkit.ogc.xml.v110.OrType) EnvelopeType(org.geotoolkit.gml.xml.v311.EnvelopeType) MultiPolygonType(org.geotoolkit.gml.xml.v311.MultiPolygonType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) NullOperator(org.opengis.filter.NullOperator) FactoryException(org.opengis.util.FactoryException) Geometry(org.locationtech.jts.geom.Geometry) PropertyIsEqualToType(org.geotoolkit.ogc.xml.v110.PropertyIsEqualToType) Expression(org.opengis.filter.Expression) Filter(org.opengis.filter.Filter) ResourceId(org.opengis.filter.ResourceId) PointType(org.geotoolkit.gml.xml.v311.PointType) MultiPointType(org.geotoolkit.gml.xml.v311.MultiPointType) LowerBoundaryType(org.geotoolkit.ogc.xml.v110.LowerBoundaryType) BinarySpatialOperator(org.opengis.filter.BinarySpatialOperator) TouchesType(org.geotoolkit.ogc.xml.v110.TouchesType)

Example 44 with PropertyNameType

use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geotoolkit by Geomatys.

the class FilterXMLBindingTest method filterUnmarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws JAXBException
 */
@Test
public void filterUnmarshalingTest() throws JAXBException {
    /*
         * Test Unmarshalling spatial filter.
         */
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "    <ogc:Overlaps>" + '\n' + "        <ogc:PropertyName>boundingBox</ogc:PropertyName>" + '\n' + "        <gml:Envelope srsName=\"EPSG:4326\">" + '\n' + "            <gml:lowerCorner>10.0 11.0</gml:lowerCorner>" + '\n' + "            <gml:upperCorner>10.0 11.0</gml:upperCorner>" + '\n' + "        </gml:Envelope>" + '\n' + "    </ogc:Overlaps>" + '\n' + "</ogc:Filter>" + '\n';
    StringReader sr = new StringReader(xml);
    JAXBElement jb = (JAXBElement) unmarshaller.unmarshal(sr);
    FilterType result = (FilterType) jb.getValue();
    DirectPositionType lowerCorner = new DirectPositionType(10.0, 11.0);
    DirectPositionType upperCorner = new DirectPositionType(10.0, 11.0);
    EnvelopeType envelope = new EnvelopeType(lowerCorner, upperCorner, "EPSG:4326");
    OverlapsType filterElement = new OverlapsType(new PropertyNameType("boundingBox"), envelope);
    FilterType expResult = new FilterType(filterElement);
    assertEquals(expResult.getSpatialOps().getValue(), result.getSpatialOps().getValue());
    assertEquals(expResult, result);
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "    <ogc:BBOX>" + '\n' + "        <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + "        <gml:Envelope srsName=\"EPSG:4326\">" + '\n' + "            <gml:lowerCorner>10.0 11.0</gml:lowerCorner>" + '\n' + "            <gml:upperCorner>10.0 11.0</gml:upperCorner>" + '\n' + "        </gml:Envelope>" + '\n' + "    </ogc:BBOX>" + '\n' + "</ogc:Filter>" + '\n';
    sr = new StringReader(xml);
    jb = (JAXBElement) unmarshaller.unmarshal(sr);
    org.geotoolkit.ogc.xml.v200.FilterType result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
    final org.geotoolkit.gml.xml.v311.ObjectFactory gmlFactory = new org.geotoolkit.gml.xml.v311.ObjectFactory();
    BBOXType filterBox = new BBOXType("boundingBox", gmlFactory.createEnvelope(envelope));
    org.geotoolkit.ogc.xml.v200.FilterType expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterBox);
    assertEquals(((JAXBElement) ((BBOXType) expResult2.getSpatialOps().getValue()).getAny()).getValue(), ((JAXBElement) ((BBOXType) result2.getSpatialOps().getValue()).getAny()).getValue());
    assertEquals(expResult2.getSpatialOps().getValue(), result2.getSpatialOps().getValue());
    assertEquals(expResult2, result2);
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\">" + '\n' + "    <ogc:BBOX>" + '\n' + "        <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + "        $test" + '\n' + "    </ogc:BBOX>" + '\n' + "</ogc:Filter>" + '\n';
    sr = new StringReader(xml);
    jb = (JAXBElement) unmarshaller.unmarshal(sr);
    result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
    filterBox = new BBOXType("boundingBox", "$test");
    expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterBox);
    assertEquals(expResult2.getSpatialOps().getValue(), result2.getSpatialOps().getValue());
    assertEquals(expResult2, result2);
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\">" + '\n' + "    <ogc:Contains>" + '\n' + "        <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + "        $test" + '\n' + "    </ogc:Contains>" + '\n' + "</ogc:Filter>" + '\n';
    sr = new StringReader(xml);
    jb = (JAXBElement) unmarshaller.unmarshal(sr);
    result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
    ContainsType filterContains = new ContainsType("boundingBox", "$test");
    expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterContains);
    assertEquals(expResult2.getSpatialOps().getValue(), result2.getSpatialOps().getValue());
    assertEquals(expResult2, result2);
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\">" + '\n' + "    <ogc:After>" + '\n' + "        <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + "        $test" + '\n' + "    </ogc:After>" + '\n' + "</ogc:Filter>" + '\n';
    sr = new StringReader(xml);
    jb = (JAXBElement) unmarshaller.unmarshal(sr);
    result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
    TimeAfterType filterAfter = new TimeAfterType("boundingBox", "$test");
    expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterAfter);
    assertEquals(expResult2.getTemporalOps().getValue(), result2.getTemporalOps().getValue());
    assertEquals(expResult2, result2);
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:gco=\"http://www.isotc211.org/2005/gco\" xmlns:gmx=\"http://www.isotc211.org/2005/gmx\" xmlns:gmi=\"http://www.isotc211.org/2005/gmi\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:ns8=\"http://www.opengis.net/gml\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:fes=\"http://www.opengis.net/fes/2.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\">\n" + "  <fes:PropertyIsBetween>\n" + "    <fes:ValueReference>prop</fes:ValueReference>\n" + "    <fes:LowerBoundary>\n" + "      <fes:Literal><gml:TimeInstant>\n" + "          <gml:timePosition>2002</gml:timePosition>\n" + "        </gml:TimeInstant></fes:Literal>\n" + "    </fes:LowerBoundary>\n" + "    <fes:UpperBoundary>\n" + "      <fes:Literal><gml:TimeInstant>\n" + "          <gml:timePosition>2004</gml:timePosition>\n" + "        </gml:TimeInstant></fes:Literal>\n" + "    </fes:UpperBoundary>\n" + "  </fes:PropertyIsBetween>\n" + "</fes:Filter>";
    sr = new StringReader(xml);
    jb = (JAXBElement) unmarshaller.unmarshal(sr);
    org.geotoolkit.ogc.xml.v200.FilterType result3 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
    final org.geotoolkit.gml.xml.v321.ObjectFactory gml32Factory = new org.geotoolkit.gml.xml.v321.ObjectFactory();
    final org.geotoolkit.ogc.xml.v200.ObjectFactory fesFactory = new org.geotoolkit.ogc.xml.v200.ObjectFactory();
    PropertyIsBetweenType expPes = new PropertyIsBetweenType();
    expPes.setExpression(fesFactory.createValueReference((String) "prop"));
    final LowerBoundaryType lower = new LowerBoundaryType();
    final TimeInstantType ti = new TimeInstantType("2002");
    final LiteralType lowlit = new LiteralType(gml32Factory.createTimeInstant(ti));
    lower.setExpression(fesFactory.createLiteral(lowlit));
    expPes.setLowerBoundary(lower);
    final UpperBoundaryType upper = new UpperBoundaryType();
    final TimeInstantType ti2 = new TimeInstantType("2004");
    final LiteralType upplit = new LiteralType(gml32Factory.createTimeInstant(ti2));
    upper.setExpression(fesFactory.createLiteral(upplit));
    expPes.setUpperBoundary(upper);
    org.geotoolkit.ogc.xml.v200.FilterType expResult3 = new org.geotoolkit.ogc.xml.v200.FilterType(expPes);
    assertTrue(result3.getComparisonOps().getValue() instanceof PropertyIsBetweenType);
    PropertyIsBetweenType resPes = (PropertyIsBetweenType) result3.getComparisonOps().getValue();
    assertEquals(expPes.getUpperBoundary(), resPes.getUpperBoundary());
    assertEquals(expPes.getLowerBoundary(), resPes.getLowerBoundary());
    assertEquals(expPes, resPes);
    assertEquals(expResult3.getComparisonOps().getValue(), result3.getComparisonOps().getValue());
    assertEquals(expResult3, result3);
}
Also used : OverlapsType(org.geotoolkit.ogc.xml.v110.OverlapsType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) TimeInstantType(org.geotoolkit.gml.xml.v321.TimeInstantType) ObjectFactory(org.geotoolkit.ogc.xml.v110.ObjectFactory) StringReader(java.io.StringReader) PropertyIsBetweenType(org.geotoolkit.ogc.xml.v200.PropertyIsBetweenType) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) EnvelopeType(org.geotoolkit.gml.xml.v311.EnvelopeType) LiteralType(org.geotoolkit.ogc.xml.v200.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) TimeAfterType(org.geotoolkit.ogc.xml.v200.TimeAfterType) UpperBoundaryType(org.geotoolkit.ogc.xml.v200.UpperBoundaryType) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) ContainsType(org.geotoolkit.ogc.xml.v200.ContainsType) BBOXType(org.geotoolkit.ogc.xml.v200.BBOXType) LowerBoundaryType(org.geotoolkit.ogc.xml.v200.LowerBoundaryType)

Example 45 with PropertyNameType

use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geotoolkit by Geomatys.

the class GTtoSE100Transformer method visitGeometryType.

/**
 * Transform a geometrie name in a geometrytype.
 */
public org.geotoolkit.sld.xml.v100.Geometry visitGeometryType(String str) {
    final org.geotoolkit.sld.xml.v100.Geometry geo = sld_factory_v100.createGeometry();
    final PropertyNameType value = ogc_factory.createPropertyNameType();
    if (str == null)
        str = "";
    value.setContent(str);
    geo.setPropertyName(value);
    return geo;
}
Also used : PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType)

Aggregations

PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)62 JAXBElement (javax.xml.bind.JAXBElement)46 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)38 Test (org.junit.Test)38 Unmarshaller (javax.xml.bind.Unmarshaller)37 Marshaller (javax.xml.bind.Marshaller)36 ValueReference (org.opengis.filter.ValueReference)36 Literal (org.opengis.filter.Literal)30 Filter (org.opengis.filter.Filter)26 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)20 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)20 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)16 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)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