@janekolszak/poland 1.0.8 → 1.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janekolszak/poland",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Administrative division of Poland",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/src/compute.ts CHANGED
@@ -31,6 +31,13 @@ export interface Computed {
31
31
  streetsDistricts: MultiKeyMap
32
32
  }
33
33
 
34
+
35
+ const getFullName = (f: string, s: string): string => {
36
+ if (!s || s === "") {
37
+ return f
38
+ }
39
+ return f + " " + s
40
+ }
34
41
  // RODZ_GMI
35
42
  // 1 - gmina miejska,
36
43
  // 2 - gmina wiejska,
@@ -212,7 +219,7 @@ export function compute(regions: Array<Region>, localities: Array<Locality>, loc
212
219
  return
213
220
  }
214
221
 
215
- const fullName = r.name + " " + r.restName
222
+ const fullName = getFullName(r.name, r.restName)
216
223
 
217
224
  if (districtIds.includes(l.localityTypeId)) {
218
225
  const d = out.districts.get([v, c, m, l.name])
@@ -254,7 +261,7 @@ export function compute(regions: Array<Region>, localities: Array<Locality>, loc
254
261
 
255
262
  let s = out.streetsDistricts.get([v, c, m, l, d])
256
263
  s = s ? s : []
257
- const fullName = r.name + " " + r.restName
264
+ const fullName = getFullName(r.name, r.restName)
258
265
 
259
266
  if (!s.includes(fullName)) {
260
267
  out.streetsDistricts.set([v, c, m, l, d], [...s, fullName])
@@ -281,7 +288,7 @@ export function compute(regions: Array<Region>, localities: Array<Locality>, loc
281
288
 
282
289
  let s = out.streetsDistricts.get([v, c, m, l, d])
283
290
  s = s ? s : []
284
- const fullName = r.name + " " + r.restName
291
+ const fullName = getFullName(r.name, r.restName)
285
292
  if (!s.includes(fullName)) {
286
293
  out.streetsDistricts.set([v, c, m, l, d], [...s, fullName])
287
294
  }