Hi Gabriel and all,
Thank you for help me. But now, I get another problem. When I trying to
generate the filter with this code, I get an incomplete geometry filter
encoding. Follows the source code:
FilterFactory2 ff = (FilterFactory2)CommonFactoryFinder.getFilterFactory(
null );
PropertyName propertyName = ff.property( "testString" );
Literal literal = ff.literal( 2 );
PropertyIsEqualTo filter = ff.equals( propertyName, literal );
GeometryFactory gf = new GeometryFactory();
Coordinate c = new Coordinate(-38.0, -7.0);
Point p = gf.createPoint(c);
Filter f = ff.contains(ff.property("SERVICEBBOX"), ff.literal(p));
Or orFilter = ff.or(filter, f);
// create the encoder with the filter 1.0 configuration
org.geotools.xml.Configuration configuration = new
org.geotools.filter.v1_0.OGCConfiguration();
org.geotools.xml.Encoder encoder = new org.geotools.xml.Encoder(
configuration );
// create an output stream
OutputStream xml = new
FileOutputStream("C:\\eclipse\\workspace\\WebServiceDescriptionTool2\\src\\test\\geoTest4.xml");
// encode
encoder.encode( orFilter, org.geotools.filter.v1_0.OGC.Filter, xml );
Follows the filter encoding generated:
<ogc:Or>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>testString</ogc:PropertyName>
<ogc:Literal>2</ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:comparisonOps />
<ogc:Contains>
<ogc:PropertyName>SERVICEBBOX</ogc:PropertyName>
<gml:Point/> Incomplete Geometry inconding - where are the
coordenates ?
</ogc:Contains>
</ogc:Or>
I think that I am forget anything else to do in the code or anything that I
don't know. Anyone knows what's happening ? Thanks in advance.
On 3/14/07, Gabriel Roldán <[EMAIL PROTECTED]> wrote:
sorry, sent the message incomplete accidentally, here goes the rest of it:
On Wednesday 14 March 2007 16:50, Gabriel Roldán wrote:
> Hi Fabio,
>
> non authoritative answer follows:
>
> right now you can't create an iso Geometry. A group of people is just
> working on its implementation.
> By now, you'll have to stick to the traditional geotools geometry model,
> which is JTS.
>
> About how to create a JTS geometry, you'll find plenty of examples out
> there, since its used everywhere. A couple links:
http://docs.codehaus.org/display/GEOTOOLS/Working+with+JTS+Geometries+from+DataStores
http://www.vividsolutions.com/jts/JTSHome.htm
as for creating the filter you want, you'll need to cast FilterFactory to
FilterFactory2. Rationale is that the geoapi FilterFactory methods are
meant
to represent exactly the filter building capabilities expressed in the
spec.
The Filter interfaces have actually more expressing power then what the
factory allows, so FilterFactory2 exposes it full fledged:
FilterFactory2 ff = (FilterFactory2)CommonFactoryFinder.getFilterFactory(
null );
Geometry geom = ... //whatever you want to get the geometry from
Filter filter = ff.contains(ff.property("SERVICEBBOX"), ff.literal(geom));
...
hope that helps
Gabriel
> On Wednesday 14 March 2007 15:33, Fabio Luiz Leite wrote:
> > Hi all,
> >
> > How to create an org.geotools.geometry ? I am encoding an OGC Filter
> > using geotools 2.4, but the method needs this geometry. Follows code
> > sample:
> >
> > FilterFactory ff = CommonFactoryFinder.getFilterFactory( null );
> >
> > *Geometry g = ???? // How to create this geometry ?
> > *
> > Contains containsFilter = ff.contains("SERVICEBBOX", *g*);
> > // create the encoder with the filter 1.0 configuration
> > org.geotools.xml.Configuration configuration = new
> > org.geotools.filter.v1_0OGCConfguration ();
> > org.geotools.xml.Encoder encoder = new org.geotools.xml.Encoder(
> > configuration );
> >
> > // create an output stream
> > OutputStream xml = new
> > FileOutputStream("H:\\projetoFabioCasa\\filter4.xml");
> >
> > // encode
> > encoder.encode( containsFilter , org.geotools.filter.v1_0.OGC.Filter
,
> > xml );
> > Thank's in advance.
--
Fábio Luiz Leite Júnior
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users