# POI Data

## OpenStreetMap POIs

[OpenStreetMap](https://www.openstreetmap.org/) (OSM) is maybe the most extensive open data project for geo-data. It has rich information on points of interest (POIs), such as apartments, shops, or offices, globally.

Based on the original `.osm` files, which [Geofabrik](http://download.geofabrik.de/) provides as a daily update, we parse the OSM tags and create consolidated objects.

We aggregate tags that are useful for categorization into 24 high-level categories:

`administration, airport, apartment, art_culture, automobile, beauty, cafe, drinks, education, entertainment, food, groceries, medical, misc, office, public_service, public_transportation, recreation, religious_building, service, shopping, social_service, sport, tourism, wholesaler`

For ways and relations, we transform the building footprint into the `GeoJSON` format. For address and contact details, we also consolidate the OSM tags into separate objects.

### Prerequisites

Installed version of _node_, _npm_, _Docker_ and _docker-compose_.

This project has dependency on [_h3-node_](https://www.npmjs.com/package/h3-node/). This module requires you to have the following libraries installed on your machine: _git, gyp, make, cmake, and a C compiler (gcc or clang)_.

An easy way to run docker on your machine is using [_Docker Desktop_](https://docs.docker.com/desktop/) with a GUI to manage your containers.

**Hints for macOS**

Installation of _node + npm_ and _docker-compose_ via _Homebrew_:

```
brew install node, docker-compose
```

### Setup

Install node modules _in both_ the _current folder/project_ and in the _shared folder which is present in the root directory_.

```
npm ci
```

Make sure Docker is running on your machine.

Start mongo with _docker-compose_

```
docker-compose up -d
```

Load OSM data into database

```
npm run start-processing:local
```

Follow the prompts to download, process and write data for a continent, country or region \[2]

_**Alternative**_: You can also download .osm.pbf files directly from [Geofabrik](http://download.geofabrik.de/) and place them in an arbitrary folder under `tmp/osmFiles` and follow \[1] instead.

```
[1] Existing download
[2] New download
[0] Cancel

Do you want to make a new download? [1, 2, 0]: 2

[1] africa
[2] antarctica
[3] asia
[4] australia-oceania
[5] central-america
[6] europe
[7] north-america
[8] south-america
[0] Cancel

Which continent are you interested in? [1...8 / 0]: 
```

### Usage

Run the app locally.

(Data can only be returned for regions that have previously been downloaded and processed.)

```
npm run start-api:local
```

#### API Calls

**Get POIs within Radius**

Request Method: **GET**\
URL: `/radius/:radius`\
Query Params (**required**): `h3_index` _**OR**_ `lat, lng`

_Example_: `localhost:3001/radius/50?lat=52.5291472&lng=13.4015439`

**Get POIs within Polygon**

Request Method: **GET**\
URL: `/geojson`\
Request Body (**required**): `GeoJSON` format\


_Example_: `localhost:3001/geojson`\
Request Body:

```
    {
        "geometry": {
            "type": "Polygon",
            "coordinates": […]
        }
    }
```

**Categories**

Relevant yet unmatched OSM tags are automatically added to the category `misc` and then can be added to more appropriate high-level categories. When committing, also include the new tags under `misc` for later categorization.

#### License

We are neither providing nor are we responsible for the OSM data. This repository is purely a tool for working with that data. You are responsible for complying with OSM's and [Geofabrik](http://www.geofabrik.de/)'s licences when using the data.

OSM is published under the [Open Data Commons Open Database License](https://www.openstreetmap.org/copyright).
