Skip to content

Commit a5e2df6

Browse files
committed
use API instead of cli for overpass
it's not possible to catch errors with cli because they don't pass to stderr
1 parent 3dc1743 commit a5e2df6

5 files changed

Lines changed: 69 additions & 9 deletions

File tree

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- 6
3+
- 7
44
branches:
55
only:
66
- dev
@@ -15,9 +15,9 @@ env:
1515
- DEPLOY_BRANCH="dev"
1616
script:
1717
- yarn run update
18-
- curl -s -o src/data/speelterreinen.geojson https://datatank.stad.gent/4/cultuursportvrijetijd/speelterreinen.geojson
19-
- curl -s -o src/data/clubhuizenvoorsenioren.geojson https://datatank.stad.gent/4/doelgroepen/clubhuizenvoorsenioren.geojson
20-
- curl -s -o src/data/hondenvoorzieningen.geojson https://datatank.stad.gent/4/infrastructuur/hondenvoorzieningen.geojson
18+
- curl --fail --silent --show-error -o src/data/speelterreinen.geojson https://datatank.stad.gent/4/cultuursportvrijetijd/speelterreinen.geojson
19+
- curl --fail --silent --show-error -o src/data/clubhuizenvoorsenioren.geojson https://datatank.stad.gent/4/doelgroepen/clubhuizenvoorsenioren.geojson
20+
- curl --fail --silent --show-error -o src/data/hondenvoorzieningen.geojson https://datatank.stad.gent/4/infrastructuur/hondenvoorzieningen.geojson
2121
after_success:
2222
- yarn run gh-pages-travis
2323
before_install:

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2016
3+
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21+
OR OTHER DEALINGS IN THE SOFTWARE.
22+

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
},
99
"scripts": {
1010
"gipod": "gipod --type workassignment --query city=gent > src/data/werken.geojson",
11-
"studenten": "query-overpass assets/overpass/studenten.ql > src/data/studenten.geojson",
12-
"toerisme": "query-overpass assets/overpass/toerisme.ql > src/data/toerisme.geojson",
13-
"cafes": "query-overpass assets/overpass/cafes.ql > src/data/cafes.geojson",
14-
"update": "npm run gipod & npm run studenten & npm run toerisme & npm run cafes",
11+
"overpass": "node src/overpass",
12+
"update": "npm run gipod & npm run overpass",
1513
"serve": "jekyll s --ssl-cert assets/ca.crt --ssl-key assets/ca.key"
1614
},
1715
"bugs": {
@@ -23,6 +21,8 @@
2321
"query-overpass": "^1.1.0"
2422
},
2523
"devDependencies": {
24+
"fs.promised": "^3.0.0",
2625
"gh-pages-travis": "^1.0.0"
27-
}
26+
},
27+
"license": "MIT"
2828
}

src/overpass.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const path = require('path')
2+
const fs = require('fs.promised');
3+
const overpass = require('query-overpass');
4+
5+
const data = {
6+
studenten: {
7+
file: () => path.join(__dirname, '../assets/overpass/studenten.ql'),
8+
output: () => path.join(__dirname, './data/studenten.geojson'),
9+
},
10+
toerisme: {
11+
file: () => path.join(__dirname, '../assets/overpass/toerisme.ql'),
12+
output: () => path.join(__dirname, './data/toerisme.geojson'),
13+
},
14+
cafes: {
15+
file: () => path.join(__dirname, '../assets/overpass/cafes.ql'),
16+
output: () => path.join(__dirname, './data/cafes.geojson'),
17+
},
18+
};
19+
20+
Object.keys(data).forEach((point) => {
21+
fs.readFile(data[point].file()).then((query) => {
22+
try {
23+
overpass(query, (err, res) => {
24+
if (!err) {
25+
fs.writeFile(data[point].output(), JSON.stringify(res));
26+
} else {
27+
console.log(err);
28+
}
29+
});
30+
} catch(err) {
31+
console.log(err);
32+
};
33+
});
34+
});

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ form-data@~2.1.1:
194194
combined-stream "^1.0.5"
195195
mime-types "^2.1.12"
196196

197+
fs.promised@^3.0.0:
198+
version "3.0.0"
199+
resolved "https://registry.yarnpkg.com/fs.promised/-/fs.promised-3.0.0.tgz#ab77379f7c1ad0939e1262a8c2ced93fa6c39d3b"
200+
197201
generate-function@^2.0.0:
198202
version "2.0.0"
199203
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74"

0 commit comments

Comments
 (0)