[Geoserver-users] Filter for a postgis featureType: WFS vs WMS

I have a Postgis table that has quite a few records.
I am trying to select a single row from the table, using a Filter in an
SLD.
I notice, however, that the filter is not included in the constructed SQL
statement when making a GetMap request:

org.geotools.data.jdbc.JDBC1DataStore - sql is SELECT "gid", "tiff_name",
AsText(force_2d("geom")) FROM "contours" WHERE "geom" &&
GeometryFromText('POLYGON ((-4578323 -2500332.999999999, -4578323 4611929,
3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306) AND intersects("geom",
GeometryFromText('POLYGON ((-4578323 -2500332.999999999, -4578323 4611929,
3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306))
333145 [FINE] org.geotools.data.jdbc.JDBC1DataStore - About to execute
query: SELECT "gid", "tiff_name", AsText(force_2d("geom")) FROM "contours"
WHERE "geom" && GeometryFromText('POLYGON ((-4578323 -2500332.999999999,
-4578323 4611929, 3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306) AND intersects("geom",
GeometryFromText('POLYGON ((-4578323 -2500332.999999999, -4578323 4611929,
3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306))
333145 [FINE] org.geotools.data.jdbc.ConnectionPool - Getting available
connection.

Eventually, I get an exception:

org.vfny.geoserver.wms.WmsException
        at
org.vfny.geoserver.wms.WmsExceptionHandler.newServiceException(WmsExceptionHandler.java:70)
        at
org.vfny.geoserver.servlets.AbstractService.sendError(AbstractService.java:776)
        at
org.vfny.geoserver.servlets.AbstractService.doService(AbstractService.java:469)
        at org.vfny.geoserver.wms.servlets.GetMap.doPost(GetMap.java:73)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.vfny.geoserver.wms.servlets.WmsDispatcher.doResponse(WmsDispatcher.java:156)
        at
org.vfny.geoserver.wms.servlets.WmsDispatcher.doPost(WmsDispatcher.java:85)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:358)
        at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
        at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
        at org.mortbay.http.HttpServer.service(HttpServer.java:879)
        at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
        at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
        at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
        at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
        at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
        at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)
Caused by: java.lang.OutOfMemoryError

On the other hand, flitering data through WFS works (note the WHERE
clause):

SQL: SELECT AsText(force_2d(Envelope(Extent("geom")))) FROM "contours"
WHERE "tiff_name" = 'O3_00_00'
50805 [FINE] org.geotools.data.jdbc.ConnectionPool$ConnectionListManager -
Connection closed - adding to available connections.
50812 [FINE] org.geotools.data.jdbc.JDBC1DataStore - calling sql builder
with filter [ tiff_name = O3_00_00 ]
50812 [FINE] org.geotools.data.jdbc.JDBC1DataStore - sql is SELECT "gid",
AsText(force_2d("geom")), "tiff_name" FROM "contours" WHERE "tiff_name" =
'O3_00_00'
50812 [FINE] org.geotools.data.jdbc.JDBC1DataStore - About to execute
query: SELECT "gid", AsText(force_2d("geom")), "tiff_name" FROM "contours"
WHERE "tiff_name" = 'O3_00_00'

1. How can I get the WFS GetFeature (correct) behaviour while making a WMS
GetMap request?

2. Is the Filtering being done on the Geoserver' side, after all data has
been downloaded from Postgis?

TIA,

Alex Petkov

I can answer #2

2. Is the Filtering being done on the Geoserver' side, after all data has

been downloaded from Postgis?

Answer: It should be being done on the PostGIS side. The postgis data store will construct a select statement based on your filter. However, datastores such as the shapefile datastore do it all on the geoserver (geotools) side, because there is no fancy backend to do it.

Brent Owens
TOPP

Alex Petkov wrote:

I have a Postgis table that has quite a few records.
I am trying to select a single row from the table, using a Filter in an
SLD.
I notice, however, that the filter is not included in the constructed SQL
statement when making a GetMap request:

org.geotools.data.jdbc.JDBC1DataStore - sql is SELECT "gid", "tiff_name",
AsText(force_2d("geom")) FROM "contours" WHERE "geom" &&
GeometryFromText('POLYGON ((-4578323 -2500332.999999999, -4578323 4611929,
3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306) AND intersects("geom",
GeometryFromText('POLYGON ((-4578323 -2500332.999999999, -4578323 4611929,
3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306))
333145 [FINE] org.geotools.data.jdbc.JDBC1DataStore - About to execute
query: SELECT "gid", "tiff_name", AsText(force_2d("geom")) FROM "contours"
WHERE "geom" && GeometryFromText('POLYGON ((-4578323 -2500332.999999999,
-4578323 4611929, 3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306) AND intersects("geom",
GeometryFromText('POLYGON ((-4578323 -2500332.999999999, -4578323 4611929,
3189008 4611929, 3189008 -2500332.999999999, -4578323
-2500332.999999999))', 104306))
333145 [FINE] org.geotools.data.jdbc.ConnectionPool - Getting available
connection.

Eventually, I get an exception:

org.vfny.geoserver.wms.WmsException
       at
org.vfny.geoserver.wms.WmsExceptionHandler.newServiceException(WmsExceptionHandler.java:70)
       at
org.vfny.geoserver.servlets.AbstractService.sendError(AbstractService.java:776)
       at
org.vfny.geoserver.servlets.AbstractService.doService(AbstractService.java:469)
       at org.vfny.geoserver.wms.servlets.GetMap.doPost(GetMap.java:73)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
       at
org.vfny.geoserver.wms.servlets.WmsDispatcher.doResponse(WmsDispatcher.java:156)
       at
org.vfny.geoserver.wms.servlets.WmsDispatcher.doPost(WmsDispatcher.java:85)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
       at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:358)
       at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
       at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
       at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
       at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525)
       at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
       at org.mortbay.http.HttpServer.service(HttpServer.java:879)
       at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
       at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
       at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
       at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
       at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:276)
       at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)
Caused by: java.lang.OutOfMemoryError

On the other hand, flitering data through WFS works (note the WHERE
clause):

SQL: SELECT AsText(force_2d(Envelope(Extent("geom")))) FROM "contours"
WHERE "tiff_name" = 'O3_00_00'
50805 [FINE] org.geotools.data.jdbc.ConnectionPool$ConnectionListManager -
Connection closed - adding to available connections.
50812 [FINE] org.geotools.data.jdbc.JDBC1DataStore - calling sql builder
with filter [ tiff_name = O3_00_00 ]
50812 [FINE] org.geotools.data.jdbc.JDBC1DataStore - sql is SELECT "gid",
AsText(force_2d("geom")), "tiff_name" FROM "contours" WHERE "tiff_name" =
'O3_00_00'
50812 [FINE] org.geotools.data.jdbc.JDBC1DataStore - About to execute
query: SELECT "gid", AsText(force_2d("geom")), "tiff_name" FROM "contours"
WHERE "tiff_name" = 'O3_00_00'

1. How can I get the WFS GetFeature (correct) behaviour while making a WMS
GetMap request?

2. Is the Filtering being done on the Geoserver' side, after all data has
been downloaded from Postgis?

TIA,

Alex Petkov

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users