Skip to content

Commit

Permalink
fix: Merge pull request #52 from pelias/useLocalResolver
Browse files Browse the repository at this point in the history
Use localResolver method from pelias-wof-admin-lookup
  • Loading branch information
Diana Shkolnikov authored Dec 1, 2017
2 parents 3290c6b + 4e89048 commit 4d77c7d
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 347 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ RUN npm install
RUN npm test

# start the pip service using the directory the data was downloaded to
CMD ["npm", "start", "--", "/data/whosonfirst"]
CMD ["npm", "start"]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The `pelias-pip-service` npm module can be found here:

#### Usage

To start the PiP service, type: `npm start <path to Who's on First data>`. By default, the service starts on port 3102.
To start the PiP service, type: `npm start`. By default, the service starts on port 3102. It will look for Who's on First data in the place configured in `pelias.json`.

Requests are made to the endpoint in the format: `http://localhost:3102/<lon>/<lat>`.

Expand All @@ -42,6 +42,7 @@ Because [pelias/whosonfirst](https://github.com/pelias/whosonfirst) is a depende
`npm run download`

This will download Who's on First data using the same [configuration options](https://github.com/pelias/whosonfirst#downloading-the-data) from `pelias.json` as the whosonfirst downloader.
That means it will automatically put the data in the place the service will expect to load it from.

##### Privacy Concerns

Expand All @@ -57,4 +58,4 @@ When any of these headers are supplied in the request (with any value), the requ

The only available configuration option is the port on which the service runs. To run on a different port, start with:

`PORT=3103 npm start <path to Who's on First data>`
`PORT=3103 npm start`
9 changes: 2 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,8 @@ function log() {
});
}

module.exports = (datapath) => {
// verify the WOF data structure first (must contain data and meta directories)
if (!['meta', 'data'].every((sub) => { return fs.existsSync(path.join(datapath, sub)); })) {
throw Error(`${datapath} does not contain Who's on First data`);
}

const pointInPoly = adminLookup.resolver(datapath);
module.exports = () => {
const pointInPoly = adminLookup.localResolver();

const router = new Router();
router.get('/:lon/:lat', validate, parseLayers, lookup(pointInPoly), output);
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try {
const app = require('./app')(process.argv[2]);
const app = require('./app')();
const port = ( parseInt(process.env.PORT) || 3102 );

app.listen(port, () => {
Expand Down
Loading

0 comments on commit 4d77c7d

Please sign in to comment.