Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #29 from DenisCarriere/master
Browse files Browse the repository at this point in the history
Add extra arguments
  • Loading branch information
Andygol authored Dec 5, 2016
2 parents 9a5b1e3 + 4ee1185 commit 8f4c0df
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
"extends": "mourner",
"rules": {
"strict": [0],
"camelcase": [0],
"consistent-return": [0],
"valid-jsdoc": [2, { "requireReturn": false }]
}
};
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
.idea/*

.DS_Store

pids
logs
results

npm-debug.log*

node_modules
yarn.lock
*.mbtiles
*.geojson
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ var count = cleanArguments.argv.count,
mbtilesPath = cleanArguments.argv.mbtiles,
tmpGeojson = cleanArguments.tmpGeojson,
tagFilter = cleanArguments.argv.filter,
bbox = cleanArguments.argv.bbox,
maxWorkers = cleanArguments.argv.maxWorkers,
tiles = cleanArguments.argv.tiles,
osmID = new Set(),
tmpFd;

Expand All @@ -32,6 +35,9 @@ tileReduce({
zoom: 12,
map: path.join(__dirname, 'map.js'),
sources: [{name: 'osm', mbtiles: mbtilesPath}],
maxWorkers: maxWorkers,
bbox: bbox,
tiles: tiles,
mapOptions: {
'count': count,
'tmpGeojson': tmpGeojson,
Expand All @@ -47,7 +53,7 @@ tileReduce({
})
.on('reduce', function (id) {
if (count && id) {
id.forEach(function(idElement) {
id.forEach(function (idElement) {
osmID.add(idElement);
});
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
"geojson-stream-merge": "^2.0.0",
"mapbox-data-team": "^1.0.0",
"minimist": "^1.2.0",
"path": "^0.12.7",
"tile-reduce": "^3.1.1",
"turf-featurecollection": "^1.0.1",
"underscore": "^1.8.3"
},
"bin": {
"osm-tag-stats": "index.js"
},
"devDependencies": {},
"devDependencies": {
"eslint-config-mourner": "^2.0.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mapbox/osm-tag-stats.git"
Expand Down
16 changes: 16 additions & 0 deletions util/cleanArguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ function cleanArguments(argv, tmpFilesDir) {
argv.mbtiles = false;
}
}

//bbox
if (argv.bbox) {
argv.bbox = JSON.parse(argv.bbox);
if (argv.bbox.length !== 4) {
throw new Error('BBox is invalid --bbox=[west, south, east, north]');
}
}

//tiles
if (argv.tiles) {
argv.tiles = JSON.parse(argv.tiles);
if (typeof(argv.tiles) !== 'object') {
throw new Error('Tiles is invalid --tiles=[[x, y, z]]');
}
}
return {'argv': argv, 'tmpGeojson': tmpGeojson};
}

Expand Down

0 comments on commit 8f4c0df

Please sign in to comment.