Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

City-of-Helsinki/geocoder

Repository files navigation

geocoder

geocoder is a Django-based web service that allows for geocoding and reverse geocoding of addresses, POI lookups and browsing city plan geometries.

Currently there are data importing scripts for the cities of Helsinki and Manchester.

API

The API specification is automatically generated by django-tastypie-swagger. A live version lives at http://dev.hel.fi/geocoder/doc.

Examples

Geocoding

http://dev.hel.fi/geocoder/v1/address/?name=aleksanterinkatu+20
{
    "meta": {
        ...
    },
    "objects": [
        {
            "id": 34465, 
            "letter": "", 
            "location": {
                "coordinates": [
                    24.95212937899918, 
                    60.1633660991522
                ], 
                "type": "Point"
            }, 
            "municipality": "/v1/municipality/91/", 
            "name": "Unioninkatu 1, Helsinki", 
            "number": 1, 
            "number_end": null, 
            "resource_uri": "/v1/address/34465/", 
            "street": "Unioninkatu"
        }, 
        {
            "id": 34466, 
            "letter": "", 
            "location": {
                "coordinates": [
                    24.95068871283578, 
                    60.16327581648179
                ], 
                "type": "Point"
            }, 
            "municipality": "/v1/municipality/91/", 
            "name": "Unioninkatu 2, Helsinki", 
            "number": 2, 
            "number_end": null, 
            "resource_uri": "/v1/address/34466/", 
            "street": "Unioninkatu"
        }, 
        ...
    ]
}

Reverse geocoding

http://dev.hel.fi/geocoder/v1/address/?format=json&lon=24.9531&lat=60.1689
{
    "meta": {
        ...
    },
    "objects": [
        {
            "distance": 18.5508163203, 
            "id": 461, 
            "letter": "", 
            "location": {
                "coordinates": [
                    24.95316597791287, 
                    60.168976122654
                ], 
                "type": "Point"
            }, 
            "municipality": "/v1/municipality/91/", 
            "name": "Aleksanterinkatu 20, Helsinki", 
            "number": 20, 
            "number_end": null, 
            "resource_uri": "/v1/address/461/", 
            "street": "Aleksanterinkatu"
        }, 
        {
            "distance": 34.2157243331, 
            "id": 464, 
            "letter": "", 
            "location": {
                "coordinates": [
                    24.9528237422914, 
                    60.16896702585059
                ], 
                "type": "Point"
            }, 
            "municipality": "/v1/municipality/91/",
            "name": "Aleksanterinkatu 22, Helsinki",
            "number": 22,
            "number_end": null,
            "resource_uri": "/v1/address/464/",
            "street": "Aleksanterinkatu"
        },
        ...
    ]
}

POI search

http://dev.hel.fi/geocoder/v1/poi/?format=json&lon=24.9531&lat=60.1689&category__type=park
{
    "meta": {
        ...
    }, 
    "objects": [
        {
            "category": "/v1/poicategory/4/",
            "category_type": "park",
            "description": "",
            "distance": 691.107942661,
            "id": 862,
            "location": {
                "coordinates": [
                    24.94762037868587,
                    60.16744822200204
                ], 
                "type": "Point"
            }, 
            "name": "Esplanadin puisto",
            "origin_id": "21357",
            "resource_uri": "/v1/poi/862/",
            "street_address": "Eteläesplanadi-Pohjoisesplanadi (Kaartinkaupunki)",
            "zip_code": "00170"
        },
        ...
    ]
}

Environment installation

Ubuntu packages:

virtualenvwrapper libpq-dev python-dev

Shell commands:

mkvirtualenv geocoder
pip install -r requirements.txt

Database installation

Ubuntu packages:

language-pack-fi postgis postgresql postgresql-contrib

Shell commands:

sudo su postgres
createdb -l fi_FI.UTF8 -E UTF8 -T template0 template_postgis
# (following can already be installed)
createlang -d template_postgis plpgsql
psql -d template_postgis -c"CREATE EXTENSION hstore;"
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
createuser -R -S -D -P geocoder
createdb -O geocoder -T template_postgis -E utf8 geocoder

Edit file /etc/postgresql/9.1/main/pg_hba.conf. Change line

local   all             all                                     peer

to

local   all             all                                     md5

Now, restart the postgres server:

sudo service postgresql restart

Releases

No releases published

Packages

No packages published

Languages