Package: openpoiservice
OpenpoiserviceOpenpoiservice (ops) is a flask application which hosts a highly customizable points of interest database derived from
OpenStreetMap.org data and therebyexploitsit's notion of tags...OpenStreetMaptagsconsisting of a key and value describe specific features of
map elements (nodes, ways, or relations) or changesets.  Both items are free format text fields, but often represent numeric
or other structured items.This service consumes OSM tags on nodes, ways and relations by grouping them into predefined categories.
If it picks up an OSM object tagged with one of the osm keys defined incategories.ymlit will import this
point of interest with specific additional tags which may be defined inops_settings.yml. Any additional tag,
for instancewheelchairorsmokingmay then be used to query the service via the API after import.For instance, if you want to request all pois accessible by wheelchair within a geometry, you could add then addwheelchair: ['yes', 'dedicated]infilterswithin the body of your HTTP POST request.You may pass 3 different types of geometry within the request to the database. Currently "Point" and "LineString" with
a corresponding and buffer are supported as well as a polygon. Points of interest will be returned within the given geometry.You can control the maximum size of geometries and further restrictions in the settings file of this service.Import ProcessThe osm file(s) to be imported are parsed several times to extract points of interest from relations (osm_type 3),
ways (osm_type 2) and nodes (osm_type 1) in order. Which type the specific point of interest originated from will be
returned in the response - this will help you find the object directly onOpenStreetMap.org.InstallationYou can either runopenpoiserviceon your host machine in a virtual environment or simply with docker. The Dockerfile
provided installs a WSGI server (gunicorn) which starts the flask service on port 5000.Technical specs for storing and importing OSM filesPython versionAs this service makes use of the python collections library, in particular the notion of deque's and its functions
it only supports python 3.5 and greater.DatabaseThis application uses a psql/postgis setup for storing the points of interest. We highly recommendusing thisdocker container.ImporterPlease consider the following technical requirements for parsing & importing osm files.RegionMemoryGermany8 GBEurope32 GBPlanet128 GBNote:Openpoiservice will import any osm pbf file located in the osm folder or subdirectory within.
This way you can split the planet file into smaller regions (e.g. download from Geofabrik, scraper script for the download
links to be found in the osm folder) and use asmallerinstance to import the global data set (as long as
the OSM files don't exceed 5 GB of disk space, 16 GB of memory will suffice to import the entire planet).Run as Docker Container (Flask + Gunicorn)Make your necessary changes to the settings in the fileops_settings_docker.yml. This file will be copied to the docker container.
If you are planning to import a different osm file, please download it to theosm folder(any folder within will be scanned
for osm files) as this will be a shared volume.Afterwards run:$docker-composeup-d-f/path/to/docker-compose.ymlOnce the container is built you can either, create the empty database:$dockerexec-itcontainer_name/ops_venv/bin/pythonmanage.pycreate_dbDelete the database:$dockerexec-itcontainer_name/ops_venv/bin/pythonmanage.pydrop_dbOr import the OSM data:$dockerexec-itcontainer_name/ops_venv/bin/pythonmanage.pyimport_dataRun in a Virtual EnvironmentCreate and activate a virtualenvThis repository usesimposm.parserto parse the
OpenStreetMap data. To this end,make suregoogle's protobufis installed on your system:Ubuntu (16.04 and earlier, supported on 17.10): most likely you will have to install protobuffrom sourceifhttps://imposm.org/docs/imposm.parser/latest/install.html#requirementsdoesn't
do the job.OS XUsing homebrewon OS Xbrew install protobuf` will suffice.Afterwards you can install the necessary requirements via pipwithpip install -r requirements.txtPrepare settings.ymlUpdateopenpoiservice/server/ops_settings.ymlwith your necessary settings and then run one of the following
commands.[$exportAPP_SETTINGS="openpoiservice.server.config.ProductionConfig|DevelopmentConfig"]Create the POI DB$pythonmanage.pycreate_dbDrop the POI DB$pythonmanage.pydrop_dbParse and import OSM data$pythonmanage.pyimport_dataRun the Application with Flask-Werkzeug$pythonmanage.pyrunPer default you can access the application at the addresshttp://localhost:5000/Want to specify a different port?$pythonmanage.pyrun-h0.0.0.0-p8080Tests$exportTESTING="True"&&pythonmanage.pytestCategory IDs and their configurationopenpoiservice/server/categories/categories.ymlis a list of (note:not all!) OpenStreetMap tags with arbitrary category IDs.
If you keep the structure as follows, you can manipulate this list as you wish.transport:id:580children:aeroway:aerodrome:581aeroport:582helipad:598heliport:599amenity:bicycle_parking:583sustenance:id:560children:amenity:bar:561bbq:562...Openpoiservice uses this mapping while it imports pois from the OpenStreetMap data and assigns the custom category IDs
accordingly.column_mappingsinopenpoiservice/server/ops_settings.ymlcontrols which OSM information will be considered in the database and also if
these may be queried by the user via the API , e.g.wheelchair:smoking:fees:For instance means that the OpenStreetMap tagwheelchairwill be considered
during import and save to the database. A user may then add a list of common values in the filters objectwheelchair: ['yes', 'dedicated', ...]which correspond to the OSM common values of the tag itself, e.g.https://wiki.openstreetmap.org/wiki/Key:wheelchair.API DocumentationThe documentation for this flask service is provided viaflasggerand can be
accessed viahttp://localhost:5000/apidocs/.Generally you have three different request typespois,statsandlist.Usingrequest=poisin the POST body will return a GeoJSON FeatureCollection
in your specified bounding box or geometry.Usingrequest=statswill do the same but group by the categories, ultimately
returning a JSON object with the absolute numbers of pois of a certain group.Finally,request=listwill return a JSON object generated fromopenpoiservice/server/categories/categories.yml.ExamplesPOIS around a buffered pointcurl-XPOST\http://localhost:5000/pois\-H'Content-Type: application/json'\-d'{"request": "pois","geometry": {"bbox": [[8.8034, 53.0756],[8.7834, 53.0456]],"geojson": {"type": "Point","coordinates": [8.8034, 53.0756]},"buffer": 250}}'POIs of given categoriescurl-XPOST\http://localhost:5000/pois\-H'Content-Type: application/json'\-d'{"request": "pois","geometry": {"bbox": [[8.8034, 53.0756],[8.7834, 53.0456]],"geojson": {"type": "Point","coordinates": [8.8034, 53.0756]},"buffer": 100},"limit": 200,"filters": {"category_ids": [180, 245]}}'POIs of given category groupscurl-XPOST\http://localhost:5000/pois\-H'Content-Type: application/json'\-d'{"request": "pois","geometry": {"bbox": [[8.8034, 53.0756],[8.7834, 53.0456]],"geojson": {"type": "Point","coordinates": [8.8034, 53.0756]},"buffer": 100},"limit": 200,"filters": {"category_group_ids": [160]}}'POI Statisticscurl-XPOST\http://129.206.7.157:5005/pois\-H'Content-Type: application/json'\-d'{"request": "stats","geometry": {"bbox": [[8.8034, 53.0756],[8.7834, 53.0456]],"geojson": {"type": "Point","coordinates": [8.8034, 53.0756]},"buffer": 100}}'POI Categories as a listcurl-XPOST\http://127.0.0.1:5000/pois\-H'content-type: application/json'\-d'{"request": "list"}'