@hebcal/geo-sqlite 5.5.1 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/build-geonames-sqlite +33 -14
- package/bin/download-and-make-dbs +10 -3
- package/dist/index.js +36 -339
- package/package.json +13 -7
|
@@ -2,32 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
import {buildGeonamesSqlite} from '@hebcal/geo-sqlite';
|
|
4
4
|
import {pino} from 'pino';
|
|
5
|
+
import minimist from 'minimist';
|
|
6
|
+
|
|
7
|
+
const argv = minimist(process.argv.slice(2), {
|
|
8
|
+
boolean: ['help', 'quiet'],
|
|
9
|
+
string: ['population'],
|
|
10
|
+
alias: {h: 'help', q: 'quiet'},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (argv.help) {
|
|
14
|
+
usage();
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
5
17
|
|
|
6
18
|
const logger = pino({
|
|
7
|
-
|
|
19
|
+
level: argv.quiet ? 'warn' : 'info',
|
|
8
20
|
transport: {
|
|
9
21
|
target: 'pino-pretty',
|
|
10
22
|
options: {translateTime: 'SYS:standard', ignore: 'pid,hostname'},
|
|
11
23
|
},
|
|
12
24
|
});
|
|
13
25
|
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
console.error(`Usage: build-geonames-sqlite geonames.sqlite3 ${infiles}`);
|
|
26
|
+
const args = argv._;
|
|
27
|
+
if (args.length !== 7) {
|
|
28
|
+
usage();
|
|
18
29
|
process.exit(1);
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
const
|
|
22
|
-
dbFilename:
|
|
23
|
-
countryInfotxt:
|
|
24
|
-
cities5000txt:
|
|
25
|
-
citiesPatch:
|
|
26
|
-
admin1CodesASCIItxt:
|
|
27
|
-
ILtxt:
|
|
28
|
-
ILalternate:
|
|
32
|
+
const options = {
|
|
33
|
+
dbFilename: args[0],
|
|
34
|
+
countryInfotxt: args[1],
|
|
35
|
+
cities5000txt: args[2],
|
|
36
|
+
citiesPatch: args[3],
|
|
37
|
+
admin1CodesASCIItxt: args[4],
|
|
38
|
+
ILtxt: args[5],
|
|
39
|
+
ILalternate: args[6],
|
|
29
40
|
logger: logger,
|
|
30
41
|
};
|
|
31
|
-
|
|
42
|
+
if (argv.population) {
|
|
43
|
+
options.population = +argv.population;
|
|
44
|
+
}
|
|
45
|
+
buildGeonamesSqlite(options).then(() => {
|
|
32
46
|
console.log('Done!');
|
|
33
47
|
});
|
|
48
|
+
|
|
49
|
+
function usage() {
|
|
50
|
+
const infiles = 'countryInfo.txt cities5000.txt cities-patch.txt admin1CodesASCII.txt IL.txt IL-alternatenames.txt';
|
|
51
|
+
console.log(`Usage: build-geonames-sqlite geonames.sqlite3 ${infiles}`);
|
|
52
|
+
}
|
|
@@ -5,14 +5,20 @@ set -x
|
|
|
5
5
|
TMPDIR=`mktemp -d /tmp/geonames.XXXXXX`
|
|
6
6
|
CURDIR=`pwd`
|
|
7
7
|
|
|
8
|
+
# optionally specify minimum city population size with POPULATION=750
|
|
9
|
+
POPULATION=${POPULATION:-"0"}
|
|
10
|
+
|
|
11
|
+
# optionally specify a geonames export file such as cities500 or cities5000
|
|
12
|
+
CITIES=${CITIES:-"cities1000"}
|
|
13
|
+
|
|
8
14
|
curl -o $TMPDIR/countryInfo.txt http://download.geonames.org/export/dump/countryInfo.txt
|
|
9
15
|
curl -o $TMPDIR/admin1CodesASCII.txt http://download.geonames.org/export/dump/admin1CodesASCII.txt
|
|
10
|
-
curl -o $TMPDIR
|
|
16
|
+
curl -o $TMPDIR/$CITIES.zip http://download.geonames.org/export/dump/$CITIES.zip
|
|
11
17
|
curl -o $TMPDIR/IL.zip http://download.geonames.org/export/dump/IL.zip
|
|
12
18
|
curl -o $TMPDIR/alt-IL.zip http://download.geonames.org/export/dump/alternatenames/IL.zip
|
|
13
19
|
|
|
14
20
|
cd $TMPDIR
|
|
15
|
-
unzip
|
|
21
|
+
unzip $CITIES.zip
|
|
16
22
|
unzip alt-IL.zip
|
|
17
23
|
mv IL.txt alt-IL.txt
|
|
18
24
|
rm readme.txt
|
|
@@ -22,9 +28,10 @@ cd $CURDIR
|
|
|
22
28
|
|
|
23
29
|
#npx --package '@hebcal/geo-sqlite' build-geonames-sqlite \
|
|
24
30
|
$CURDIR/node_modules/.bin/build-geonames-sqlite \
|
|
31
|
+
--population=$POPULATION \
|
|
25
32
|
$CURDIR/geonames.sqlite3 \
|
|
26
33
|
$TMPDIR/countryInfo.txt \
|
|
27
|
-
$TMPDIR
|
|
34
|
+
"$TMPDIR/$CITIES.txt" \
|
|
28
35
|
"$CURDIR/node_modules/@hebcal/geo-sqlite/cities-patch.txt" \
|
|
29
36
|
$TMPDIR/admin1CodesASCII.txt \
|
|
30
37
|
$TMPDIR/IL.txt \
|