nationalparkservice / places-api

An API, written in Node as Express middleware, built to work with the OSM API database schema. Used internally by Places.
The Unlicense
0 stars 0 forks source link

Description

places-api is an implementation of the OpenStreetMap API written in node.js as middleware for the express.js web application framework.

API Installation

The places-api acts as middleware for express.js, and cannot run on its own. The places-website is designed to be a container for the places-api.

The following steps are designed to be copied and pasted directly into your CLI.

#1. Clone the places-website

git clone https://github.com/nationalparkservice/places-website.git

#2. Change directory to places-website

cd places-website

#3. Install the components

npm install

#4. Copy the example.config.json to config.json

cp example.config.json config.json

#5. Open the config.json with your favorite text editor and change the values to match your settings

`which subl || which vim` config.json

#6. You're ready to run the website!

npm start

#Database Setup

This guide will detail the steps to installing the PostGIS database on an ubuntu machine. There is a guide for windows as well. To install on Mac OSX, see ./node_modules/places-api/scripts/create_osm_db_mac.sh.

#1. Change to the API directory

cd ./node_modules/places-api/

#2. Run the postgresql 9.4 and PostGIS 2.1 install script here:

bash ./scripts/install_postgres_9.4.sh

#3. Either clone an existing set of places_api databases or run the database setup script:

bash ./scripts/create_osm_db.sh

Notes:

The default snapshot database name (poi_pgs) and owner (postgres) are configurable in config.json, however they are hardcoded into two functions (nps_dblink_pgs and nps_dblink_pgs_text) in sql_scripts/api/func_nps_tools.sql. If you choose to stray from the defaults, this file will need to be edited accordingly.

Usage

The iD editor that is include will not work be default, as it needs to be built. You will need to remove the places-editor directory from the /node_modules directory and clone it in instead. This will ensure that you have all the dev dependencies.

After it's cloned, edit the js/id/id.js file's npmap variable to reflect the path to your server/port.

Once you do that, run an npm install on it and the make command.

You can then navigate to http://SERVER:PORT/dist and start editing the map!