@hebcal/geo-sqlite 4.4.3 → 4.5.2
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 +14 -12
- package/dist/index.mjs +14 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/geo-sqlite v4.
|
|
1
|
+
/*! @hebcal/geo-sqlite v4.5.2 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -60,13 +60,15 @@ FROM ZIPCodes_Primary
|
|
|
60
60
|
WHERE ZipCode LIKE ?
|
|
61
61
|
ORDER BY Population DESC
|
|
62
62
|
LIMIT 10`;
|
|
63
|
-
const ZIP_FULLTEXT_COMPLETE_SQL = `SELECT ZipCode
|
|
63
|
+
const ZIP_FULLTEXT_COMPLETE_SQL = `SELECT ZipCode
|
|
64
64
|
FROM ZIPCodes_CityFullText5
|
|
65
65
|
WHERE ZIPCodes_CityFullText5 MATCH ?
|
|
66
|
+
ORDER BY Population DESC
|
|
66
67
|
LIMIT 20`;
|
|
67
|
-
const GEONAME_COMPLETE_SQL = `SELECT geonameid
|
|
68
|
+
const GEONAME_COMPLETE_SQL = `SELECT geonameid
|
|
68
69
|
FROM geoname_fulltext
|
|
69
70
|
WHERE geoname_fulltext MATCH ?
|
|
71
|
+
ORDER BY population DESC
|
|
70
72
|
LIMIT 20`;
|
|
71
73
|
const stateNames = {
|
|
72
74
|
'AK': 'Alaska',
|
|
@@ -316,6 +318,7 @@ class GeoDb {
|
|
|
316
318
|
admin1: res.State,
|
|
317
319
|
asciiname: res.CityMixedCase,
|
|
318
320
|
country: 'United States',
|
|
321
|
+
cc: 'US',
|
|
319
322
|
latitude: res.Latitude,
|
|
320
323
|
longitude: res.Longitude,
|
|
321
324
|
timezone: core.Location.getUsaTzid(res.State, res.TimeZone, res.DayLightSaving),
|
|
@@ -369,19 +372,19 @@ class GeoDb {
|
|
|
369
372
|
|
|
370
373
|
const geoMatches = geoRows.map(res => {
|
|
371
374
|
const loc = this.lookupGeoname(res.geonameid);
|
|
372
|
-
const
|
|
375
|
+
const cc = loc.getCountryCode();
|
|
376
|
+
const country = this.countryNames.get(cc) || '';
|
|
373
377
|
const admin1 = loc.admin1 || '';
|
|
374
|
-
const rankPop = Math.sqrt(loc.population) / 40;
|
|
375
378
|
const obj = {
|
|
376
379
|
id: res.geonameid,
|
|
377
380
|
value: loc.name,
|
|
378
381
|
admin1,
|
|
379
382
|
country,
|
|
383
|
+
cc,
|
|
380
384
|
latitude: loc.latitude,
|
|
381
385
|
longitude: loc.longitude,
|
|
382
386
|
timezone: loc.getTzid(),
|
|
383
|
-
geo: 'geoname'
|
|
384
|
-
rank: rankPop + -30 * res.rank
|
|
387
|
+
geo: 'geoname'
|
|
385
388
|
};
|
|
386
389
|
|
|
387
390
|
if (loc.population) {
|
|
@@ -411,19 +414,18 @@ class GeoDb {
|
|
|
411
414
|
const zipMatches = zipRows.map(res => {
|
|
412
415
|
const zipCode = res.ZipCode;
|
|
413
416
|
const loc = this.lookupZip(zipCode);
|
|
414
|
-
const rankPop = Math.sqrt(loc.population) / 40;
|
|
415
417
|
const obj = {
|
|
416
418
|
id: zipCode,
|
|
417
419
|
value: loc.getName(),
|
|
418
420
|
admin1: loc.admin1,
|
|
419
421
|
asciiname: loc.getShortName(),
|
|
420
422
|
country: 'United States',
|
|
423
|
+
cc: 'US',
|
|
421
424
|
latitude: loc.latitude,
|
|
422
425
|
longitude: loc.longitude,
|
|
423
426
|
timezone: loc.getTzid(),
|
|
424
427
|
population: loc.population,
|
|
425
|
-
geo: 'zip'
|
|
426
|
-
rank: rankPop + -30 * res.rank
|
|
428
|
+
geo: 'zip'
|
|
427
429
|
};
|
|
428
430
|
return obj;
|
|
429
431
|
});
|
|
@@ -444,8 +446,8 @@ class GeoDb {
|
|
|
444
446
|
}
|
|
445
447
|
|
|
446
448
|
const values = Array.from(map.values());
|
|
447
|
-
values.sort((a, b) => b.
|
|
448
|
-
const topN = values.slice(0,
|
|
449
|
+
values.sort((a, b) => b.population - a.population);
|
|
450
|
+
const topN = values.slice(0, 15);
|
|
449
451
|
|
|
450
452
|
if (!latlong) {
|
|
451
453
|
for (const val of topN) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/geo-sqlite v4.
|
|
1
|
+
/*! @hebcal/geo-sqlite v4.5.2 */
|
|
2
2
|
import Database from 'better-sqlite3';
|
|
3
3
|
import { Location, Locale } from '@hebcal/core';
|
|
4
4
|
import '@hebcal/cities';
|
|
@@ -48,13 +48,15 @@ FROM ZIPCodes_Primary
|
|
|
48
48
|
WHERE ZipCode LIKE ?
|
|
49
49
|
ORDER BY Population DESC
|
|
50
50
|
LIMIT 10`;
|
|
51
|
-
const ZIP_FULLTEXT_COMPLETE_SQL = `SELECT ZipCode
|
|
51
|
+
const ZIP_FULLTEXT_COMPLETE_SQL = `SELECT ZipCode
|
|
52
52
|
FROM ZIPCodes_CityFullText5
|
|
53
53
|
WHERE ZIPCodes_CityFullText5 MATCH ?
|
|
54
|
+
ORDER BY Population DESC
|
|
54
55
|
LIMIT 20`;
|
|
55
|
-
const GEONAME_COMPLETE_SQL = `SELECT geonameid
|
|
56
|
+
const GEONAME_COMPLETE_SQL = `SELECT geonameid
|
|
56
57
|
FROM geoname_fulltext
|
|
57
58
|
WHERE geoname_fulltext MATCH ?
|
|
59
|
+
ORDER BY population DESC
|
|
58
60
|
LIMIT 20`;
|
|
59
61
|
const stateNames = {
|
|
60
62
|
'AK': 'Alaska',
|
|
@@ -304,6 +306,7 @@ class GeoDb {
|
|
|
304
306
|
admin1: res.State,
|
|
305
307
|
asciiname: res.CityMixedCase,
|
|
306
308
|
country: 'United States',
|
|
309
|
+
cc: 'US',
|
|
307
310
|
latitude: res.Latitude,
|
|
308
311
|
longitude: res.Longitude,
|
|
309
312
|
timezone: Location.getUsaTzid(res.State, res.TimeZone, res.DayLightSaving),
|
|
@@ -357,19 +360,19 @@ class GeoDb {
|
|
|
357
360
|
|
|
358
361
|
const geoMatches = geoRows.map(res => {
|
|
359
362
|
const loc = this.lookupGeoname(res.geonameid);
|
|
360
|
-
const
|
|
363
|
+
const cc = loc.getCountryCode();
|
|
364
|
+
const country = this.countryNames.get(cc) || '';
|
|
361
365
|
const admin1 = loc.admin1 || '';
|
|
362
|
-
const rankPop = Math.sqrt(loc.population) / 40;
|
|
363
366
|
const obj = {
|
|
364
367
|
id: res.geonameid,
|
|
365
368
|
value: loc.name,
|
|
366
369
|
admin1,
|
|
367
370
|
country,
|
|
371
|
+
cc,
|
|
368
372
|
latitude: loc.latitude,
|
|
369
373
|
longitude: loc.longitude,
|
|
370
374
|
timezone: loc.getTzid(),
|
|
371
|
-
geo: 'geoname'
|
|
372
|
-
rank: rankPop + -30 * res.rank
|
|
375
|
+
geo: 'geoname'
|
|
373
376
|
};
|
|
374
377
|
|
|
375
378
|
if (loc.population) {
|
|
@@ -399,19 +402,18 @@ class GeoDb {
|
|
|
399
402
|
const zipMatches = zipRows.map(res => {
|
|
400
403
|
const zipCode = res.ZipCode;
|
|
401
404
|
const loc = this.lookupZip(zipCode);
|
|
402
|
-
const rankPop = Math.sqrt(loc.population) / 40;
|
|
403
405
|
const obj = {
|
|
404
406
|
id: zipCode,
|
|
405
407
|
value: loc.getName(),
|
|
406
408
|
admin1: loc.admin1,
|
|
407
409
|
asciiname: loc.getShortName(),
|
|
408
410
|
country: 'United States',
|
|
411
|
+
cc: 'US',
|
|
409
412
|
latitude: loc.latitude,
|
|
410
413
|
longitude: loc.longitude,
|
|
411
414
|
timezone: loc.getTzid(),
|
|
412
415
|
population: loc.population,
|
|
413
|
-
geo: 'zip'
|
|
414
|
-
rank: rankPop + -30 * res.rank
|
|
416
|
+
geo: 'zip'
|
|
415
417
|
};
|
|
416
418
|
return obj;
|
|
417
419
|
});
|
|
@@ -432,8 +434,8 @@ class GeoDb {
|
|
|
432
434
|
}
|
|
433
435
|
|
|
434
436
|
const values = Array.from(map.values());
|
|
435
|
-
values.sort((a, b) => b.
|
|
436
|
-
const topN = values.slice(0,
|
|
437
|
+
values.sort((a, b) => b.population - a.population);
|
|
438
|
+
const topN = values.slice(0, 15);
|
|
437
439
|
|
|
438
440
|
if (!latlong) {
|
|
439
441
|
for (const val of topN) {
|