← Back to team overview

dhis2-devs team mailing list archive

Re: Generating GeoJSON from the database

 

On Thu, May 20, 2010 at 1:26 PM, Knut Staring <knutst@xxxxxxxxx> wrote:
> Working on converting all our data to geojson, I've changed my mind
> for representation in the database somewhat. Instead of just having
> the coordinates in one field and the type of geometry in another, it
> will be both more efficient and easier to have just store the full
> geometry string in one field, like this:
>
> {"type": "Point", "coordinates": [6.18218, 45.5949]}
>
> Similarly for Polygon and Multipolygon.

On the topic of representation and transmission of geometries, I
notice that http://waterandhealth.eu/ does not use GeoJSON, but rather
the Well Known Text  (WKT) format, which seems slightly more compact
(but is perhaps harder to process on the client?). Below is a snippet
of their output, which can be compared to mine
(http://109.74.202.200/ke/geojson.php):

{
    "geometries": [{
        "fid": "1",
        "geom": "POLYGON((-2557240.9748832
6329005.6983322,-2564581.4426868 6353888.5764035,-2553392.6270149
6391595.0284018,-2502799.807139 6423373.1582081,-2473735.0208929
6401109.7954626,-2456127.2424861 6347915.0302067,-2467612.2173775
6310880.8052258,-2469614.0814956 6310851.8313805,-2504979.3381634
6246832.1685795,-2487429.17942 6188194.8654726,-2497166.6999307
6155148.5968215,-2550830.1263206 6119993.6983044,-2584648.0144422
6122612.2128699,-2585395.8731606 6100662.2483157,-2609950.1694991
6090001.439647,-2624827.4209589 6102934.6409606,-2619099.8045086
6146070.9573777,-2645062.206619 6208261.4281141,-2633371.4023808
6193731.1831049,-2631973.584123 6230944.3385753,-2601190.04894
6250081.9372284,-2557240.9748832 6329005.6983322))",
        "country_id": "4",
        "country_name": "Albania"
    },
    {
        "fid": "2",
        "geom": "POLYGON((-3787328.9817063
7292282.8224448,-3768426.9845767 7270348.9602439,-3776802.3350657
7268439.5634358,-3799035.4668783 7278575.4189864,-3787328.9817063
7292282.8224448))",
        "country_id": "133",
        "country_name": "Andorra"
    }]
}



References