@hebcal/geo-sqlite 4.4.0 → 4.4.1

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/geo-sqlite v4.4.0 */
1
+ /*! @hebcal/geo-sqlite v4.4.1 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -356,7 +356,7 @@ class GeoDb {
356
356
  }
357
357
 
358
358
  qraw = qraw.replace(/\"/g, '""');
359
- const geoRows = this.geonamesCompStmt.all(`{asciiname country admin1} : "${qraw}" *`);
359
+ const geoRows = this.geonamesCompStmt.all(`{longname} : "${qraw}" *`);
360
360
  const geoMatches = geoRows.map(res => {
361
361
  const country = res.country || '';
362
362
  const admin1 = res.admin1 || '';
@@ -602,19 +602,31 @@ async function buildGeonamesSqlite(opts) {
602
602
  doSql(logger, db, `update admin1 set name='',asciiname='' where key like 'PS.%';`, `update country set country = '' where iso = 'PS';`, `delete from geoname where geonameid = 7303419;`);
603
603
  doSql(logger, db, `DROP TABLE IF EXISTS geoname_fulltext`, `CREATE VIRTUAL TABLE geoname_fulltext
604
604
  USING fts5(geonameid,
605
+ longname,
605
606
  asciiname, admin1, country,
606
607
  population, latitude, longitude, timezone
607
608
  );
608
609
  `, `DROP TABLE IF EXISTS geoname_non_ascii`, `CREATE TABLE geoname_non_ascii AS
609
610
  SELECT geonameid FROM geoname WHERE asciiname <> name`, `INSERT INTO geoname_fulltext
610
611
  SELECT g.geonameid,
612
+ g.asciiname||', '||a.asciiname||', '||c.Country,
611
613
  g.asciiname, a.asciiname, c.Country,
612
614
  g.population, g.latitude, g.longitude, g.timezone
613
615
  FROM geoname g, admin1 a, country c
614
616
  WHERE g.country = c.ISO
617
+ AND g.country <> 'US'
615
618
  AND g.country||'.'||g.admin1 = a.key
616
619
  `, `INSERT INTO geoname_fulltext
617
620
  SELECT g.geonameid,
621
+ g.asciiname||', '||a.asciiname||', USA',
622
+ g.asciiname, a.asciiname, 'United States',
623
+ g.population, g.latitude, g.longitude, g.timezone
624
+ FROM geoname g, admin1 a
625
+ WHERE g.country = 'US'
626
+ AND g.country||'.'||g.admin1 = a.key
627
+ `, `INSERT INTO geoname_fulltext
628
+ SELECT g.geonameid,
629
+ g.asciiname||', '||c.Country,
618
630
  g.asciiname, '', c.Country,
619
631
  g.population, g.latitude, g.longitude, g.timezone
620
632
  FROM geoname g, country c
@@ -622,6 +634,7 @@ async function buildGeonamesSqlite(opts) {
622
634
  AND (g.admin1 = '' OR g.admin1 = '00')
623
635
  `, `INSERT INTO geoname_fulltext
624
636
  SELECT g.geonameid,
637
+ g.name||', '||a.name||', '||c.Country,
625
638
  g.name, a.name, c.Country,
626
639
  g.population, g.latitude, g.longitude, g.timezone
627
640
  FROM geoname_non_ascii gna, geoname g, admin1 a, country c
@@ -630,6 +643,7 @@ async function buildGeonamesSqlite(opts) {
630
643
  AND g.country||'.'||g.admin1 = a.key
631
644
  `, `INSERT INTO geoname_fulltext
632
645
  SELECT g.geonameid,
646
+ alt.name||', ישראל',
633
647
  alt.name, '', 'ישראל',
634
648
  g.population, g.latitude, g.longitude, g.timezone
635
649
  FROM geoname g, altnames alt
@@ -638,6 +652,7 @@ async function buildGeonamesSqlite(opts) {
638
652
  AND g.geonameid = alt.geonameid
639
653
  `, `INSERT INTO geoname_fulltext
640
654
  SELECT g.geonameid,
655
+ alt.name||', '||a1.asciiname||', Israel',
641
656
  alt.name, a1.asciiname, 'Israel',
642
657
  g.population, g.latitude, g.longitude, g.timezone
643
658
  FROM geoname g, admin1 a1, altnames alt
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/geo-sqlite v4.4.0 */
1
+ /*! @hebcal/geo-sqlite v4.4.1 */
2
2
  import Database from 'better-sqlite3';
3
3
  import { Location, Locale } from '@hebcal/core';
4
4
  import '@hebcal/cities';
@@ -344,7 +344,7 @@ class GeoDb {
344
344
  }
345
345
 
346
346
  qraw = qraw.replace(/\"/g, '""');
347
- const geoRows = this.geonamesCompStmt.all(`{asciiname country admin1} : "${qraw}" *`);
347
+ const geoRows = this.geonamesCompStmt.all(`{longname} : "${qraw}" *`);
348
348
  const geoMatches = geoRows.map(res => {
349
349
  const country = res.country || '';
350
350
  const admin1 = res.admin1 || '';
@@ -590,19 +590,31 @@ async function buildGeonamesSqlite(opts) {
590
590
  doSql(logger, db, `update admin1 set name='',asciiname='' where key like 'PS.%';`, `update country set country = '' where iso = 'PS';`, `delete from geoname where geonameid = 7303419;`);
591
591
  doSql(logger, db, `DROP TABLE IF EXISTS geoname_fulltext`, `CREATE VIRTUAL TABLE geoname_fulltext
592
592
  USING fts5(geonameid,
593
+ longname,
593
594
  asciiname, admin1, country,
594
595
  population, latitude, longitude, timezone
595
596
  );
596
597
  `, `DROP TABLE IF EXISTS geoname_non_ascii`, `CREATE TABLE geoname_non_ascii AS
597
598
  SELECT geonameid FROM geoname WHERE asciiname <> name`, `INSERT INTO geoname_fulltext
598
599
  SELECT g.geonameid,
600
+ g.asciiname||', '||a.asciiname||', '||c.Country,
599
601
  g.asciiname, a.asciiname, c.Country,
600
602
  g.population, g.latitude, g.longitude, g.timezone
601
603
  FROM geoname g, admin1 a, country c
602
604
  WHERE g.country = c.ISO
605
+ AND g.country <> 'US'
603
606
  AND g.country||'.'||g.admin1 = a.key
604
607
  `, `INSERT INTO geoname_fulltext
605
608
  SELECT g.geonameid,
609
+ g.asciiname||', '||a.asciiname||', USA',
610
+ g.asciiname, a.asciiname, 'United States',
611
+ g.population, g.latitude, g.longitude, g.timezone
612
+ FROM geoname g, admin1 a
613
+ WHERE g.country = 'US'
614
+ AND g.country||'.'||g.admin1 = a.key
615
+ `, `INSERT INTO geoname_fulltext
616
+ SELECT g.geonameid,
617
+ g.asciiname||', '||c.Country,
606
618
  g.asciiname, '', c.Country,
607
619
  g.population, g.latitude, g.longitude, g.timezone
608
620
  FROM geoname g, country c
@@ -610,6 +622,7 @@ async function buildGeonamesSqlite(opts) {
610
622
  AND (g.admin1 = '' OR g.admin1 = '00')
611
623
  `, `INSERT INTO geoname_fulltext
612
624
  SELECT g.geonameid,
625
+ g.name||', '||a.name||', '||c.Country,
613
626
  g.name, a.name, c.Country,
614
627
  g.population, g.latitude, g.longitude, g.timezone
615
628
  FROM geoname_non_ascii gna, geoname g, admin1 a, country c
@@ -618,6 +631,7 @@ async function buildGeonamesSqlite(opts) {
618
631
  AND g.country||'.'||g.admin1 = a.key
619
632
  `, `INSERT INTO geoname_fulltext
620
633
  SELECT g.geonameid,
634
+ alt.name||', ישראל',
621
635
  alt.name, '', 'ישראל',
622
636
  g.population, g.latitude, g.longitude, g.timezone
623
637
  FROM geoname g, altnames alt
@@ -626,6 +640,7 @@ async function buildGeonamesSqlite(opts) {
626
640
  AND g.geonameid = alt.geonameid
627
641
  `, `INSERT INTO geoname_fulltext
628
642
  SELECT g.geonameid,
643
+ alt.name||', '||a1.asciiname||', Israel',
629
644
  alt.name, a1.asciiname, 'Israel',
630
645
  g.population, g.latitude, g.longitude, g.timezone
631
646
  FROM geoname g, admin1 a1, altnames alt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/geo-sqlite",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "hebcal"