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 am displaying 100 000 points in a layer via WFS protocol. I need about 5 minutes. However, 100 000 does not seems so much...

My points are stored in PostGIS, in a column defined this way : AddGeometryColumn('records','position', 4326, 'POINT', 2)

My geoserver server tell me almost instantly this :

outputFormat = text/xml; subtype=gml/3.1.1
    resultType = results

So i think it it ok for reading in postGIS, and send the response to my browser.

But my firefox/chrome are very long to display it, so much that it tells me that the page is unresponsive many times. So maybe it is my javascript or my browser who is long to display. Here is my javascript with openlayer :

var wfs = new OpenLayers.Layer.Vector("Record2", {
                    strategies: [new OpenLayers.Strategy.Fixed()],
                    protocol: new OpenLayers.Protocol.WFS({          
                    version: "1.1.0",
                    url: "http://localhost:8080/geoserver/wfs",            
                    featurePrefix: "cite",
                    featureType: "record",
                    featureNS: "http://www.openplans.org/cite",
                    srsName: "EPSG:4326",
                        geometryName: ""
                  })          
        });

        map.addLayers([world, wfs]);
        map.zoomToMaxExtent();

Do you have an idea of the reason for this?

Thks a lot!

share|improve this question
    
Does the browser become unresponsive also when you zoom/pan the map? –  unicoletti May 25 '13 at 17:17
    
I think the important thing here is: 100,000 is a lot, considering what you're doing with the data. Does your user have any hope of actually using the data, either seeing all those points at once or any processing that requires them all to be loaded in the client? –  tomfumb May 26 '13 at 15:03

1 Answer 1

up vote 14 down vote accepted

The reasons why it is so slow is

  • you retrieve megabytes of data doing your WFS request. To confirm, open Firebug (Firefox addon debugger) or Chrome and look into Net(work) panel. You will see it's too huge. This data takes time to be process (your "page is unresponsive" syndrom)
  • browser capabilities: you never display more than one thousand of feature in a browser because lot of DOM objects can't be handle by any browser (limit in the future will change with Canvas and WebGL renderer in upcoming OpenLayers 3 version)
  • fixed strategy : load all data in one time

You can also look the related answer in gis.stackexchange.com about same topic of WFS poor perfs.

Some solutions (to combine and not definitive)

  • polygon simplification (at PostGIS level)
  • zoom level (higher level you display WMS and less features you use WFS). If you need to make some interrogation you do a wmsGetFeatureInfo (WMS related) and not a getfeature (WFS related)
  • Strategy (for OpenLayers you already do it)
  • Agregation (only for points) with AnimatedCluster plugin
  • Define maximum number of features (in Geoserver config or through WFS URL call)
  • Change output to Geojson in your WFS call and you retrieve it with a code like below

    var myLayer = new OpenLayers.Layer.Vector("States", {
        minScale: 15000000,
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: new OpenLayers.Protocol.WFS({
            url: "http://demo.opengeo.org/geoserver/wfs",
            featureType: "states",
            featureNS: "http://www.openplans.org/topp",
            outputFormat: "application/json",
            readFormat: new OpenLayers.Format.GeoJSON()
        }),
        renderers: renderer
    });
    
  • Change Strategy to BBOX (see above code)
share|improve this answer
    
I'd say that to speed things up you need just 4 things: (1) WMS instead of WFS, (2) GeoJSON as output, (3) use a primary key in your postgis table and use that in geoserver (I assume it works like mapserver for queries and connections), (4) use strategy and zoom level around 10 –  Gery May 25 '13 at 7:01
    
Thks ThomasG77 and Gery, very clear explanations. –  Gabriel May 28 '13 at 19:08
    
Great comments. Using GeoJSON and AnimatedCluster has really sped up my previosly clunky mobile app. Thanks ThomasG77 and acuriousanimal.com –  minisaurus Feb 8 at 11:58

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.