Hi Jody, I use only GeoTools 2.3 (each time I change my GeoTools version, I need to do a lot of changes :-/)
I try to filter on a property, what I want is a filter like this : <ogc:Filter> <ogc:Or> <ogc:PropertyIsEqualTo> <ogc:PropertyName>constraint-id</ogc:PropertyName> <ogc:Literal>ZICO</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:PropertyName>constraint-id</ogc:PropertyName> <ogc:Literal>ZPS</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Or> </ogc:Filter> My code is like this : // START of code MapContext context = new DefaultMapContext( crs ); // crs is a "CoordinateReferenceSystem" DefaultQuery dq = new DefaultQuery( slayer ); // slayer is the typename of the feature I want dq.setCoordinateSystem( crs ); Filter filtre = FilterCreator.createOrFilter( FilterCreator.createEqualsFilter( "constraint-id" , "ZICO" ) , FilterCreator.createEqualsFilter( "constraint-id" , "ZPS" ) ); // The FilterCreator is explain later dq.setFilter( ( (org.geotools.filter.Filter) filtre ) ); context.addLayer( wfsd.getView( dq ) , style ); // wfsd is my WFSDataSotre, and style is the org.geotools.styling.Style attached to this layer context.setCoordinateReferenceSystem( factory.createCoordinateReferenceSystem( sSRS ) ); // sSRS is the output SRS // Area of Interest is set StreamingRenderer sr = new StreamingRenderer(); sr.setContext( context ); // g2d is defined as the Graphics of a BufferedImage sr.paint( g2d , new Rectangle(size) , context.getAreaOfInterest() ); // END of code // START of FilterCreator public static Filter createEqualsFilter( String Attribute, String Literal){ FilterFactory filterFactory = FilterFactoryFinder.createFilterFactory(); Expression ExpAttribute = filterFactory.createAttributeExpression( Attribute ); Expression ExpLiteral = filterFactory.createLiteralExpression( Literal ); return filterFactory.equal( ExpAttribute , ExpLiteral ); } public static Filter createOrFilter( Filter f1 , Filter f2 ){ return FilterFactoryFinder.createFilterFactory().or( f1 , f2 ); } // END of FilterCreator I know that the FilterFactory is deprecated but due to a lack of time it will stay a few more in state. My WFS getCapabilities says me that the filter is supported (and using it by hand is ok). Thanks by advance. ________________ François Tertre BRGM STI/AD -----Message d'origine----- De : Jody Garnett [mailto:[EMAIL PROTECTED] Envoyé : vendredi 3 octobre 2008 18:52 À : Tertre Francois Cc : Geotools-gt2-users@lists.sourceforge.net Objet : Re: [Geotools-gt2-users] Filter in wfs request What version are you using? I have been noticing some problems with WFS filter encoding in GeoTools 2.6; the last version that was known to work for uDig was GeoTools 2.2.... Can you be more specific about what you are doing? Which filter is having problems ... Feature ID? Spatial Filter? Attribute tests? You can include some code in your email if that will help explain ... DefaultQuery query = new DefaultQuery( "city", .... ); query.setFilter( CQL.toFilter("NAME = 'victoria'") ); FeatureSource source = datastore.getView( query ); FeatureCollection features = source.getFeatures( CQL.toFilter("THE_GEOM contains POINT(12,3)") ); is exactly the same as issuing.... FeatureSource source = datastore.getFeatureSource( "city" ); FeatureCollection features = source.getFeatures( CQL.toFilter("NAME = 'victoria' AND THE_GEOM contains POINT(12,3)"); Any problems you are seeing are due to either: - the capabilities document of the WFS you are hitting? (Does it support the filter you are trying to write? - if not geotools will request more data; and perform some filtering on the client side) - straight problems encoding the filter (I fixed one of these last week for a customer) Also not there are some "strict" or "lax" modes for the WFSDataStore ... that control how careful it is about making valid Filter requests; and how careful it is when reading in the resulting data (can it recover if the WFS server is inconsistent - usually servers are not careful about returning data in the order they advertise in the DescribeFeatureType operation?) Cheers, Jody Tertre Francois wrote: > Hi the list, > > I try to add a filter to a query to a WFSDatastore, but at the > getFeature request and not after, but I have only the filter which > happen after the getFeature request. > > I have tried to use WFSDatastore.getView(Query) with a Filter in my > Query, to use a WFSDataStore with the same Query which include the > filter, and I always have the filtering after the request. > > Is anyone have a solution to this problem ? > > Thanks, > > ________________ > François Tertre > BRGM STI/AD > 3, avenue Claude Guillemin > BP 6009 - 45060 Orléans Cedex 2 > France > Web: http://www.brgm.fr > > > ---------------------------------------------------------------------- > -- > > ---------------------------------------------------------------------- > --- This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge Build the coolest Linux based applications with Moblin SDK & > win great prizes Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ---------------------------------------------------------------------- > -- > > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users