whosonfirst / go-whosonfirst-pip-v2

An in-memory point-in-polygon (reverse geocoding) package for GeoJSON data, principally Who's On First data.
BSD 3-Clause "New" or "Revised" License
11 stars 5 forks source link

Add support for decorating responses from SQLite databases #17

Closed thisisaaronland closed 6 years ago

thisisaaronland commented 6 years ago

Essentially support for an ?extras= parameter. See also:

https://github.com/whosonfirst/go-whosonfirst-pip-v2/issues/16

thisisaaronland commented 6 years ago

First pass:

./bin/wof-pip-server -cache-all -www -mode sqlite -allow-extras -extras-database microhood-20171212.db microhood-20171212.db

curl 'http://localhost:8080/?latitude=37.794906&longitude=-122.395229&extras=name:,edtf:' | python -mjson.tool

{
    "places": [
        {
            "edtf:cessation": "2016-02-07",
            "edtf:inception": "2016-01-30",
            "mz:is_ceased": 1,
            "mz:is_current": 0,
            "mz:is_deprecated": 0,
            "mz:is_superseded": 0,
            "mz:is_superseding": 0,
            "mz:latitude": 37.794906,
            "mz:longitude": -122.395229,
            "mz:max_latitude": 37.796684756991,
            "mz:max_longitude": -122.39310801029,
            "mz:min_latitude": 37.792339744389,
            "mz:min_longitude": -122.39753901958,
            "mz:uri": "https://whosonfirst.mapzen.com/data/420/561/633/420561633.geojson",
            "name:eng_x_preferred": [
                "Super Bowl City"
            ],
            "wof:country": "US",
            "wof:id": 420561633,
            "wof:lastmodified": 1501284302,
            "wof:name": "Super Bowl City",
            "wof:parent_id": 85865899,
            "wof:path": "420/561/633/420561633.geojson",
            "wof:placetype": "microhood",
            "wof:repo": "whosonfirst-data",
            "wof:superseded_by": [],
            "wof:supersedes": []
        }
    ]
}
thisisaaronland commented 6 years ago

Second pass:

./bin/wof-pip-server -www -allow-extras -cache-all -mode sqlite ~/Downloads/microhood-20171212.db
15:15:14.128454 [wof-pip-server] STATUS index extras /var/folders/ld/cr5tbfw55_l0g9w15nq5dc2h0000gn/T/pip-extras344905520
15:15:14.133227 [wof-pip-server] STATUS -www flag is true causing the following flags to also be true: -allow-geojson -candidates
15:15:14.133251 [wof-pip-server] STATUS listening on localhost:8080
15:15:15.136439 [wof-pip-server] STATUS indexing 500 records indexed
15:15:16.138114 [wof-pip-server] STATUS indexing 749 records indexed
15:15:17.133487 [wof-pip-server] STATUS indexing 980 records indexed
15:15:18.137925 [wof-pip-server] STATUS indexing 1249 records indexed
15:15:19.132730 [wof-pip-server] STATUS finished indexing

curl 'http://localhost:8080/?latitude=37.794906&longitude=-122.395229&extras=name:,edtf:' | python -mjson.tool

{
    "places": [
        {
            "edtf:cessation": "2016-02-07",
            "edtf:inception": "2016-01-30",
            "mz:is_ceased": 1,
            "mz:is_current": 0,
            "mz:is_deprecated": 0,
            "mz:is_superseded": 0,
            "mz:is_superseding": 0,
            "mz:latitude": 37.794906,
            "mz:longitude": -122.395229,
            "mz:max_latitude": 37.796684756991,
            "mz:max_longitude": -122.39310801029,
            "mz:min_latitude": 37.792339744389,
            "mz:min_longitude": -122.39753901958,
            "mz:uri": "https://whosonfirst.mapzen.com/data/420/561/633/420561633.geojson",
            "name:eng_x_preferred": [
                "Super Bowl City"
            ],
            "wof:country": "US",
            "wof:id": 420561633,
            "wof:lastmodified": 1501284302,
            "wof:name": "Super Bowl City",
            "wof:parent_id": 85865899,
            "wof:path": "420/561/633/420561633.geojson",
            "wof:placetype": "microhood",
            "wof:repo": "whosonfirst-data",
            "wof:superseded_by": [],
            "wof:supersedes": []
        }
    ]
}
thisisaaronland commented 6 years ago

Done as part of the sqlite branch.