-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from pelias/wip_merge
wip merge
- Loading branch information
Showing
7 changed files
with
153 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# directory of this file | ||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
|
||
# placetypes to download and extract | ||
PLACETYPES=( 'ocean' 'continent' 'marinearea' 'empire' 'country' 'dependency' 'disputed' 'macroregion' 'region', | ||
'macrocounty' 'county' 'localadmin' 'locality' 'borough' 'macrohood' 'neighbourhood' ) | ||
|
||
# download and extract fields from contents of tar | ||
function extract { | ||
curl -so "/tmp/wof-${1}-latest-bundle.tar.bz2" "https://whosonfirst.mapzen.com/bundles/wof-${1}-latest-bundle.tar.bz2" | ||
tar --wildcards '*.geojson' -jx --to-command 'jq -cMf "${DIR}/jq.filter"' -f "/tmp/wof-${1}-latest-bundle.tar.bz2" | ||
rc=$?; if [[ $rc != 0 ]]; then | ||
>&2 echo "/tmp/wof-${1}-latest-bundle.tar.bz2" | ||
>&2 echo "command exited with status: $rc" | ||
fi | ||
} | ||
|
||
# export variables required by the 'extract' function | ||
export -f extract | ||
export DIR | ||
|
||
# run the import | ||
parallel \ | ||
--no-notice \ | ||
--line-buffer \ | ||
--jobs -1 \ | ||
extract \ | ||
::: "${PLACETYPES[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var tape = require('tape'); | ||
var path = require('path'); | ||
|
||
var tests = [ | ||
'./prototype/tokenize', | ||
'./prototype/query', | ||
'./prototype/wof', | ||
'./functional', | ||
]; | ||
|
||
// test runner | ||
tests.map( function( testpath ){ | ||
|
||
var file = require( testpath ); | ||
|
||
var test = function( name, func ) { | ||
return tape( path.normalize( testpath ) + ': ' + name , func ); | ||
}; | ||
|
||
for( var testCase in file ){ | ||
if( 'function' === typeof file[testCase] ){ | ||
file[testCase]( test ); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters