[Users] GeoJSON vs WKT

Andreas Hocevar ahocevar at opengeo.org
Tue May 25 10:43:51 CEST 2010


Hi Knut,

I don't think that anybody has done benchmarking on the various formats that GeoExt supports through OpenLayers.

Be warned, regardless of the format you choose, that building the geometries and rendering features on a vector layer is a time consuming task. Web applications that process more than a few hundred features are known to feel slow, and switching to a different format won't make much of a difference.

Alternatives to check for a large number of features include rendering features on the server (e.g. using WMS) and using WMS GetFeatureInfo or WFS GetFeature to get information for a small number of features. With the available WMSGetFeatureInfo and GetFeature controls of OpenLayers, you can easily build interactive applications without having all the features on the client.

Regards,
Andreas.

On May 24, 2010, at 15:48 , Knut Staring wrote:

> Dear list,
> 
> I was wondering if there are any criteria for choosing between GeoJSON
> or WKT when feeding GeoExt from the database? I care about both
> transmission size (since many users will have low bandwidth) and
> processing (users may have low spec hardware, and even the latest
> Chrome and Opera struggle with too large geometries).
> 
> WKT looks more compact, in that there are much fewer square brackets.
> But since browsers speak javascript, it may be heavier to process?
> 
> I've written some PHP to generate GeoJSON, like this:
> http://109.74.202.200/ke/geojson.php, which feeds into
> http://109.74.202.200/ke/feature-grid.html in the following way:
> 
> protocol: new OpenLayers.Protocol.HTTP({
>                url: "geojson.php",
> 		format: new OpenLayers.Format.GeoJSON()
>            })
> 
> However, looking at http://waterandhealth.eu/, I notice that WKT is
> used rather than GeoJSON:
> http://waterandhealth.eu/php/geometries.php
> 
> Here is a snippet from the javascript:
> 
> Atlas.data.store.GeometryStore = Ext.extend(Ext.data.JsonStore, {
>    features: [],
>    countryRoot: null,
>    constructor: function (a) {
>        Ext.apply(this, a);
>        Atlas.data.store.GeometryStore.superclass.constructor.call(this,
> Ext.apply({
>            proxy: new Ext.data.HttpProxy({
>                url: "php/geometries.php",
>                method: "POST"
>            }),
>            root: "geometries",
>            fields: ["fid", "geom", "country_id", "country_name"]
>        }, a));
>        this.addEvents("featureLoad");
>        this.on("load", function () {
>            this.data.each(function (e, b, f) {
>                var d = OpenLayers.Geometry.fromWKT(e.get("geom"));
>                var c = new OpenLayers.Feature.Vector(d, {
>                    id: e.get("fid"),
>                    countryId: e.get("country_id"),
>                    countryName: e.get("country_name"),
>                    value: -1
>                });
>                this.features.push(c)
>            }, this);
>            this.fireEvent("featureLoad")
>        })
>    },
>    getFeatures: function () {
>        var c = this.features;
>        var d = [];
>        for (var b = 0; b < c.length; b++) {
>            var a = c[b].clone();
>            d.push(a)
>        }
>        return d
>    }
> });
> 
> Grateful for any guidance.
> 
> Cheers,
> Knut
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list