@futdevpro/fsm-dynamo 1.20.204 → 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.
Files changed (30) hide show
  1. package/README.md +9 -0
  2. package/build/_modules/location/_collections/assets/country-subdivisions/hungary.json +174 -0
  3. package/build/_modules/location/_collections/assets/subdivision-boundaries/hungary.json +1 -0
  4. package/build/_modules/location/_collections/loc-subdivision-locator.util.d.ts +35 -0
  5. package/build/_modules/location/_collections/loc-subdivision-locator.util.d.ts.map +1 -0
  6. package/build/_modules/location/_collections/loc-subdivision-locator.util.js +67 -0
  7. package/build/_modules/location/_collections/loc-subdivision-locator.util.js.map +1 -0
  8. package/build/_modules/location/_models/loc-subdivision-boundaries.interface.d.ts +20 -0
  9. package/build/_modules/location/_models/loc-subdivision-boundaries.interface.d.ts.map +1 -0
  10. package/build/_modules/location/_models/loc-subdivision-boundaries.interface.js +3 -0
  11. package/build/_modules/location/_models/loc-subdivision-boundaries.interface.js.map +1 -0
  12. package/build/_modules/location/index.d.ts +2 -0
  13. package/build/_modules/location/index.d.ts.map +1 -1
  14. package/build/_modules/location/index.js +2 -0
  15. package/build/_modules/location/index.js.map +1 -1
  16. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-field-new-settings.control-model.d.ts +6 -0
  17. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-field-new-settings.control-model.d.ts.map +1 -1
  18. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-field-new-settings.control-model.js +6 -0
  19. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-field-new-settings.control-model.js.map +1 -1
  20. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-range-field-new-settings.control-model.d.ts +6 -0
  21. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-range-field-new-settings.control-model.d.ts.map +1 -1
  22. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-range-field-new-settings.control-model.js +6 -0
  23. package/build/_modules/ngx-models/_models/control-models/forms-new/slider-range-field-new-settings.control-model.js.map +1 -1
  24. package/build-esm/_modules/location/_collections/assets/subdivision-boundaries/hungary.json +1 -0
  25. package/build-esm/_modules/location/_collections/loc-subdivision-locator.util.js +61 -0
  26. package/build-esm/_modules/location/_models/loc-subdivision-boundaries.interface.js +1 -0
  27. package/build-esm/_modules/location/index.js +2 -0
  28. package/build-esm/_modules/ngx-models/_models/control-models/forms-new/slider-field-new-settings.control-model.js +6 -0
  29. package/build-esm/_modules/ngx-models/_models/control-models/forms-new/slider-range-field-new-settings.control-model.js +6 -0
  30. package/package.json +1 -1
@@ -0,0 +1,61 @@
1
+ import HungaryBoundaries from './assets/subdivision-boundaries/hungary.json';
2
+ /**
3
+ * BFR-HELOCIA-077 — coordinates ⇒ ISO 3166-2 subdivision code, without network: the simplified boundaries ship in the
4
+ * package, and the lookup is a point-in-polygon test.
5
+ *
6
+ * Covered countries: Hungary (the 19 counties and Budapest; a city with county rights is counted in its county).
7
+ * Source: the OpenStreetMap boundary relations (© OpenStreetMap contributors, ODbL 1.0: the boundary files are under
8
+ * the ODbL, not the MIT License, and a product showing results from them credits OpenStreetMap). ⚠️ The boundaries
9
+ * are simplified to about 100 m: within about 100 m of a county border a point can fall on the other side. For a
10
+ * statistic per county that is fine; for anything legal (a court, an authority) use the address, not this.
11
+ */
12
+ export class DyFM_SubdivisionLocator {
13
+ /** The boundary sets, one per covered country. */
14
+ static boundaries = [HungaryBoundaries];
15
+ /** ISO 3166-1 alpha-2 codes of the covered countries. */
16
+ static countries = DyFM_SubdivisionLocator.boundaries
17
+ .map((set) => set.country);
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, options) {
27
+ const longitude = coordinates?.longitude;
28
+ const latitude = coordinates?.latitude;
29
+ // a missing, non-finite or out-of-range point is no place
30
+ if (!Number.isFinite(longitude) || !Number.isFinite(latitude) || Math.abs(latitude) > 90 ||
31
+ Math.abs(longitude) > 180) {
32
+ return null;
33
+ }
34
+ for (const set of DyFM_SubdivisionLocator.boundaries) {
35
+ // the areas are ordered: the first one that holds the point is the most specific
36
+ const area = set.areas.find((candidate) => candidate.polygons.some((polygon) => DyFM_SubdivisionLocator.isInPolygon(longitude, latitude, polygon)));
37
+ if (area) {
38
+ return options?.cities ? area.code : area.county;
39
+ }
40
+ }
41
+ return null;
42
+ }
43
+ /**
44
+ * Whether the point is inside a GeoJSON polygon: the even-odd ray casting over every ring, so a hole (a city cut out
45
+ * of its county) is outside.
46
+ */
47
+ static isInPolygon(longitude, latitude, polygon) {
48
+ let inside = false;
49
+ for (const ring of polygon) {
50
+ // every edge the eastward ray from the point crosses flips the side
51
+ for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
52
+ const [xi, yi] = ring[i];
53
+ const [xj, yj] = ring[j];
54
+ if ((yi > latitude) !== (yj > latitude) && longitude < (xj - xi) * (latitude - yi) / (yj - yi) + xi) {
55
+ inside = !inside;
56
+ }
57
+ }
58
+ }
59
+ return inside;
60
+ }
61
+ }
@@ -7,6 +7,7 @@ export * from './_collections/loc-country-divisions.const';
7
7
  export * from './_collections/loc-country-isos.const';
8
8
  export * from './_collections/loc.util';
9
9
  export * from './_collections/loc-regions.util';
10
+ export * from './_collections/loc-subdivision-locator.util';
10
11
  // INTERFACES
11
12
  export * from './_models/loc-country-division.interface';
12
13
  export * from './_models/loc-country-iso.interface';
@@ -15,3 +16,4 @@ export * from './_models/loc-division-collection.interface';
15
16
  export * from './_models/loc-division-region-data.interface';
16
17
  export * from './_models/loc-geo-ip-location.interface';
17
18
  export * from './_models/loc-coordinates.interface';
19
+ export * from './_models/loc-subdivision-boundaries.interface';
@@ -28,6 +28,12 @@ export class DyFM_SliderFieldNew_Settings_ControlModel extends DyFM_FieldNew_Set
28
28
  */
29
29
  /** @deprecated Use isValueDisplayShown; showValueDisplay remains the serialized compatibility key. */
30
30
  showValueDisplay;
31
+ /**
32
+ * BFR-HELOCIA-082 — the "not given" choice (the legacy `nullOption`; the select's `nullOptionLabel`): when set, a
33
+ * checkbox with this label stands by the slider; checked, the slider hides and the value is `null`. A stored
34
+ * `null` loads as `null` (⛔ the bottom); unchecking gives the own `defaultValue`, else the bottom (`min`).
35
+ */
36
+ nullOptionLabel;
31
37
  /** Initializes the existing defaults and applies caller-provided settings. */
32
38
  constructor(set) {
33
39
  super(set);
@@ -25,6 +25,12 @@ export class DyFM_SliderRangeFieldNew_Settings_ControlModel extends DyFM_FieldNe
25
25
  */
26
26
  /** @deprecated Use isValueDisplayShown; showValueDisplay remains the serialized compatibility key. */
27
27
  showValueDisplay;
28
+ /**
29
+ * BFR-HELOCIA-082 — the "not given" choice (the legacy `nullOption`; the select's `nullOptionLabel`): when set, a
30
+ * checkbox with this label stands by the range; checked, the range hides and the value is `null`. A stored
31
+ * `null` loads as `null` (⛔ the full range); unchecking gives the own `defaultValue`, else the full range.
32
+ */
33
+ nullOptionLabel;
28
34
  /** Initializes the existing defaults and applies caller-provided settings. */
29
35
  constructor(set) {
30
36
  super(set);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futdevpro/fsm-dynamo",
3
- "version": "1.20.204",
3
+ "version": "1.20.206",
4
4
  "description": "Full Stack Model Collection for Dynamic (NodeJS-Typescript) Framework called Dynamo, by Future Development Ltd.",
5
5
  "DyBu_settings": {
6
6
  "packageType": "full-stack-package",