[geotk] CQL filter - error parsing geometry operation
sorel johann
johann.sorel at geomatys.fr
Wed Feb 16 10:30:28 EST 2011
Hello,
I'm not the most familiar with cql, cedric should know more.
But by looking at the test cases, there are a few examples like :
CONTAINS(ATTR1, POINT(1 2))
DISJOINT(the_geom, POINT(1 2))
I made a try an it seems the first parameter must be the attribute you
refer to.
More usually I write them in full java. it's a bit longer but it's more
efficient too.
final GeometryFactory GF = new GeometryFactory();
final FilterFactory2 FF = (FilterFactory2)
FactoryFinder.getFilterFactory(null);
final Polygon poly = GF.createPolygon(GF.createLinearRing(new
Coordinate[]{
new Coordinate(2,64),
new Coordinate(2,73),
new Coordinate(4,68),
new Coordinate(2,64)}),
new LinearRing[0]);
final Point point = GF.createPoint(new Coordinate(3, 68));
final Filter filter = FF.contains(FF.literal(poly),
FF.literal(point));
System.out.println(filter);
System.out.println(filter.evaluate(null));
hope this helps
johann
Le 16/02/2011 15:35, Westgård Trond a écrit :
>
> I tried to test examples using the CQL and the FilterFactory.
>
> It works OK for me for features attributes that are date, string and
> numbers.
>
> I then selects the features I should expect (examples of filter text:
> "employee_no BETWEEN 1000 AND 8000" etc.)
>
> Now I wanted to use some geometry operations. I started out using an
> expression that should be true always:
>
> myfilter = CQL.toFilter("contains(polygon((2 64,2 73,4 68, 2,64)),
> point(3 68))");
>
> The exception states that this expression lacks an operator and is an
> invalid filterexpression. (I also tried with st_contains instead of
> contains).
>
> Any of the experts that could give me a hint -- ideally a link to
> examples/documentation ???
>
> Trond Westgård
>
> Senior Engineer
>
> Institute of Marine Research
>
> Bergen, Norway
>
> trondwe at imr.no
>
>
> _______________________________________________
> Geotoolkit mailing list
> Geotoolkit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geotoolkit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geotoolkit/attachments/20110216/16393f56/attachment.html
More information about the Geotoolkit
mailing list