Skip to content

Commit

Permalink
Merge pull request #323 from pelias/staging
Browse files Browse the repository at this point in the history
Merge staging into production
  • Loading branch information
orangejulius authored Sep 10, 2018
2 parents 44bd672 + a351966 commit bafed2f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 77 deletions.
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ language: node_js
notifications:
email: false
node_js:
- 4
- 6
- 8
- 10
matrix:
fast_finish: true
env:
global:
- BUILD_LEADER_ID=2
script: npm run travis
before_install:
- npm i -g npm@^3.0.0
before_script:
- npm prune
- npm i -g npm
after_success:
- npm install -g npx
- npx -p node@8 npm run semantic-release
- npx semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
>This repository is part of the [Pelias](http://pelias.io)
>project. Pelias is an open-source, open-data geocoder built by
>[Mapzen](https://www.mapzen.com/) that also powers [Mapzen Search](https://mapzen.com/projects/search). Our
>official user documentation is [here](https://mapzen.com/documentation/search/).
>This repository is part of the [Pelias](https://github.com/pelias/pelias)
>project. Pelias is an open-source, open-data geocoder originally sponsored by
>[Mapzen](https://www.mapzen.com/). Our official user documentation is
>[here](https://github.com/pelias/documentation).
# Pelias Geonames importer

Expand All @@ -15,7 +15,7 @@ import.

## Requirements

- Node.js '4.0' or greater
- Node.js '6.0' or greater

### Installation

Expand All @@ -34,7 +34,8 @@ The importer can be configured from your local [pelias-config](https://github.co
"imports": {
"geonames": {
"datapath": "/path/to/geonames/data",
"countryCode": "MX"
"countryCode": "MX",
"sourceURL": "http://example.com/geonames/"
}
}
}
Expand All @@ -45,6 +46,9 @@ The following are all *optional*:
* `datapath`: the path to geonames data. Defaults to a directory inside the importer.
* `countryCode`: the two digit ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1)) country code
for the country for which data will be downloaded and imported. Use `ALL` for all countries.
* `sourceURL`: allows for specification of an alternate url prefix for downloads.
Will be appended with your specified countryCode and `.zip`.
If the field is undefined or an empty string then the code defaults to the official Geonames dumps.

#### Admin Lookup
Pelias has the ability to compute the admin hierarchy (county, region, country, etc)
Expand Down
11 changes: 11 additions & 0 deletions bin/downloadData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const config = require('pelias-config').generate();
const validateISOCode = require('../lib/validateISOCode');

const countryCode = validateISOCode(config.imports.geonames.countryCode);

const filename = countryCode === 'ALL' ? 'allCountries' : countryCode;

const task = require('../lib/tasks/download');
task(filename);
34 changes: 0 additions & 34 deletions bin/download_data.js

This file was deleted.

14 changes: 8 additions & 6 deletions lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const child_process = require('child_process');
const logger = require( 'pelias-logger' ).get( 'geonames' );

// use datapath setting from your config file
const settings = require('pelias-config').generate();
const basepath = settings.imports.geonames.datapath;

module.exports = function (filename) {
const remoteFilePath = `http://download.geonames.org/export/dump/${filename}.zip`;
const localFileName = `${basepath}/${filename}.zip`;
const config = require('pelias-config').generate();
const basepath = config.imports.geonames.datapath;
const sourceURL = config.imports.geonames.sourceURL;

module.exports = function (countryCode) {
const urlPrefix = sourceURL || 'http://download.geonames.org/export/dump';
const remoteFilePath = `${urlPrefix}/${countryCode}.zip`;
const localFileName = `${basepath}/${countryCode}.zip`;

logger.info( 'downloading datafile from:', remoteFilePath );

Expand Down
45 changes: 23 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
{
"name": "pelias-geonames",
"version": "0.0.0-semantic-release",
"version": "0.0.0-development",
"author": "mapzen",
"description": "Open-source geo-coder & reverse geo-coder",
"homepage": "https://github.com/mapzen/pelias-geonames",
"license": "MIT",
"scripts": {
"download_metadata": "mkdirp metadata && node bin/updateMetadata.js",
"download": "node bin/download_data.js",
"download": "node bin/downloadData.js",
"countryCodes": "node bin/viewCountryCodes.js",
"functional": "NODE_ENV=test node test/functional.js | tap-dot",
"import": "npm run start",
"lint": "jshint .",
"postinstall": "npm run download_metadata",
"start": "node --max_old_space_size=4096 import.js",
"test": "NODE_ENV=test npm run units",
"travis": "npm run check-dependencies && npm test && npm run functional",
"travis": "npm test && npm run functional",
"units": "node test/units.js | tap-dot",
"validate": "npm ls",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"check-dependencies": "node_modules/.bin/npm-check --production"
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"repository": {
"type": "git",
Expand All @@ -36,43 +35,45 @@
"url": "https://github.com/mapzen/pelias-geonames/issues"
},
"engines": {
"node": ">=4.0.0",
"node": ">=6.0.0",
"npm": ">=1.4.3",
"elasticsearch": ">=1.1.1"
},
"dependencies": {
"JSONStream": "^1.0.7",
"cli-table": "^0.3.0",
"csv-parse": "^1.3.3",
"csv-parse": "^2.0.2",
"geonames-stream": "^2.0.3",
"lodash": "^4.2.1",
"pelias-config": "2.14.0",
"pelias-config": "^3.0.2",
"mkdirp": "^0.5.1",
"pelias-dbclient": "2.4.0",
"pelias-logger": "0.3.1",
"pelias-model": "5.3.2",
"pelias-wof-admin-lookup": "4.5.4",
"pelias-dbclient": "^2.5.6",
"pelias-logger": "^0.4.2",
"pelias-model": "^5.5.2",
"pelias-wof-admin-lookup": "^4.6.5",
"request": "^2.34.0",
"through2": "^2.0.1",
"through2-filter": "^2.0.0",
"through2-filter": "^3.0.0",
"through2-sink": "^1.0.0",
"unzipper": "^0.8.3"
},
"devDependencies": {
"deep-diff": "^0.3.3",
"deep-diff": "^1.0.0",
"event-stream": "^3.3.2",
"npm-check": "git://github.com/orangejulius/npm-check.git#disable-update-check",
"pelias-mock-logger": "^1.1.0",
"precommit-hook": "3.0.0",
"proxyquire": "^1.7.11",
"semantic-release": "^8.0.0",
"tap-dot": "^1.0.1",
"precommit-hook": "^3.0.0",
"proxyquire": "^2.0.0",
"semantic-release": "^15.0.0",
"tap-dot": "^2.0.0",
"tape": "^4.4.0"
},
"pre-commit": [
"lint",
"validate",
"test",
"check-dependencies"
]
"test"
],
"release": {
"branch": "production",
"success": []
}
}

0 comments on commit bafed2f

Please sign in to comment.