Hi Vurfem

> The explanation on the javadoc for "contains" filter is;
>
> " contains(Expression geometry1, Expression geometry2)"

Yeeesss.... it does leave a bit to the imagination doesn't it.

(Note to self: spend a bit of time on javadocs for filter classes)

> What means expression here? May be The name of geometry of the parcel and
> the building seperately?

The filter tests if the first geometry contains the second geometry.

The first argument should be a literal expression for the geometry
attribute (almost always "the_geom").

The second argument is the actual geometry that you are testing to see
if it is contained within a given feature's geometry.

> SimpleFeature building = buildingiterator.next();
>                        Geometry geom = (Geometry) 
> building.getDefaultGeometry();
>                        String filterStr = "CONTAINS(the_geom, " +(geom) + ")";
> Filter filter2 = CQL.toFilter(filterStr);
>

No, that doesn't look quite right. With CQL the second geometry has to
be expressed as a WKT string such as POINT(12 34) or LINESTRING(10 10,
20 10, 20 20).  You could do it like this...

        WKTWriter writer = new WKTWriter();
        Geometry geom2 = ...
        String cqlPredicate = "CONTAIMS(the_geom, " + writer.write(geom2) + ")";
        Filter filter = CQL.toFilter(cqlPredicate);

Or you could use FilterFactory2 directly which is probably easier if
you are dealing directly with the JTS Geometry objects...

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);

        Geometry building = ...;
        Filter filter = ff.contains(ff.literal("the_geom"),
ff.literal(building));

Hope this helps,

Michael

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to