I have a fairly simple question. What is the best strategy to do the following scenario? I think this is a very common scenario:

  1. I have a several thousands of dataset with polygon/points. Each dataset/record can have multiple polygons.

  2. Allow users to draw a polygon and search which datasets fall into that space

  3. I have several predefined polygon/areas, that the users can also use/pick to search for datasets.

When the search is done, just show the list of the datasets, display as markers on a map. I'm not worried about this bit because it has been done just with OpenLayers.

My current options (I am new and some of my current options may not even be possible. Please let me know if that is the case) are:

  1. Put datasets in PostGIS, set it up in Geoserver. Put predefined polygons straight in geoserver. Use WMS filtering.
  2. Put datasets in PostGIS, but not in Geoserver. Put predefined polygons in PostGIS and Geoserver for displaying. Use PostGIS intersection.
  3. I've heard from another person that for performance ,it is best to calculate the intersection using a custom app, e.g. Java / other

I'm not sure what is the best in terms of performance and efficiency. Suggestions are very welcomed!


you can use cql or ecql filters.



BBOX(the_geom, -10, 20, -30, 40)


Cross layer filtering, here.

That is, the ability to find in layer A features that have a certain relationship with features in layer B. This can be used, for example, to find all bus stops within a certain distance from a shop, or all coffe shops in a certain city district. Since filter functions are widely supported in GeoServer this cross layer filtering can be applied in SLDs, CQL filters and WFS requests alike.

for wms:

DWITHIN(the_geom, collectGeometries(queryCollection('sf:roads','the_geom','INCLUDE')),
        200, meters)

for wfs:

@Andrea Aime has given an example about wfs request.

beside this geodjango has lots of spatial lookup as you want...

i hope it helps you...

  • Hi, thanks for that. I guess the consideration for me right now is performance. Which strategy between WFS, WMS. Between PostGIS or Geoserver or native application gives the best performance given the scenario. (More info at my comment to Andrea) – Yun Jun 20 '12 at 0:20

If it's just search that you're looking for you can do a WFS request with a spatial filter of type Contains or Intersects, something like:

<wfs:GetFeature service="WFS" version="1.1.0"
  <wfs:Query typeName="topp:states">

The above will be translated into a native spatial search in PostGIS

  • Hi, thanks for that. So is there no performance risks by doing this with WFS and Geoserver? There are several thousands datasets (that can grow) that needs to be indexed to PostGIS, and there are probably several thousand Predefined regions as well. (Though only a few will be picked of the predefined regions by the user). In your experience does Geoserver and or PostGIS have a problem intersecting this amount of data? – Yun Jun 20 '12 at 0:19
  • Depends a lot on the specific geometry structure. Several thousands is not much, I've played with millions, but if each geometry is very complex (thousands or more points) then it can become slow – Andrea Aime Jun 21 '12 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.