@futdevpro/fsm-dynamo 1.20.205 → 1.20.206
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 +9 -0
- package/build/_modules/location/_collections/assets/country-subdivisions/hungary.json +174 -0
- package/build/_modules/location/_collections/assets/subdivision-boundaries/hungary.json +1 -0
- package/build/_modules/location/_collections/loc-subdivision-locator.util.d.ts +35 -0
- package/build/_modules/location/_collections/loc-subdivision-locator.util.d.ts.map +1 -0
- package/build/_modules/location/_collections/loc-subdivision-locator.util.js +67 -0
- package/build/_modules/location/_collections/loc-subdivision-locator.util.js.map +1 -0
- package/build/_modules/location/_models/loc-subdivision-boundaries.interface.d.ts +20 -0
- package/build/_modules/location/_models/loc-subdivision-boundaries.interface.d.ts.map +1 -0
- package/build/_modules/location/_models/loc-subdivision-boundaries.interface.js +3 -0
- package/build/_modules/location/_models/loc-subdivision-boundaries.interface.js.map +1 -0
- package/build/_modules/location/index.d.ts +2 -0
- package/build/_modules/location/index.d.ts.map +1 -1
- package/build/_modules/location/index.js +2 -0
- package/build/_modules/location/index.js.map +1 -1
- package/build-esm/_modules/location/_collections/assets/subdivision-boundaries/hungary.json +1 -0
- package/build-esm/_modules/location/_collections/loc-subdivision-locator.util.js +61 -0
- package/build-esm/_modules/location/_models/loc-subdivision-boundaries.interface.js +1 -0
- package/build-esm/_modules/location/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DyFM_LocationCoordinates } from '../_models/loc-coordinates.interface';
|
|
2
|
+
import { DyFM_SubdivisionBoundaries } from '../_models/loc-subdivision-boundaries.interface';
|
|
3
|
+
/**
|
|
4
|
+
* BFR-HELOCIA-077 — coordinates ⇒ ISO 3166-2 subdivision code, without network: the simplified boundaries ship in the
|
|
5
|
+
* package, and the lookup is a point-in-polygon test.
|
|
6
|
+
*
|
|
7
|
+
* Covered countries: Hungary (the 19 counties and Budapest; a city with county rights is counted in its county).
|
|
8
|
+
* Source: the OpenStreetMap boundary relations (© OpenStreetMap contributors, ODbL 1.0: the boundary files are under
|
|
9
|
+
* the ODbL, not the MIT License, and a product showing results from them credits OpenStreetMap). ⚠️ The boundaries
|
|
10
|
+
* are simplified to about 100 m: within about 100 m of a county border a point can fall on the other side. For a
|
|
11
|
+
* statistic per county that is fine; for anything legal (a court, an authority) use the address, not this.
|
|
12
|
+
*/
|
|
13
|
+
export declare class DyFM_SubdivisionLocator {
|
|
14
|
+
/** The boundary sets, one per covered country. */
|
|
15
|
+
static readonly boundaries: DyFM_SubdivisionBoundaries[];
|
|
16
|
+
/** ISO 3166-1 alpha-2 codes of the covered countries. */
|
|
17
|
+
static readonly countries: string[];
|
|
18
|
+
/**
|
|
19
|
+
* The ISO 3166-2 code of the subdivision the point lies in (Hungary: the county, `HU-BU` for Budapest), or `null`
|
|
20
|
+
* outside every covered country or for an invalid point.
|
|
21
|
+
*
|
|
22
|
+
* @param coordinates the point (WGS 84 degrees)
|
|
23
|
+
* @param options.cities a point inside a city with county rights gets the city's own code (e.g. `HU-DE`), not its
|
|
24
|
+
* county's (`HU-HB`)
|
|
25
|
+
*/
|
|
26
|
+
static getSubdivisionCode(coordinates: DyFM_LocationCoordinates, options?: {
|
|
27
|
+
cities?: boolean;
|
|
28
|
+
}): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the point is inside a GeoJSON polygon: the even-odd ray casting over every ring, so a hole (a city cut out
|
|
31
|
+
* of its county) is outside.
|
|
32
|
+
*/
|
|
33
|
+
static isInPolygon(longitude: number, latitude: number, polygon: number[][][]): boolean;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=loc-subdivision-locator.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loc-subdivision-locator.util.d.ts","sourceRoot":"","sources":["../../../../src/_modules/location/_collections/loc-subdivision-locator.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAI7F;;;;;;;;;GASG;AACH,qBAAa,uBAAuB;IAClC,kDAAkD;IAClD,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,0BAA0B,EAAE,CAAyB;IAEjF,yDAAyD;IACzD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAC8B;IAEjE;;;;;;;OAOG;IACH,MAAM,CAAC,kBAAkB,CACvB,WAAW,EAAE,wBAAwB,EACrC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAC7B,MAAM,GAAG,IAAI;IA0BhB;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO;CAiBxF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DyFM_SubdivisionLocator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const hungary_json_1 = tslib_1.__importDefault(require("./assets/subdivision-boundaries/hungary.json"));
|
|
6
|
+
/**
|
|
7
|
+
* BFR-HELOCIA-077 — coordinates ⇒ ISO 3166-2 subdivision code, without network: the simplified boundaries ship in the
|
|
8
|
+
* package, and the lookup is a point-in-polygon test.
|
|
9
|
+
*
|
|
10
|
+
* Covered countries: Hungary (the 19 counties and Budapest; a city with county rights is counted in its county).
|
|
11
|
+
* Source: the OpenStreetMap boundary relations (© OpenStreetMap contributors, ODbL 1.0: the boundary files are under
|
|
12
|
+
* the ODbL, not the MIT License, and a product showing results from them credits OpenStreetMap). ⚠️ The boundaries
|
|
13
|
+
* are simplified to about 100 m: within about 100 m of a county border a point can fall on the other side. For a
|
|
14
|
+
* statistic per county that is fine; for anything legal (a court, an authority) use the address, not this.
|
|
15
|
+
*/
|
|
16
|
+
class DyFM_SubdivisionLocator {
|
|
17
|
+
/** The boundary sets, one per covered country. */
|
|
18
|
+
static boundaries = [hungary_json_1.default];
|
|
19
|
+
/** ISO 3166-1 alpha-2 codes of the covered countries. */
|
|
20
|
+
static countries = DyFM_SubdivisionLocator.boundaries
|
|
21
|
+
.map((set) => set.country);
|
|
22
|
+
/**
|
|
23
|
+
* The ISO 3166-2 code of the subdivision the point lies in (Hungary: the county, `HU-BU` for Budapest), or `null`
|
|
24
|
+
* outside every covered country or for an invalid point.
|
|
25
|
+
*
|
|
26
|
+
* @param coordinates the point (WGS 84 degrees)
|
|
27
|
+
* @param options.cities a point inside a city with county rights gets the city's own code (e.g. `HU-DE`), not its
|
|
28
|
+
* county's (`HU-HB`)
|
|
29
|
+
*/
|
|
30
|
+
static getSubdivisionCode(coordinates, options) {
|
|
31
|
+
const longitude = coordinates?.longitude;
|
|
32
|
+
const latitude = coordinates?.latitude;
|
|
33
|
+
// a missing, non-finite or out-of-range point is no place
|
|
34
|
+
if (!Number.isFinite(longitude) || !Number.isFinite(latitude) || Math.abs(latitude) > 90 ||
|
|
35
|
+
Math.abs(longitude) > 180) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
for (const set of DyFM_SubdivisionLocator.boundaries) {
|
|
39
|
+
// the areas are ordered: the first one that holds the point is the most specific
|
|
40
|
+
const area = set.areas.find((candidate) => candidate.polygons.some((polygon) => DyFM_SubdivisionLocator.isInPolygon(longitude, latitude, polygon)));
|
|
41
|
+
if (area) {
|
|
42
|
+
return options?.cities ? area.code : area.county;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether the point is inside a GeoJSON polygon: the even-odd ray casting over every ring, so a hole (a city cut out
|
|
49
|
+
* of its county) is outside.
|
|
50
|
+
*/
|
|
51
|
+
static isInPolygon(longitude, latitude, polygon) {
|
|
52
|
+
let inside = false;
|
|
53
|
+
for (const ring of polygon) {
|
|
54
|
+
// every edge the eastward ray from the point crosses flips the side
|
|
55
|
+
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
|
|
56
|
+
const [xi, yi] = ring[i];
|
|
57
|
+
const [xj, yj] = ring[j];
|
|
58
|
+
if ((yi > latitude) !== (yj > latitude) && longitude < (xj - xi) * (latitude - yi) / (yj - yi) + xi) {
|
|
59
|
+
inside = !inside;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return inside;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.DyFM_SubdivisionLocator = DyFM_SubdivisionLocator;
|
|
67
|
+
//# sourceMappingURL=loc-subdivision-locator.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loc-subdivision-locator.util.js","sourceRoot":"","sources":["../../../../src/_modules/location/_collections/loc-subdivision-locator.util.ts"],"names":[],"mappings":";;;;AAGA,wGAA6E;AAE7E;;;;;;;;;GASG;AACH,MAAa,uBAAuB;IAClC,kDAAkD;IAClD,MAAM,CAAU,UAAU,GAAiC,CAAE,sBAAiB,CAAE,CAAC;IAEjF,yDAAyD;IACzD,MAAM,CAAU,SAAS,GAAa,uBAAuB,CAAC,UAAU;SACrE,GAAG,CAAC,CAAC,GAA+B,EAAU,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEjE;;;;;;;OAOG;IACH,MAAM,CAAC,kBAAkB,CACvB,WAAqC,EACrC,OAA8B;QAE9B,MAAM,SAAS,GAAW,WAAW,EAAE,SAAS,CAAC;QACjD,MAAM,QAAQ,GAAW,WAAW,EAAE,QAAQ,CAAC;QAE/C,0DAA0D;QAC1D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAA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AAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC;oBACpG,MAAM,GAAG,CAAC,MAAM,CAAC;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;;AAjEH,0DAkEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BFR-HELOCIA-077 — a country's simplified subdivision boundaries, shipped in the package (no network).
|
|
3
|
+
*
|
|
4
|
+
* The areas are in lookup order: the more specific first (a city inside its county comes before the county).
|
|
5
|
+
* A polygon is a GeoJSON polygon: rings of `[longitude, latitude]`, the first ring the outline, the others holes.
|
|
6
|
+
*/
|
|
7
|
+
export interface DyFM_SubdivisionBoundaries {
|
|
8
|
+
/** ISO 3166-1 alpha-2 code of the country. */
|
|
9
|
+
country: string;
|
|
10
|
+
/** Where the boundaries come from, with the licence. */
|
|
11
|
+
source: string;
|
|
12
|
+
areas: {
|
|
13
|
+
/** ISO 3166-2 code of the area (a city has its own code). */
|
|
14
|
+
code: string;
|
|
15
|
+
/** ISO 3166-2 code the area is counted in (a city: its county; a county: itself). */
|
|
16
|
+
county: string;
|
|
17
|
+
polygons: number[][][][];
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=loc-subdivision-boundaries.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loc-subdivision-boundaries.interface.d.ts","sourceRoot":"","sources":["../../../../src/_modules/location/_models/loc-subdivision-boundaries.interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE;QACL,6DAA6D;QAC7D,IAAI,EAAE,MAAM,CAAC;QACb,qFAAqF;QACrF,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;KAC1B,EAAE,CAAC;CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loc-subdivision-boundaries.interface.js","sourceRoot":"","sources":["../../../../src/_modules/location/_models/loc-subdivision-boundaries.interface.ts"],"names":[],"mappings":""}
|
|
@@ -5,6 +5,7 @@ export * from './_collections/loc-country-divisions.const';
|
|
|
5
5
|
export * from './_collections/loc-country-isos.const';
|
|
6
6
|
export * from './_collections/loc.util';
|
|
7
7
|
export * from './_collections/loc-regions.util';
|
|
8
|
+
export * from './_collections/loc-subdivision-locator.util';
|
|
8
9
|
export * from './_models/loc-country-division.interface';
|
|
9
10
|
export * from './_models/loc-country-iso.interface';
|
|
10
11
|
export * from './_models/loc-country-phone-code.interface';
|
|
@@ -12,4 +13,5 @@ export * from './_models/loc-division-collection.interface';
|
|
|
12
13
|
export * from './_models/loc-division-region-data.interface';
|
|
13
14
|
export * from './_models/loc-geo-ip-location.interface';
|
|
14
15
|
export * from './_models/loc-coordinates.interface';
|
|
16
|
+
export * from './_models/loc-subdivision-boundaries.interface';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/_modules/location/index.ts"],"names":[],"mappings":"AAEA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2CAA2C,CAAC;AAG1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/_modules/location/index.ts"],"names":[],"mappings":"AAEA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2CAA2C,CAAC;AAG1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6CAA6C,CAAC;AAG5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gDAAgD,CAAC"}
|
|
@@ -10,6 +10,7 @@ tslib_1.__exportStar(require("./_collections/loc-country-divisions.const"), expo
|
|
|
10
10
|
tslib_1.__exportStar(require("./_collections/loc-country-isos.const"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./_collections/loc.util"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./_collections/loc-regions.util"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./_collections/loc-subdivision-locator.util"), exports);
|
|
13
14
|
// INTERFACES
|
|
14
15
|
tslib_1.__exportStar(require("./_models/loc-country-division.interface"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./_models/loc-country-iso.interface"), exports);
|
|
@@ -18,4 +19,5 @@ tslib_1.__exportStar(require("./_models/loc-division-collection.interface"), exp
|
|
|
18
19
|
tslib_1.__exportStar(require("./_models/loc-division-region-data.interface"), exports);
|
|
19
20
|
tslib_1.__exportStar(require("./_models/loc-geo-ip-location.interface"), exports);
|
|
20
21
|
tslib_1.__exportStar(require("./_models/loc-coordinates.interface"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./_models/loc-subdivision-boundaries.interface"), exports);
|
|
21
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/_modules/location/index.ts"],"names":[],"mappings":";;;AACA,QAAQ;AACR,mEAAyC;AACzC,uEAA6C;AAC7C,oFAA0D;AAE1D,cAAc;AACd,qFAA2D;AAC3D,gFAAsD;AACtD,kEAAwC;AACxC,0EAAgD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/_modules/location/index.ts"],"names":[],"mappings":";;;AACA,QAAQ;AACR,mEAAyC;AACzC,uEAA6C;AAC7C,oFAA0D;AAE1D,cAAc;AACd,qFAA2D;AAC3D,gFAAsD;AACtD,kEAAwC;AACxC,0EAAgD;AAChD,sFAA4D;AAE5D,aAAa;AACb,mFAAyD;AACzD,8EAAoD;AACpD,qFAA2D;AAC3D,sFAA4D;AAC5D,uFAA6D;AAC7D,kFAAwD;AACxD,8EAAoD;AACpD,yFAA+D"}
|