A GeoJSON REST service for georeferenced Wikipedia articles, built with MapFish.
Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
wikigeolinks
.gitignore
README.md
layers.ini
setup.cfg
setup.py

README.md

wikigeolinks

Adrià Mercader -http://amercader.net (@amercader)

A GeoJSON REST service for georeferenced Wikipedia articles, built with MapFish.

It was built around the georeferenced Wikipedia articles dataset that can be downloaded from this website:

http://amercader.net/dev/wikipedia

You will need to import the dataset to a PostGIS database (or any other geodatabase engine supported by GeoAlchemy, though this has not been tested).

Installation

Create and activate a virtual environment:

virtualenv --no-site-packages wikigeolinks
cd wikigeolinks
source bin/activate
easy_install pip

Install the source (will also install the other requirements):

pip install -e git+git://github.com/amercader/wikigeolinks.git#egg=wikigeolinks

Create a configuration file:

cd src/wikigeolinks
paster make-config wikigeolinks development.ini

Edit the database connection string to point to your database containing the georeferenced articles:

sqlalchemy.url = postgresql://<user_name>:<password>@<server>/<database>

Serve the application with the following command:

paster serve --reload development.ini

You should get a GeoJSON response visiting the following URL:

http://localhost:5000/articles

API Overview

Georeferenced articles are returned as GeoJSON Features:

GET http://<server>/articles/<id_or_title>

E.g.:

GET http://<server>/articles/1234
GET http://<server>/articles/United%20States%20Naval%20Observatory

{
    geometry: {
        type: "Point",
        coordinates: [
            -77.066946,
            38.921473
        ]
    },
    id: 1234,
    type: "Feature",
    bbox: [
        -77.066946,
        38.921473,
        -77.066946,
        38.921473
    ],
    properties: {
        links_count: 7,
        title: "United States Naval Observatory"
    }
}

You can use both the numeric id or the article title as indentifiers.

You can perform various queries using the MapFish Protocol on the main endpoint:

GET http://<server>/articles?<query>
  • Search by title:

      GET http://<server>/articles?title__ilike=%tarrag%&attrs=id,title,links_count&queryable=title&order_by=links_count&dir=desc&limit=30
    
  • Search by location:

      GET http://<server>/articles?lon=-1.60&lat=54.98&tolerance=0.5&order_by=links_count&dir=desc&limit=30
    
  • Search by bounding box:

      GET http://<server>/articles?bbox=5,50,7,60
    

All these queries return a FeatureCollection of georeferenced articles.

{
    type: "FeatureCollection",
    features: [
        {
            geometry: {
                type: "Point",
                coordinates: [
                    1.25,
                    41.13333333333333
                ]
            },
            id: 47441,
            type: "Feature",
            bbox: [
                1.25,
                41.13333333333333,
                1.25,
                41.13333333333333
            ],
            properties: {
                links_count: 13,
                title: "Camp de Tarragona"
            }
        },
        {
            geometry: {
                type: "Point",
                    coordinates: [
                        1.2740638888888889,
                        41.19218055555555
                    ]
            },
            id: 172375,
            type: "Feature",
            bbox: [
                1.2740638888888889,
                41.19218055555555,
                1.2740638888888889,
                41.19218055555555
            ],
            properties: {
                links_count: 9,
                title: "Camp de Tarragona railway station"
            }
        },
        ...
    }