Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

up vote 1 down vote accepted

you can use cql or ecql filters.

cql_filter=INTERSECT(the_geom,%20POINT%20(-10.00000%20.000000))

or

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

or

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...

share|improve this answer
    
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"
  xmlns:topp="http://www.openplans.org/topp"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns="http://www.opengis.net/ogc"
  xmlns:gml="http://www.opengis.net/gml"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/wfs
                      http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
  <wfs:Query typeName="topp:states">
    <Filter>
      <Intersects>
        <PropertyName>the_geom</PropertyName>
          <gml:Polygon>
            ...
          </gml:Polygon>
        </Intersects>
      </Filter>
  </wfs:Query>
</wfs:GetFeature>

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

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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