4

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 OpenLayers:

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?

2
  • Does the browser become unresponsive also when you zoom/pan the map?
    – unicoletti
    May 25, 2013 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, 2013 at 15:03

1 Answer 1

18

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)
3
  • 1
    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, 2013 at 7:01
  • Thks ThomasG77 and Gery, very clear explanations.
    – Gabriel
    May 28, 2013 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, 2014 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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