Skip to content

CatalystCode/featureService

Repository files navigation

featureService

Travis CI status Docker Pulls

What's this?

The featureService is a simple JSON REST API that enables you to work with the OpenStreetMap data-set.

Using the featureService you can, for example, discover all the locations or points of interest in a particular area or look up properties of locations such as their bounding box, centroid or name.

Setup

System dependencies

In order to run this project on your machine, you will need to install the following system-level dependencies:

Azure resources

You will need to set up an instance of Azure Databases for PostgreSQL for the featureService.

You can run the following snippet in a Bash shell (such as the Windows Subsystem for Linux) to set up a new instance of Azure Databases for PostgreSQL using the Azure CLI:

dbname="----CHANGEME----"             # e.g. myfeaturesservicedb
dbuser="----CHANGEME----"             # e.g. admin
dbpassword="----CHANGEME----"         # e.g. featureService1!Rocks
dbsku="----CHANGEME----"              # e.g. GP_Gen4_2
resource_group="----CHANGEME----"     # e.g. myfeaturesserviceresourcegroup
resource_location="----CHANGEME----"  # e.g. eastus

az group create \
  --name="${resource_group}" \
  --location="${resource_location}"

az postgres server create \
  --name="${dbname}" \
  --admin-user="${dbuser}" \
  --admin-password="${dbpassword}" \
  --resource-group="${resource_group}" \
  --location="${resource_location}" \
  --sku-name="${dbsku}"

Next, enable clients to connect to the database. You can either white-list particular IPs or a range of IPs:

az postgres server firewall-rule create \
  --server-name="${dbname}" \
  --resource-group="${resource_group}" \
  --start-ip-address="0.0.0.0" \
  --end-ip-address="255.255.255.255" \
  --name="AllowAll"

Running the application

Once the system dependencies are installed and your Postgres database has been created, you can run the project via Docker:

docker build -t featureservice .

docker run \
  -p 3035:80 \
  -e FEATURES_DB_USER="${dbuser}@${dbname}" \
  -e FEATURES_DB_PASSWORD="${dbpassword}" \
  -e FEATURES_DB_HOST="${dbname}.postgres.database.azure.com" \
  -t featureservice

The first time that you run this command, it will take about 90 minutes while your Postgres on Azure instance is getting populated with over 2GB of global geo-spatial features and appropriate indices are being built. On subsequent runs, the start should be instantaneous.

Using the application

After starting the service, you will be able to call the featureService, for example via the following requests: