@mcp-b/geo-support 0.2.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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/dist/base/geo-map-element.d.ts +60 -0
  3. package/dist/base/geo-map-element.d.ts.map +1 -0
  4. package/dist/base/geo-map-element.js +100 -0
  5. package/dist/base/geo-map-element.js.map +1 -0
  6. package/dist/classification/algorithms.d.ts +26 -0
  7. package/dist/classification/algorithms.d.ts.map +1 -0
  8. package/dist/classification/algorithms.js +101 -0
  9. package/dist/classification/algorithms.js.map +1 -0
  10. package/dist/classification/channel.d.ts +16 -0
  11. package/dist/classification/channel.d.ts.map +1 -0
  12. package/dist/classification/channel.js +18 -0
  13. package/dist/classification/channel.js.map +1 -0
  14. package/dist/classification/classify-style.d.ts +25 -0
  15. package/dist/classification/classify-style.d.ts.map +1 -0
  16. package/dist/classification/classify-style.js +70 -0
  17. package/dist/classification/classify-style.js.map +1 -0
  18. package/dist/classification/color-schemes.d.ts +18 -0
  19. package/dist/classification/color-schemes.d.ts.map +1 -0
  20. package/dist/classification/color-schemes.js +193 -0
  21. package/dist/classification/color-schemes.js.map +1 -0
  22. package/dist/classification/index.d.ts +5 -0
  23. package/dist/classification/index.d.ts.map +1 -0
  24. package/dist/classification/index.js +5 -0
  25. package/dist/classification/index.js.map +1 -0
  26. package/dist/components/classify-panel/classify-panel.d.ts +70 -0
  27. package/dist/components/classify-panel/classify-panel.d.ts.map +1 -0
  28. package/dist/components/classify-panel/classify-panel.js +273 -0
  29. package/dist/components/classify-panel/classify-panel.js.map +1 -0
  30. package/dist/components/classify-panel/classify-panel.styles.d.ts +3 -0
  31. package/dist/components/classify-panel/classify-panel.styles.d.ts.map +1 -0
  32. package/dist/components/classify-panel/classify-panel.styles.js +96 -0
  33. package/dist/components/classify-panel/classify-panel.styles.js.map +1 -0
  34. package/dist/components/legend/legend.d.ts +49 -0
  35. package/dist/components/legend/legend.d.ts.map +1 -0
  36. package/dist/components/legend/legend.js +129 -0
  37. package/dist/components/legend/legend.js.map +1 -0
  38. package/dist/components/legend/legend.styles.d.ts +3 -0
  39. package/dist/components/legend/legend.styles.d.ts.map +1 -0
  40. package/dist/components/legend/legend.styles.js +76 -0
  41. package/dist/components/legend/legend.styles.js.map +1 -0
  42. package/dist/docs/custom-elements.json +1796 -0
  43. package/dist/events/classify.d.ts +23 -0
  44. package/dist/events/classify.d.ts.map +1 -0
  45. package/dist/events/classify.js +12 -0
  46. package/dist/events/classify.js.map +1 -0
  47. package/dist/events/feature.d.ts +21 -0
  48. package/dist/events/feature.d.ts.map +1 -0
  49. package/dist/events/feature.js +17 -0
  50. package/dist/events/feature.js.map +1 -0
  51. package/dist/events/index.d.ts +5 -0
  52. package/dist/events/index.d.ts.map +1 -0
  53. package/dist/events/index.js +5 -0
  54. package/dist/events/index.js.map +1 -0
  55. package/dist/events/layer.d.ts +17 -0
  56. package/dist/events/layer.d.ts.map +1 -0
  57. package/dist/events/layer.js +15 -0
  58. package/dist/events/layer.js.map +1 -0
  59. package/dist/events/map.d.ts +42 -0
  60. package/dist/events/map.d.ts.map +1 -0
  61. package/dist/events/map.js +43 -0
  62. package/dist/events/map.js.map +1 -0
  63. package/dist/index.d.ts +7 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +7 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/styles/map-host.styles.d.ts +4 -0
  68. package/dist/styles/map-host.styles.d.ts.map +1 -0
  69. package/dist/styles/map-host.styles.js +17 -0
  70. package/dist/styles/map-host.styles.js.map +1 -0
  71. package/dist/types/coordinates.d.ts +13 -0
  72. package/dist/types/coordinates.d.ts.map +1 -0
  73. package/dist/types/coordinates.js +2 -0
  74. package/dist/types/coordinates.js.map +1 -0
  75. package/dist/types/geojson.d.ts +18 -0
  76. package/dist/types/geojson.d.ts.map +1 -0
  77. package/dist/types/geojson.js +3 -0
  78. package/dist/types/geojson.js.map +1 -0
  79. package/dist/types/index.d.ts +5 -0
  80. package/dist/types/index.d.ts.map +1 -0
  81. package/dist/types/index.js +5 -0
  82. package/dist/types/index.js.map +1 -0
  83. package/dist/types/map.d.ts +17 -0
  84. package/dist/types/map.d.ts.map +1 -0
  85. package/dist/types/map.js +2 -0
  86. package/dist/types/map.js.map +1 -0
  87. package/dist/types/style.d.ts +48 -0
  88. package/dist/types/style.d.ts.map +1 -0
  89. package/dist/types/style.js +2 -0
  90. package/dist/types/style.js.map +1 -0
  91. package/package.json +103 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MCP-B contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,60 @@
1
+ import { type PropertyValues } from "lit";
2
+ import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
3
+ import type { FlyToOptions, FitBoundsOptions } from "../types/map.js";
4
+ /**
5
+ * Abstract base class for all geo map components. Provides shared reactive
6
+ * properties, ResizeObserver lifecycle, and abstract hooks for library-specific
7
+ * map creation and updates.
8
+ *
9
+ * Subclasses must implement `createMap`, `destroyMap`, `updateView`, and
10
+ * `invalidateSize`.
11
+ */
12
+ export declare abstract class GeoMapElement extends SigveloElement {
13
+ static styles: import("lit").CSSResult[];
14
+ /** Map center latitude. */
15
+ latitude: number;
16
+ /** Map center longitude. */
17
+ longitude: number;
18
+ /** Map zoom level. */
19
+ zoom: number;
20
+ /** Minimum allowed zoom level. */
21
+ minZoom: number;
22
+ /** Maximum allowed zoom level. */
23
+ maxZoom: number;
24
+ /** Map bearing (rotation) in degrees. Not all libraries support this. */
25
+ bearing: number;
26
+ /** Map pitch (tilt) in degrees. Not all libraries support this. */
27
+ pitch: number;
28
+ protected mapHost: HTMLDivElement;
29
+ private _resizeObserver;
30
+ /**
31
+ * When true, property changes from map interaction callbacks are suppressed
32
+ * to avoid re-triggering `updateView`. Subclasses should set this to `true`
33
+ * before syncing properties from the map, and back to `false` after.
34
+ */
35
+ protected _suppressExternalUpdate: boolean;
36
+ /**
37
+ * Resolved when the underlying map instance is ready. Child components
38
+ * (markers, layers, controls) should await this before registering.
39
+ */
40
+ readonly mapReady: Promise<void>;
41
+ protected _resolveMapReady: () => void;
42
+ constructor();
43
+ /** Create the map instance and attach it to the given container element. */
44
+ protected abstract createMap(container: HTMLElement): void;
45
+ /** Destroy the map instance and clean up resources. */
46
+ protected abstract destroyMap(): void;
47
+ /** Update the map view when reactive properties change. */
48
+ protected abstract updateView(changed: PropertyValues): void;
49
+ /** Notify the map library that its container has been resized. */
50
+ protected abstract invalidateSize(): void;
51
+ /** Programmatically fly to a location. */
52
+ abstract flyTo(options: FlyToOptions): void;
53
+ /** Programmatically fit the map to bounds. */
54
+ abstract fitBounds(options: FitBoundsOptions): void;
55
+ protected firstUpdated(changed: PropertyValues): void;
56
+ protected updated(changed: PropertyValues): void;
57
+ disconnectedCallback(): void;
58
+ render(): import("lit-html").TemplateResult<1>;
59
+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YAAY,GAAG,IAAI;IAElD,8CAA8C;aAC9B,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAE1D,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc;IAU9C,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc;IAOzC,oBAAoB;IAOpB,MAAM;CAMP"}
@@ -0,0 +1,100 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html } from "lit";
8
+ import { property, query } from "lit/decorators.js";
9
+ import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
10
+ import hostStyles from "@mcp-b/wc-support/styles/host.styles";
11
+ import mapHostStyles from "../styles/map-host.styles.js";
12
+ /**
13
+ * Abstract base class for all geo map components. Provides shared reactive
14
+ * properties, ResizeObserver lifecycle, and abstract hooks for library-specific
15
+ * map creation and updates.
16
+ *
17
+ * Subclasses must implement `createMap`, `destroyMap`, `updateView`, and
18
+ * `invalidateSize`.
19
+ */
20
+ export class GeoMapElement extends SigveloElement {
21
+ constructor() {
22
+ super();
23
+ /** Map center latitude. */
24
+ this.latitude = 0;
25
+ /** Map center longitude. */
26
+ this.longitude = 0;
27
+ /** Map zoom level. */
28
+ this.zoom = 2;
29
+ /** Minimum allowed zoom level. */
30
+ this.minZoom = 0;
31
+ /** Maximum allowed zoom level. */
32
+ this.maxZoom = 22;
33
+ /** Map bearing (rotation) in degrees. Not all libraries support this. */
34
+ this.bearing = 0;
35
+ /** Map pitch (tilt) in degrees. Not all libraries support this. */
36
+ this.pitch = 0;
37
+ this._resizeObserver = null;
38
+ /**
39
+ * When true, property changes from map interaction callbacks are suppressed
40
+ * to avoid re-triggering `updateView`. Subclasses should set this to `true`
41
+ * before syncing properties from the map, and back to `false` after.
42
+ */
43
+ this._suppressExternalUpdate = false;
44
+ this.mapReady = new Promise((resolve) => {
45
+ this._resolveMapReady = resolve;
46
+ });
47
+ }
48
+ firstUpdated(changed) {
49
+ super.firstUpdated(changed);
50
+ this.createMap(this.mapHost);
51
+ this._resizeObserver = new ResizeObserver(() => {
52
+ this.invalidateSize();
53
+ });
54
+ this._resizeObserver.observe(this.mapHost);
55
+ }
56
+ updated(changed) {
57
+ super.updated(changed);
58
+ if (!this._suppressExternalUpdate) {
59
+ this.updateView(changed);
60
+ }
61
+ }
62
+ disconnectedCallback() {
63
+ super.disconnectedCallback();
64
+ this._resizeObserver?.disconnect();
65
+ this._resizeObserver = null;
66
+ this.destroyMap();
67
+ }
68
+ render() {
69
+ return html `
70
+ <div class="map-host" part="map"></div>
71
+ <slot></slot>
72
+ `;
73
+ }
74
+ }
75
+ GeoMapElement.styles = [hostStyles, mapHostStyles];
76
+ __decorate([
77
+ property({ type: Number })
78
+ ], GeoMapElement.prototype, "latitude", void 0);
79
+ __decorate([
80
+ property({ type: Number })
81
+ ], GeoMapElement.prototype, "longitude", void 0);
82
+ __decorate([
83
+ property({ type: Number })
84
+ ], GeoMapElement.prototype, "zoom", void 0);
85
+ __decorate([
86
+ property({ attribute: "min-zoom", type: Number })
87
+ ], GeoMapElement.prototype, "minZoom", void 0);
88
+ __decorate([
89
+ property({ attribute: "max-zoom", type: Number })
90
+ ], GeoMapElement.prototype, "maxZoom", void 0);
91
+ __decorate([
92
+ property({ type: Number })
93
+ ], GeoMapElement.prototype, "bearing", void 0);
94
+ __decorate([
95
+ property({ type: Number })
96
+ ], GeoMapElement.prototype, "pitch", void 0);
97
+ __decorate([
98
+ query(".map-host")
99
+ ], GeoMapElement.prototype, "mapHost", void 0);
100
+ //# s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+1,26 @@
1
+ /**
2
+ * Classification algorithms for choropleth mapping.
3
+ * All break functions return `numClasses + 1` values: [min, break1, ..., max].
4
+ */
5
+ /**
6
+ * Equal interval classification.
7
+ * Divides the range [min, max] into equal-width bins.
8
+ */
9
+ export declare function equalInterval(values: number[], numClasses: number): number[];
10
+ /**
11
+ * Quantile classification.
12
+ * Splits sorted values into groups of approximately equal count.
13
+ */
14
+ export declare function quantileBreaks(values: number[], numClasses: number): number[];
15
+ /**
16
+ * Natural breaks (Jenks-Fisher) classification.
17
+ * Minimizes within-class variance using dynamic programming.
18
+ */
19
+ export declare function naturalBreaks(values: number[], numClasses: number): number[];
20
+ /**
21
+ * Returns the class index (0-based) for a value given a breaks array.
22
+ * The breaks array has `numClasses + 1` entries: [min, break1, ..., max].
23
+ * Returns -1 for NaN/null/undefined values.
24
+ */
25
+ export declare function classifyValue(value: number, breaks: number[]): number;
26
+ //# sourceMappingURL=algorithms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorithms.d.ts","sourceRoot":"","sources":["../../src/classification/algorithms.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAK5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAY7E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAiE5E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAOrE"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Classification algorithms for choropleth mapping.
3
+ * All break functions return `numClasses + 1` values: [min, break1, ..., max].
4
+ */
5
+ /**
6
+ * Equal interval classification.
7
+ * Divides the range [min, max] into equal-width bins.
8
+ */
9
+ export function equalInterval(values, numClasses) {
10
+ const min = Math.min(...values);
11
+ const max = Math.max(...values);
12
+ const step = (max - min) / numClasses;
13
+ return Array.from({ length: numClasses + 1 }, (_, i) => min + i * step);
14
+ }
15
+ /**
16
+ * Quantile classification.
17
+ * Splits sorted values into groups of approximately equal count.
18
+ */
19
+ export function quantileBreaks(values, numClasses) {
20
+ const sorted = [...values].toSorted((a, b) => a - b);
21
+ const n = sorted.length;
22
+ const breaks = [sorted[0]];
23
+ for (let i = 1; i < numClasses; i++) {
24
+ const idx = Math.floor((i / numClasses) * n);
25
+ breaks.push(sorted[Math.min(idx, n - 1)]);
26
+ }
27
+ breaks.push(sorted[n - 1]);
28
+ return breaks;
29
+ }
30
+ /**
31
+ * Natural breaks (Jenks-Fisher) classification.
32
+ * Minimizes within-class variance using dynamic programming.
33
+ */
34
+ export function naturalBreaks(values, numClasses) {
35
+ const sorted = [...values].toSorted((a, b) => a - b);
36
+ const n = sorted.length;
37
+ if (n <= numClasses) {
38
+ return [...sorted, sorted[n - 1]];
39
+ }
40
+ // Lower class limits matrix: lc[i][j] = start index for class j considering first i values
41
+ const lc = Array.from({ length: n + 1 }, () => Array.from({ length: numClasses + 1 }, () => 0));
42
+ // Variance combinations matrix
43
+ const vc = Array.from({ length: n + 1 }, () => {
44
+ const row = Array.from({ length: numClasses + 1 }, () => Infinity);
45
+ return row;
46
+ });
47
+ for (let j = 1; j <= numClasses; j++) {
48
+ lc[1][j] = 1;
49
+ vc[1][j] = 0;
50
+ }
51
+ for (let l = 2; l <= n; l++) {
52
+ let sum = 0;
53
+ let sumSq = 0;
54
+ for (let m = 1; m <= l; m++) {
55
+ const lower = l - m + 1;
56
+ const val = sorted[lower - 1];
57
+ sum += val;
58
+ sumSq += val * val;
59
+ const variance = sumSq - (sum * sum) / m;
60
+ const i = lower - 1;
61
+ if (i !== 0) {
62
+ for (let j = 2; j <= numClasses; j++) {
63
+ const candidate = variance + vc[i][j - 1];
64
+ if (vc[l][j] >= candidate) {
65
+ lc[l][j] = lower;
66
+ vc[l][j] = candidate;
67
+ }
68
+ }
69
+ }
70
+ lc[l][1] = 1;
71
+ vc[l][1] = sumSq - (sum * sum) / l;
72
+ }
73
+ }
74
+ // Extract breaks by backtracking through the lower class limits matrix
75
+ const breaks = Array.from({ length: numClasses + 1 }, () => 0);
76
+ breaks[numClasses] = sorted[n - 1];
77
+ breaks[0] = sorted[0];
78
+ let k = n;
79
+ for (let j = numClasses; j >= 2; j--) {
80
+ const idx = lc[k][j] - 1;
81
+ breaks[j - 1] = sorted[idx];
82
+ k = lc[k][j] - 1;
83
+ }
84
+ return breaks;
85
+ }
86
+ /**
87
+ * Returns the class index (0-based) for a value given a breaks array.
88
+ * The breaks array has `numClasses + 1` entries: [min, break1, ..., max].
89
+ * Returns -1 for NaN/null/undefined values.
90
+ */
91
+ export function classifyValue(value, breaks) {
92
+ if (value == null || Number.isNaN(value))
93
+ return -1;
94
+ const numClasses = breaks.length - 1;
95
+ for (let i = 1; i <= numClasses; i++) {
96
+ if (value <= breaks[i])
97
+ return i - 1;
98
+ }
99
+ return numClasses - 1;
100
+ }
101
+ //# sourceMappingURL=algorithms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorithms.js","sourceRoot":"","sources":["../../src/classification/algorithms.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,UAAkB;IAChE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC;IACtC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE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,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAgB;IAC3D,IAAI,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACpD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,UAAU,GAAG,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ClassificationMethod, StyleFunction } from "../types/style.js";
2
+ /** Payload published when classification settings change. */
3
+ export interface ClassifyUpdateDetail {
4
+ styleFunction: StyleFunction;
5
+ breaks: number[];
6
+ colors: string[];
7
+ property: string;
8
+ method: ClassificationMethod;
9
+ }
10
+ type ClassifyUpdateHandler = (detail: ClassifyUpdateDetail) => void;
11
+ /** Subscribe to classification updates on a named channel. Returns an unsubscribe function. */
12
+ export declare function subscribeClassify(channelId: string, handler: ClassifyUpdateHandler): () => void;
13
+ /** Publish a classification update to all subscribers on a named channel. */
14
+ export declare function publishClassify(channelId: string, detail: ClassifyUpdateDetail): void;
15
+ export {};
16
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/classification/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE7E,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,oBAAoB,CAAC;CAC9B;AAED,KAAK,qBAAqB,GAAG,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;AAIpE,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,MAAM,IAAI,CAQ/F;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,QAE9E"}
@@ -0,0 +1,18 @@
1
+ const channels = new Map();
2
+ /** Subscribe to classification updates on a named channel. Returns an unsubscribe function. */
3
+ export function subscribeClassify(channelId, handler) {
4
+ if (!channels.has(channelId))
5
+ channels.set(channelId, new Set());
6
+ channels.get(channelId).add(handler);
7
+ return () => {
8
+ const subs = channels.get(channelId);
9
+ subs?.delete(handler);
10
+ if (subs?.size === 0)
11
+ channels.delete(channelId);
12
+ };
13
+ }
14
+ /** Publish a classification update to all subscribers on a named channel. */
15
+ export function publishClassify(channelId, detail) {
16
+ channels.get(channelId)?.forEach((handler) => handler(detail));
17
+ }
18
+ //# sourceMappingURL=channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/classification/channel.ts"],"names":[],"mappings":"AAaA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAsC,CAAC;AAE/D,+FAA+F;AAC/F,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,OAA8B;IACjF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC;QAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,GAAG,EAAE;QACV,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,IAAI,EAAE,IAAI,KAAK,CAAC;YAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,MAA4B;IAC7E,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { GeoJsonFeature } from "../types/geojson.js";
2
+ import type { ClassifyResult, ClassifyStyleOptions } from "../types/style.js";
3
+ /**
4
+ * Creates a {@link StyleFunction} that classifies features by a numeric property
5
+ * and assigns fill colors from a color scheme.
6
+ *
7
+ * @param features - The full set of features (used to compute classification breaks).
8
+ * @param options - Classification configuration.
9
+ * @returns A {@link ClassifyResult} containing the style function, breaks, and colors.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const { styleFunction, breaks, colors } = createClassifyStyle(statesData.features, {
14
+ * property: 'density',
15
+ * method: 'naturalBreaks',
16
+ * numClasses: 5,
17
+ * colorScheme: 'Blues',
18
+ * })
19
+ * geojsonEl.styleFunction = styleFunction
20
+ * legendEl.breaks = breaks
21
+ * legendEl.colors = colors
22
+ * ```
23
+ */
24
+ export declare function createClassifyStyle(features: GeoJsonFeature[], options: ClassifyStyleOptions): ClassifyResult;
25
+ //# sourceMappingURL=classify-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify-style.d.ts","sourceRoot":"","sources":["../../src/classification/classify-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAgB,MAAM,mBAAmB,CAAC;AAI5F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EAAE,EAC1B,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAiDhB"}
@@ -0,0 +1,70 @@
1
+ import { classifyValue, equalInterval, naturalBreaks, quantileBreaks } from "./algorithms.js";
2
+ import { getSchemeColors } from "./color-schemes.js";
3
+ /**
4
+ * Creates a {@link StyleFunction} that classifies features by a numeric property
5
+ * and assigns fill colors from a color scheme.
6
+ *
7
+ * @param features - The full set of features (used to compute classification breaks).
8
+ * @param options - Classification configuration.
9
+ * @returns A {@link ClassifyResult} containing the style function, breaks, and colors.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const { styleFunction, breaks, colors } = createClassifyStyle(statesData.features, {
14
+ * property: 'density',
15
+ * method: 'naturalBreaks',
16
+ * numClasses: 5,
17
+ * colorScheme: 'Blues',
18
+ * })
19
+ * geojsonEl.styleFunction = styleFunction
20
+ * legendEl.breaks = breaks
21
+ * legendEl.colors = colors
22
+ * ```
23
+ */
24
+ export function createClassifyStyle(features, options) {
25
+ const { property, method, numClasses, colorScheme } = options;
26
+ const values = features
27
+ .map((f) => f.properties?.[property])
28
+ .filter((v) => typeof v === "number" && !Number.isNaN(v));
29
+ if (values.length === 0) {
30
+ return { styleFunction: () => undefined, breaks: [], colors: [], property, method };
31
+ }
32
+ let breaks;
33
+ switch (method) {
34
+ case "equalInterval":
35
+ breaks = equalInterval(values, numClasses);
36
+ break;
37
+ case "quantile":
38
+ breaks = quantileBreaks(values, numClasses);
39
+ break;
40
+ case "naturalBreaks":
41
+ breaks = naturalBreaks(values, numClasses);
42
+ break;
43
+ }
44
+ const colors = getSchemeColors(colorScheme, numClasses);
45
+ if (!colors) {
46
+ return { styleFunction: () => undefined, breaks: [], colors: [], property, method };
47
+ }
48
+ const fillOpacity = options.fillOpacity ?? 0.7;
49
+ const styleFunction = (feature) => {
50
+ const value = feature.properties?.[property];
51
+ if (typeof value !== "number" || Number.isNaN(value))
52
+ return undefined;
53
+ const idx = classifyValue(value, breaks);
54
+ if (idx < 0 || idx >= colors.length)
55
+ return undefined;
56
+ const style = {
57
+ fillColor: colors[idx],
58
+ fillOpacity,
59
+ };
60
+ if (options.strokeColor != null)
61
+ style.strokeColor = options.strokeColor;
62
+ if (options.strokeWidth != null)
63
+ style.strokeWidth = options.strokeWidth;
64
+ if (options.strokeOpacity != null)
65
+ style.strokeOpacity = options.strokeOpacity;
66
+ return style;
67
+ };
68
+ return { styleFunction, breaks, colors, property, method };
69
+ }
70
+ //# sourceMappingURL=classify-style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify-style.js","sourceRoot":"","sources":["../../src/classification/classify-style.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAA0B,EAC1B,OAA6B;IAE7B,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAE9D,MAAM,MAAM,GAAG,QAAQ;SACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,Q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AAC;QAEvE,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACzC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM;YAAE,OAAO,SAAS,CAAC;QAEtD,MAAM,KAAK,GAAiB;YAC1B,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC;YACtB,WAAW;SACZ,CAAC;QACF,IAAI,OAAO,CAAC,WAAW,IAAI,IAAI;YAAE,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACzE,IAAI,OAAO,CAAC,WAAW,IAAI,IAAI;YAAE,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACzE,IAAI,OAAO,CAAC,aAAa,IAAI,IAAI;YAAE,KAAK,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC/E,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * ColorBrewer-style color schemes for choropleth mapping.
3
+ * Keyed by scheme name for direct lookup.
4
+ *
5
+ * @see https://colorbrewer2.org
6
+ */
7
+ import type { ColorSchemeType } from "../types/style.js";
8
+ export interface ColorScheme {
9
+ name: string;
10
+ type: ColorSchemeType;
11
+ colors: Record<number, string[]>;
12
+ }
13
+ export declare const colorSchemes: Record<string, ColorScheme>;
14
+ /** Look up a color scheme by name. */
15
+ export declare function getColorScheme(name: string): ColorScheme | undefined;
16
+ /** Get the color array for a scheme at a given class count. */
17
+ export declare function getSchemeColors(name: string, numClasses: number): string[] | undefined;
18
+ //# sourceMappingURL=color-schemes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-schemes.d.ts","sourceRoot":"","sources":["../../src/classification/color-schemes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAClC;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAmLpD,CAAC;AAEF,sCAAsC;AACtC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEpE;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAEtF"}