@hebcal/geo-sqlite 5.3.0 → 5.5.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/README.md CHANGED
@@ -33,20 +33,43 @@ db.close();
33
33
  </dd>
34
34
  </dl>
35
35
 
36
+ ## Functions
37
+
38
+ <dl>
39
+ <dt><a href="#buildGeonamesSqlite">buildGeonamesSqlite(opts)</a></dt>
40
+ <dd><p>Builds <code>geonames.sqlite3</code> from files downloaded from geonames.org</p>
41
+ </dd>
42
+ <dt><a href="#doSql">doSql(logger, db, ...sqls)</a></dt>
43
+ <dd></dd>
44
+ <dt><a href="#doFile">doFile(logger, db, infile, tableName, expectedFields, callback)</a></dt>
45
+ <dd></dd>
46
+ </dl>
36
47
 
37
48
  <a name="GeoDb"></a>
38
49
 
39
50
  ## GeoDb
40
51
  Wrapper around sqlite databases
41
52
 
42
- **Kind**: global class
53
+ **Kind**: global class
43
54
 
44
55
  * [GeoDb](#GeoDb)
45
56
  * [new GeoDb(logger, zipsFilename, geonamesFilename)](#new_GeoDb_new)
46
- * [.close()](#GeoDb+close)
47
- * [.lookupZip(zip)](#GeoDb+lookupZip) <code>Location</code>
48
- * [.lookupGeoname(geonameid)](#GeoDb+lookupGeoname) <code>Location</code>
49
- * [.lookupLegacyCity(cityName)](#GeoDb+lookupLegacyCity) <code>Location</code>
57
+ * _instance_
58
+ * [.zipCache](#GeoDb+zipCache) : <code>Map.&lt;string, Location&gt;</code>
59
+ * [.geonamesCache](#GeoDb+geonamesCache) : <code>Map.&lt;number, Location&gt;</code>
60
+ * [.legacyCities](#GeoDb+legacyCities) : <code>Map.&lt;string, number&gt;</code>
61
+ * [.countryNames](#GeoDb+countryNames) : <code>Map.&lt;string, string&gt;</code>
62
+ * [.close()](#GeoDb+close)
63
+ * [.lookupZip(zip)](#GeoDb+lookupZip) ⇒ <code>Location</code>
64
+ * [.lookupGeoname(geonameid)](#GeoDb+lookupGeoname) ⇒ <code>Location</code>
65
+ * [.lookupLegacyCity(cityName)](#GeoDb+lookupLegacyCity) ⇒ <code>Location</code>
66
+ * [.autoComplete(qraw, latlong)](#GeoDb+autoComplete) ⇒ <code>Array.&lt;Object&gt;</code>
67
+ * [.cacheZips()](#GeoDb+cacheZips)
68
+ * [.cacheGeonames()](#GeoDb+cacheGeonames)
69
+ * _static_
70
+ * [.transliterate(source, [options])](#GeoDb.transliterate) ⇒ <code>string</code>
71
+ * [.geonameCityDescr(cityName, admin1, countryName)](#GeoDb.geonameCityDescr) ⇒ <code>string</code>
72
+ * [.version()](#GeoDb.version)
50
73
 
51
74
  <a name="new_GeoDb_new"></a>
52
75
 
@@ -54,39 +77,147 @@ Wrapper around sqlite databases
54
77
 
55
78
  | Param | Type |
56
79
  | --- | --- |
57
- | logger | <code>any</code> |
58
- | zipsFilename | <code>string</code> |
59
- | geonamesFilename | <code>string</code> |
80
+ | logger | <code>any</code> |
81
+ | zipsFilename | <code>string</code> |
82
+ | geonamesFilename | <code>string</code> |
83
+
84
+ <a name="GeoDb+zipCache"></a>
85
+
86
+ ### geoDb.zipCache : <code>Map.&lt;string, Location&gt;</code>
87
+ **Kind**: instance property of [<code>GeoDb</code>](#GeoDb)
88
+ <a name="GeoDb+geonamesCache"></a>
60
89
 
90
+ ### geoDb.geonamesCache : <code>Map.&lt;number, Location&gt;</code>
91
+ **Kind**: instance property of [<code>GeoDb</code>](#GeoDb)
92
+ <a name="GeoDb+legacyCities"></a>
93
+
94
+ ### geoDb.legacyCities : <code>Map.&lt;string, number&gt;</code>
95
+ **Kind**: instance property of [<code>GeoDb</code>](#GeoDb)
96
+ <a name="GeoDb+countryNames"></a>
97
+
98
+ ### geoDb.countryNames : <code>Map.&lt;string, string&gt;</code>
99
+ **Kind**: instance property of [<code>GeoDb</code>](#GeoDb)
61
100
  <a name="GeoDb+close"></a>
62
101
 
63
102
  ### geoDb.close()
64
103
  Closes database handles
65
104
 
66
- **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
105
+ **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
67
106
  <a name="GeoDb+lookupZip"></a>
68
107
 
69
108
  ### geoDb.lookupZip(zip) ⇒ <code>Location</code>
70
- **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
109
+ **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
71
110
 
72
111
  | Param | Type |
73
112
  | --- | --- |
74
- | zip | <code>string</code> |
113
+ | zip | <code>string</code> |
75
114
 
76
115
  <a name="GeoDb+lookupGeoname"></a>
77
116
 
78
117
  ### geoDb.lookupGeoname(geonameid) ⇒ <code>Location</code>
79
- **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
118
+ **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
80
119
 
81
120
  | Param | Type |
82
121
  | --- | --- |
83
- | geonameid | <code>number</code> |
122
+ | geonameid | <code>number</code> |
84
123
 
85
124
  <a name="GeoDb+lookupLegacyCity"></a>
86
125
 
87
126
  ### geoDb.lookupLegacyCity(cityName) ⇒ <code>Location</code>
88
- **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
127
+ **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
128
+
129
+ | Param | Type |
130
+ | --- | --- |
131
+ | cityName | <code>string</code> |
132
+
133
+ <a name="GeoDb+autoComplete"></a>
134
+
135
+ ### geoDb.autoComplete(qraw, latlong) ⇒ <code>Array.&lt;Object&gt;</code>
136
+ Generates autocomplete results based on a query string
137
+
138
+ **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
139
+
140
+ | Param | Type | Default |
141
+ | --- | --- | --- |
142
+ | qraw | <code>string</code> | |
143
+ | latlong | <code>boolean</code> | <code>false</code> |
144
+
145
+ <a name="GeoDb+cacheZips"></a>
146
+
147
+ ### geoDb.cacheZips()
148
+ Reads entire ZIP database and caches in-memory
149
+
150
+ **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
151
+ <a name="GeoDb+cacheGeonames"></a>
152
+
153
+ ### geoDb.cacheGeonames()
154
+ Reads entire geonames database and caches in-memory
155
+
156
+ **Kind**: instance method of [<code>GeoDb</code>](#GeoDb)
157
+ <a name="GeoDb.transliterate"></a>
158
+
159
+ ### GeoDb.transliterate(source, [options]) ⇒ <code>string</code>
160
+ Convenience wrapper of the `transliterate` function from `transliteration` npm package.
161
+ Transliterate the string `source` and return the result.
162
+
163
+ **Kind**: static method of [<code>GeoDb</code>](#GeoDb)
164
+
165
+ | Param | Type |
166
+ | --- | --- |
167
+ | source | <code>string</code> |
168
+ | [options] | <code>any</code> |
169
+
170
+ <a name="GeoDb.geonameCityDescr"></a>
171
+
172
+ ### GeoDb.geonameCityDescr(cityName, admin1, countryName) ⇒ <code>string</code>
173
+ Builds a city description from geonameid string components
174
+
175
+ **Kind**: static method of [<code>GeoDb</code>](#GeoDb)
176
+
177
+ | Param | Type | Description |
178
+ | --- | --- | --- |
179
+ | cityName | <code>string</code> | e.g. 'Tel Aviv' or 'Chicago' |
180
+ | admin1 | <code>string</code> | e.g. 'England' or 'Massachusetts' |
181
+ | countryName | <code>string</code> | full country name, e.g. 'Israel' or 'United States' |
182
+
183
+ <a name="GeoDb.version"></a>
184
+
185
+ ### GeoDb.version()
186
+ Returns the version of the GeoDb package
187
+
188
+ **Kind**: static method of [<code>GeoDb</code>](#GeoDb)
189
+ <a name="buildGeonamesSqlite"></a>
190
+
191
+ ## buildGeonamesSqlite(opts)
192
+ Builds `geonames.sqlite3` from files downloaded from geonames.org
193
+
194
+ **Kind**: global function
195
+
196
+ | Param | Type |
197
+ | --- | --- |
198
+ | opts | <code>any</code> |
199
+
200
+ <a name="doSql"></a>
201
+
202
+ ## doSql(logger, db, ...sqls)
203
+ **Kind**: global function
204
+
205
+ | Param | Type |
206
+ | --- | --- |
207
+ | logger | <code>pino.Logger</code> |
208
+ | db | <code>Database</code> |
209
+ | ...sqls | <code>string</code> |
210
+
211
+ <a name="doFile"></a>
212
+
213
+ ## doFile(logger, db, infile, tableName, expectedFields, callback)
214
+ **Kind**: global function
89
215
 
90
216
  | Param | Type |
91
217
  | --- | --- |
92
- | cityName | <code>string</code> |
218
+ | logger | <code>pino.Logger</code> |
219
+ | db | <code>Database</code> |
220
+ | infile | <code>string</code> |
221
+ | tableName | <code>string</code> |
222
+ | expectedFields | <code>number</code> |
223
+ | callback | <code>function</code> |