@hebcal/geo-sqlite 4.0.0 → 4.2.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.
@@ -9,9 +9,13 @@ curl -o $TMPDIR/countryInfo.txt http://download.geonames.org/export/dump/country
9
9
  curl -o $TMPDIR/admin1CodesASCII.txt http://download.geonames.org/export/dump/admin1CodesASCII.txt
10
10
  curl -o $TMPDIR/cities5000.zip http://download.geonames.org/export/dump/cities5000.zip
11
11
  curl -o $TMPDIR/IL.zip http://download.geonames.org/export/dump/IL.zip
12
+ curl -o $TMPDIR/alt-IL.zip http://download.geonames.org/export/dump/alternatenames/IL.zip
12
13
 
13
14
  cd $TMPDIR
14
15
  unzip cities5000.zip
16
+ unzip alt-IL.zip
17
+ mv IL.txt alt-IL.txt
18
+ rm readme.txt
15
19
  unzip IL.zip
16
20
 
17
21
  cd $CURDIR
@@ -23,7 +27,8 @@ $CURDIR/node_modules/.bin/build-geonames-sqlite \
23
27
  $TMPDIR/cities5000.txt \
24
28
  "$CURDIR/node_modules/@hebcal/geo-sqlite/cities-patch.txt" \
25
29
  $TMPDIR/admin1CodesASCII.txt \
26
- $TMPDIR/IL.txt
30
+ $TMPDIR/IL.txt \
31
+ $TMPDIR/alt-IL.txt
27
32
 
28
33
  rm -rf $TMPDIR
29
34
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/geo-sqlite v4.0.0 */
1
+ /*! @hebcal/geo-sqlite v4.2.0 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -222,6 +222,7 @@ class GeoDb {
222
222
  const cityDescr = `${result.CityMixedCase}, ${result.State} ${zip}`;
223
223
  const location = new core.Location(result.Latitude, result.Longitude, false, tzid, cityDescr, 'US', zip);
224
224
  location.admin1 = location.state = result.State;
225
+ location.stateName = stateNames[location.state];
225
226
  location.geo = 'zip';
226
227
  location.zip = zip;
227
228
  return location;
@@ -511,9 +512,16 @@ async function buildGeonamesSqlite(opts) {
511
512
  gtopo30 int,
512
513
  timezone nvarchar(40),
513
514
  moddate date);`);
514
- await doFile(logger, db, cities5000txt, 'geoname', 19);
515
- await doFile(logger, db, citiesPatch, 'geoname', 19);
515
+
516
+ const truncateAlternateNames = a => {
517
+ a[3] = '';
518
+ return true;
519
+ };
520
+
521
+ await doFile(logger, db, cities5000txt, 'geoname', 19, truncateAlternateNames);
522
+ await doFile(logger, db, citiesPatch, 'geoname', 19, truncateAlternateNames);
516
523
  await doFile(logger, db, ILtxt, 'geoname', 19, a => {
524
+ a[3] = '';
517
525
  return a[6] == 'P' && (a[7] == 'PPL' || a[7] == 'STLMT');
518
526
  });
519
527
  doSql(logger, db, `DROP TABLE IF EXISTS admin1`, `CREATE TABLE admin1 (
@@ -542,6 +550,12 @@ async function buildGeonamesSqlite(opts) {
542
550
  periodTo NULL
543
551
  );`);
544
552
  await doFile(logger, db, ILalternate, 'alternatenames', 10, a => {
553
+ const firstchar = a[3][0];
554
+
555
+ if (a[2] === 'he' && (firstchar < '\u05D0' || firstchar > '\u05EA')) {
556
+ a[2] = 'en';
557
+ }
558
+
545
559
  if (a[2] === 'he' || a[2] === 'en') {
546
560
  if (a[2] === 'he') {
547
561
  a[3] = a[3].replace(/‘/g, '׳');
@@ -597,11 +611,20 @@ async function buildGeonamesSqlite(opts) {
597
611
  SELECT g.geonameid, alt.name||', ישראל',
598
612
  alt.name, '', 'ישראל',
599
613
  g.population, g.latitude, g.longitude, g.timezone
600
- FROM geoname g, country c, altnames alt
614
+ FROM geoname g, altnames alt
601
615
  WHERE g.country = 'IL'
602
616
  AND alt.isolanguage = 'he'
603
617
  AND g.geonameid = alt.geonameid
604
- `);
618
+ `, `INSERT INTO geoname_fulltext
619
+ SELECT g.geonameid, alt.name||', '||a1.asciiname||', Israel',
620
+ alt.name, a1.asciiname, 'Israel',
621
+ g.population, g.latitude, g.longitude, g.timezone
622
+ FROM geoname g, admin1 a1, altnames alt
623
+ WHERE g.country = 'IL'
624
+ AND alt.isolanguage = 'en'
625
+ AND g.geonameid = alt.geonameid
626
+ AND g.country||'.'||g.admin1 = a1.key
627
+ `, 'VACUUM');
605
628
  db.close();
606
629
  return Promise.resolve(true);
607
630
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/geo-sqlite v4.0.0 */
1
+ /*! @hebcal/geo-sqlite v4.2.0 */
2
2
  import Database from 'better-sqlite3';
3
3
  import { Location, Locale } from '@hebcal/core';
4
4
  import '@hebcal/cities';
@@ -210,6 +210,7 @@ class GeoDb {
210
210
  const cityDescr = `${result.CityMixedCase}, ${result.State} ${zip}`;
211
211
  const location = new Location(result.Latitude, result.Longitude, false, tzid, cityDescr, 'US', zip);
212
212
  location.admin1 = location.state = result.State;
213
+ location.stateName = stateNames[location.state];
213
214
  location.geo = 'zip';
214
215
  location.zip = zip;
215
216
  return location;
@@ -499,9 +500,16 @@ async function buildGeonamesSqlite(opts) {
499
500
  gtopo30 int,
500
501
  timezone nvarchar(40),
501
502
  moddate date);`);
502
- await doFile(logger, db, cities5000txt, 'geoname', 19);
503
- await doFile(logger, db, citiesPatch, 'geoname', 19);
503
+
504
+ const truncateAlternateNames = a => {
505
+ a[3] = '';
506
+ return true;
507
+ };
508
+
509
+ await doFile(logger, db, cities5000txt, 'geoname', 19, truncateAlternateNames);
510
+ await doFile(logger, db, citiesPatch, 'geoname', 19, truncateAlternateNames);
504
511
  await doFile(logger, db, ILtxt, 'geoname', 19, a => {
512
+ a[3] = '';
505
513
  return a[6] == 'P' && (a[7] == 'PPL' || a[7] == 'STLMT');
506
514
  });
507
515
  doSql(logger, db, `DROP TABLE IF EXISTS admin1`, `CREATE TABLE admin1 (
@@ -530,6 +538,12 @@ async function buildGeonamesSqlite(opts) {
530
538
  periodTo NULL
531
539
  );`);
532
540
  await doFile(logger, db, ILalternate, 'alternatenames', 10, a => {
541
+ const firstchar = a[3][0];
542
+
543
+ if (a[2] === 'he' && (firstchar < '\u05D0' || firstchar > '\u05EA')) {
544
+ a[2] = 'en';
545
+ }
546
+
533
547
  if (a[2] === 'he' || a[2] === 'en') {
534
548
  if (a[2] === 'he') {
535
549
  a[3] = a[3].replace(/‘/g, '׳');
@@ -585,11 +599,20 @@ async function buildGeonamesSqlite(opts) {
585
599
  SELECT g.geonameid, alt.name||', ישראל',
586
600
  alt.name, '', 'ישראל',
587
601
  g.population, g.latitude, g.longitude, g.timezone
588
- FROM geoname g, country c, altnames alt
602
+ FROM geoname g, altnames alt
589
603
  WHERE g.country = 'IL'
590
604
  AND alt.isolanguage = 'he'
591
605
  AND g.geonameid = alt.geonameid
592
- `);
606
+ `, `INSERT INTO geoname_fulltext
607
+ SELECT g.geonameid, alt.name||', '||a1.asciiname||', Israel',
608
+ alt.name, a1.asciiname, 'Israel',
609
+ g.population, g.latitude, g.longitude, g.timezone
610
+ FROM geoname g, admin1 a1, altnames alt
611
+ WHERE g.country = 'IL'
612
+ AND alt.isolanguage = 'en'
613
+ AND g.geonameid = alt.geonameid
614
+ AND g.country||'.'||g.admin1 = a1.key
615
+ `, 'VACUUM');
593
616
  db.close();
594
617
  return Promise.resolve(true);
595
618
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/geo-sqlite",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "hebcal"
@@ -28,7 +28,7 @@
28
28
  "geo-sqlite.d.ts"
29
29
  ],
30
30
  "dependencies": {
31
- "@hebcal/cities": "^3.1.1",
31
+ "@hebcal/cities": "^3.1.2",
32
32
  "@hebcal/core": "^3.33.3",
33
33
  "better-sqlite3": "^7.5.0",
34
34
  "pino": "^7.8.0",
@@ -65,6 +65,6 @@
65
65
  "eslint-config-google": "^0.14.0",
66
66
  "jsdoc": "^3.6.10",
67
67
  "jsdoc-to-markdown": "^7.1.1",
68
- "rollup": "^2.69.0"
68
+ "rollup": "^2.69.1"
69
69
  }
70
70
  }