Skip to content

Commit

Permalink
feat: Support importPlace with SQLite
Browse files Browse the repository at this point in the history
This upates `wof_extract_sqlite` to support the
`imports.whosonfirst.importPlace` property, using similar logic to
`wof-admin-lookup`.

When `importPlace` specifies a small area, like a city, this speeds up
the import process considerably!
  • Loading branch information
orangejulius committed Apr 23, 2020
1 parent 335b4d4 commit 269d6bc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/wof_extract_sqlite.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const fs = require('fs');
const whosonfirst = require('pelias-whosonfirst');
const config = require('pelias-config').generate().imports.whosonfirst;
const SQLiteStream = whosonfirst.SQLiteStream;
const through = require('through2');
const Placeholder = require('../Placeholder');
Expand Down Expand Up @@ -48,7 +49,12 @@ fs.readdirSync(WOF_DIR)
.map(file => path.join(WOF_DIR, file))
.forEach(dbPath => {
sqliteStream.append(next => {
next(new SQLiteStream(dbPath, SQLiteStream.findGeoJSONByPlacetype(layers)));
next(new SQLiteStream(
dbPath,
config.importPlace ?
SQLiteStream.findGeoJSONByPlacetypeAndWOFId(layers, config.importPlace) :
SQLiteStream.findGeoJSONByPlacetype(layers)
));
});
});

Expand Down

0 comments on commit 269d6bc

Please sign in to comment.