@classic-homes/maps-core 0.2.8 → 0.2.10
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/dist/{chunk-2NISJ7WE.js → chunk-6WMCIBJJ.js} +41 -194
- package/dist/chunk-EXGGK4H7.js +2822 -0
- package/dist/chunk-ZGUACUEF.js +156 -0
- package/dist/{data-CICLgvT6.d.cts → data-k7o-Rne0.d.cts} +1 -1
- package/dist/{data-CICLgvT6.d.ts → data-k7o-Rne0.d.ts} +1 -1
- package/dist/generator-CGfqiHvG.d.cts +139 -0
- package/dist/generator-CGfqiHvG.d.ts +139 -0
- package/dist/index.d.cts +7 -1481
- package/dist/index.d.ts +7 -1481
- package/dist/index.js +6 -2786
- package/dist/marker-BjzgxVwm.d.ts +1490 -0
- package/dist/marker-zuhH2WoS.d.cts +1490 -0
- package/dist/{spatial-D4ZJ4Ul7.d.ts → spatial-Bo8nM3fC.d.ts} +2 -2
- package/dist/{spatial-D9o4mvDO.d.cts → spatial-CU60awl8.d.cts} +2 -2
- package/dist/theme/index.d.cts +3 -138
- package/dist/theme/index.d.ts +3 -138
- package/dist/theme/index.js +2 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/index.cjs +3078 -0
- package/dist/utils/index.d.cts +50 -0
- package/dist/utils/index.d.ts +50 -0
- package/dist/utils/index.js +2 -0
- package/dist/workers/index.d.cts +2 -2
- package/dist/workers/index.d.ts +2 -2
- package/package.json +9 -1
|
@@ -0,0 +1,1490 @@
|
|
|
1
|
+
import { L as LngLat, G as GeoJSONFeatureCollection, j as MarkerData, M as MapBounds, B as BoundsArray, a as GeoJSONFeature, h as GeoJSONPolygon } from './data-k7o-Rne0.cjs';
|
|
2
|
+
import { M as MapTheme } from './generator-CGfqiHvG.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Accessibility utilities for maps
|
|
6
|
+
*
|
|
7
|
+
* Provides screen reader support and keyboard navigation guidance
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Keyboard controls documentation for screen readers
|
|
12
|
+
*/
|
|
13
|
+
declare const KEYBOARD_CONTROLS: {
|
|
14
|
+
readonly pan: {
|
|
15
|
+
readonly up: "Arrow Up";
|
|
16
|
+
readonly down: "Arrow Down";
|
|
17
|
+
readonly left: "Arrow Left";
|
|
18
|
+
readonly right: "Arrow Right";
|
|
19
|
+
};
|
|
20
|
+
readonly zoom: {
|
|
21
|
+
readonly in: "Plus (+) or Equals (=)";
|
|
22
|
+
readonly out: "Minus (-)";
|
|
23
|
+
};
|
|
24
|
+
readonly rotate: {
|
|
25
|
+
readonly left: "Shift + Arrow Left";
|
|
26
|
+
readonly right: "Shift + Arrow Right";
|
|
27
|
+
};
|
|
28
|
+
readonly pitch: {
|
|
29
|
+
readonly increase: "Shift + Arrow Up";
|
|
30
|
+
readonly decrease: "Shift + Arrow Down";
|
|
31
|
+
};
|
|
32
|
+
readonly reset: {
|
|
33
|
+
readonly bearing: "N key (reset north)";
|
|
34
|
+
readonly view: "R key (reset view)";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Generate a text description of keyboard controls
|
|
39
|
+
*/
|
|
40
|
+
declare function generateKeyboardControlsDescription(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Generate an accessible description for a map
|
|
43
|
+
*/
|
|
44
|
+
declare function generateMapDescription(title: string, options?: {
|
|
45
|
+
center?: LngLat;
|
|
46
|
+
zoom?: number;
|
|
47
|
+
featureCount?: number;
|
|
48
|
+
markerCount?: number;
|
|
49
|
+
layerTypes?: string[];
|
|
50
|
+
}): string;
|
|
51
|
+
/**
|
|
52
|
+
* Generate description for GeoJSON features
|
|
53
|
+
*/
|
|
54
|
+
declare function generateFeatureCollectionDescription(title: string, data: GeoJSONFeatureCollection): string;
|
|
55
|
+
/**
|
|
56
|
+
* Generate description for markers
|
|
57
|
+
*/
|
|
58
|
+
declare function generateMarkersDescription(title: string, markers: MarkerData[]): string;
|
|
59
|
+
/**
|
|
60
|
+
* Generate a hidden data table for screen readers
|
|
61
|
+
*/
|
|
62
|
+
declare function generateFeatureTable(features: GeoJSONFeatureCollection, propertyKeys: string[]): string;
|
|
63
|
+
/**
|
|
64
|
+
* Generate a hidden marker list for screen readers
|
|
65
|
+
*/
|
|
66
|
+
declare function generateMarkerList(markers: MarkerData[]): string;
|
|
67
|
+
/**
|
|
68
|
+
* Generate live region announcement for map changes
|
|
69
|
+
*/
|
|
70
|
+
declare function generateMoveAnnouncement(center: LngLat, zoom: number, action: 'pan' | 'zoom' | 'move'): string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Style utilities for map layers
|
|
74
|
+
*
|
|
75
|
+
* Helper functions for creating MapLibre paint and layout expressions
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Color expression for data-driven styling
|
|
80
|
+
*/
|
|
81
|
+
type ColorExpression = string | unknown[];
|
|
82
|
+
/**
|
|
83
|
+
* Number expression for data-driven styling
|
|
84
|
+
*/
|
|
85
|
+
type NumberExpression = number | unknown[];
|
|
86
|
+
/**
|
|
87
|
+
* Create a solid polygon/fill style
|
|
88
|
+
*/
|
|
89
|
+
declare function createFillStyle(options: {
|
|
90
|
+
color: ColorExpression;
|
|
91
|
+
opacity?: NumberExpression;
|
|
92
|
+
outlineColor?: ColorExpression;
|
|
93
|
+
}): {
|
|
94
|
+
paint: Record<string, unknown>;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Create a line style
|
|
98
|
+
*/
|
|
99
|
+
declare function createLineStyle(options: {
|
|
100
|
+
color: ColorExpression;
|
|
101
|
+
width: NumberExpression;
|
|
102
|
+
opacity?: NumberExpression;
|
|
103
|
+
dashArray?: number[];
|
|
104
|
+
cap?: 'butt' | 'round' | 'square';
|
|
105
|
+
join?: 'bevel' | 'round' | 'miter';
|
|
106
|
+
}): {
|
|
107
|
+
paint: Record<string, unknown>;
|
|
108
|
+
layout: Record<string, unknown>;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Create a circle/point style
|
|
112
|
+
*/
|
|
113
|
+
declare function createCircleStyle(options: {
|
|
114
|
+
radius: NumberExpression;
|
|
115
|
+
color: ColorExpression;
|
|
116
|
+
opacity?: NumberExpression;
|
|
117
|
+
strokeWidth?: NumberExpression;
|
|
118
|
+
strokeColor?: ColorExpression;
|
|
119
|
+
blur?: number;
|
|
120
|
+
}): {
|
|
121
|
+
paint: Record<string, unknown>;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Create a 3D extrusion style for buildings
|
|
125
|
+
*/
|
|
126
|
+
declare function createExtrusionStyle(options: {
|
|
127
|
+
height: NumberExpression;
|
|
128
|
+
baseHeight?: NumberExpression;
|
|
129
|
+
color: ColorExpression;
|
|
130
|
+
opacity?: number;
|
|
131
|
+
verticalGradient?: boolean;
|
|
132
|
+
}): {
|
|
133
|
+
paint: Record<string, unknown>;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Create a heatmap style
|
|
137
|
+
*/
|
|
138
|
+
declare function createHeatmapStyle(options: {
|
|
139
|
+
weight?: NumberExpression;
|
|
140
|
+
intensity?: NumberExpression;
|
|
141
|
+
radius?: NumberExpression;
|
|
142
|
+
opacity?: NumberExpression;
|
|
143
|
+
colorRamp?: string[];
|
|
144
|
+
}): {
|
|
145
|
+
paint: Record<string, unknown>;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Create a hover expression for highlighting features
|
|
149
|
+
*
|
|
150
|
+
* @param baseValue - The default value
|
|
151
|
+
* @param hoverValue - The value when hovered (feature-state hover = true)
|
|
152
|
+
* @param featureStateName - The feature state property name (default: 'hover')
|
|
153
|
+
*/
|
|
154
|
+
declare function createHoverExpression(baseValue: unknown, hoverValue: unknown, featureStateName?: string): unknown[];
|
|
155
|
+
/**
|
|
156
|
+
* Create a selection expression for highlighting selected features
|
|
157
|
+
*/
|
|
158
|
+
declare function createSelectionExpression(baseValue: unknown, selectedValue: unknown, featureStateName?: string): unknown[];
|
|
159
|
+
/**
|
|
160
|
+
* Create a combined hover and selection expression
|
|
161
|
+
*/
|
|
162
|
+
declare function createInteractiveExpression(baseValue: unknown, hoverValue: unknown, selectedValue: unknown): unknown[];
|
|
163
|
+
/**
|
|
164
|
+
* Create a data-driven color expression based on a property
|
|
165
|
+
*
|
|
166
|
+
* @param property - The feature property name
|
|
167
|
+
* @param colorMap - Map of property values to colors
|
|
168
|
+
* @param defaultColor - Default color for unmapped values
|
|
169
|
+
*/
|
|
170
|
+
declare function createCategoricalColorExpression(property: string, colorMap: Record<string, string>, defaultColor: string): unknown[];
|
|
171
|
+
/**
|
|
172
|
+
* Create a continuous color ramp expression
|
|
173
|
+
*
|
|
174
|
+
* @param property - The feature property name
|
|
175
|
+
* @param stops - Array of [value, color] pairs
|
|
176
|
+
* @param interpolation - Interpolation type ('linear', 'exponential', 'cubic-bezier')
|
|
177
|
+
*/
|
|
178
|
+
declare function createContinuousColorExpression(property: string, stops: [number, string][], interpolation?: 'linear' | 'exponential' | ['cubic-bezier', number, number, number, number]): unknown[];
|
|
179
|
+
/**
|
|
180
|
+
* Create a zoom-based interpolation expression
|
|
181
|
+
*
|
|
182
|
+
* @param stops - Array of [zoom, value] pairs
|
|
183
|
+
*/
|
|
184
|
+
declare function createZoomExpression(stops: [number, number][]): unknown[];
|
|
185
|
+
/**
|
|
186
|
+
* Get pre-configured highlight style for the active theme
|
|
187
|
+
*/
|
|
188
|
+
declare function getHighlightStyle(theme?: MapTheme): {
|
|
189
|
+
fill: Record<string, unknown>;
|
|
190
|
+
line: Record<string, unknown>;
|
|
191
|
+
circle: Record<string, unknown>;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Get pre-configured selection style for the active theme
|
|
195
|
+
*/
|
|
196
|
+
declare function getSelectionStyle(theme?: MapTheme): {
|
|
197
|
+
fill: Record<string, unknown>;
|
|
198
|
+
line: Record<string, unknown>;
|
|
199
|
+
circle: Record<string, unknown>;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Options for creating lot fill styles
|
|
203
|
+
*/
|
|
204
|
+
interface LotFillStyleOptions {
|
|
205
|
+
/** Default fill color */
|
|
206
|
+
defaultColor: string;
|
|
207
|
+
/** Color when hovered */
|
|
208
|
+
hoverColor: string;
|
|
209
|
+
/** Color when selected (optional) */
|
|
210
|
+
selectedColor?: string;
|
|
211
|
+
/** Fill opacity (0-1, default: 0.7) */
|
|
212
|
+
opacity?: number;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Create fill + hover style for polygon lots
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* const fillStyle = createLotFillStyle({
|
|
220
|
+
* defaultColor: '#22c55e',
|
|
221
|
+
* hoverColor: '#3b82f6',
|
|
222
|
+
* selectedColor: '#f59e0b',
|
|
223
|
+
* opacity: 0.7,
|
|
224
|
+
* });
|
|
225
|
+
*
|
|
226
|
+
* <FillLayer
|
|
227
|
+
* fillColor={fillStyle['fill-color']}
|
|
228
|
+
* fillOpacity={fillStyle['fill-opacity']}
|
|
229
|
+
* />
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
declare function createLotFillStyle(options: LotFillStyleOptions): {
|
|
233
|
+
'fill-color': unknown[];
|
|
234
|
+
'fill-opacity': number;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Options for creating lot outline styles
|
|
238
|
+
*/
|
|
239
|
+
interface LotOutlineStyleOptions {
|
|
240
|
+
/** Default outline color */
|
|
241
|
+
defaultColor: string;
|
|
242
|
+
/** Color when hovered */
|
|
243
|
+
hoverColor: string;
|
|
244
|
+
/** Color when selected (optional) */
|
|
245
|
+
selectedColor?: string;
|
|
246
|
+
/** Default line width in pixels (default: 1) */
|
|
247
|
+
defaultWidth?: number;
|
|
248
|
+
/** Line width when hovered (default: 2) */
|
|
249
|
+
hoverWidth?: number;
|
|
250
|
+
/** Line width when selected (default: 3) */
|
|
251
|
+
selectedWidth?: number;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create outline style with hover highlighting for polygon lots
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```tsx
|
|
258
|
+
* const outlineStyle = createLotOutlineStyle({
|
|
259
|
+
* defaultColor: '#333',
|
|
260
|
+
* hoverColor: '#1d4ed8',
|
|
261
|
+
* defaultWidth: 1,
|
|
262
|
+
* hoverWidth: 2,
|
|
263
|
+
* });
|
|
264
|
+
*
|
|
265
|
+
* <LineLayer
|
|
266
|
+
* lineColor={outlineStyle['line-color']}
|
|
267
|
+
* lineWidth={outlineStyle['line-width']}
|
|
268
|
+
* />
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function createLotOutlineStyle(options: LotOutlineStyleOptions): {
|
|
272
|
+
'line-color': unknown[];
|
|
273
|
+
'line-width': unknown[];
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Options for creating extrusion height expressions
|
|
277
|
+
*/
|
|
278
|
+
interface ExtrusionHeightOptions {
|
|
279
|
+
/** Scale factor to multiply property value by (default: 1) */
|
|
280
|
+
scale?: number;
|
|
281
|
+
/** Minimum height in meters (default: 0) */
|
|
282
|
+
minHeight?: number;
|
|
283
|
+
/** Maximum height cap in meters (optional) */
|
|
284
|
+
maxHeight?: number;
|
|
285
|
+
/** Default height when property is missing (default: 0) */
|
|
286
|
+
defaultHeight?: number;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Create data-driven extrusion height expression from a feature property
|
|
290
|
+
*
|
|
291
|
+
* This is useful for visualizing property values like price, square footage,
|
|
292
|
+
* or density as 3D heights on a map.
|
|
293
|
+
*
|
|
294
|
+
* @param property - The feature property name to use for height
|
|
295
|
+
* @param options - Configuration options for height calculation
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```tsx
|
|
299
|
+
* // Simple height based on price (scaled down)
|
|
300
|
+
* const heightExpr = createExtrusionHeightExpression('price', {
|
|
301
|
+
* scale: 0.0001, // $100,000 = 10m height
|
|
302
|
+
* minHeight: 5,
|
|
303
|
+
* maxHeight: 100,
|
|
304
|
+
* });
|
|
305
|
+
*
|
|
306
|
+
* <FillExtrusionLayer
|
|
307
|
+
* fillExtrusionHeight={heightExpr}
|
|
308
|
+
* fillExtrusionBase={0}
|
|
309
|
+
* />
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
declare function createExtrusionHeightExpression(property: string, options?: ExtrusionHeightOptions): unknown[];
|
|
313
|
+
/**
|
|
314
|
+
* Create categorical color expression for lot status
|
|
315
|
+
*
|
|
316
|
+
* This creates a match expression that maps status values to colors.
|
|
317
|
+
* Commonly used for real estate lot statuses like available, sold, pending.
|
|
318
|
+
*
|
|
319
|
+
* @param statusColors - Map of status values to colors
|
|
320
|
+
* @param defaultColor - Fallback color for unknown statuses (default: '#888888')
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```tsx
|
|
324
|
+
* const statusColorExpr = createStatusColorExpression({
|
|
325
|
+
* available: '#22c55e', // green
|
|
326
|
+
* pending: '#f59e0b', // amber
|
|
327
|
+
* sold: '#ef4444', // red
|
|
328
|
+
* reserved: '#3b82f6', // blue
|
|
329
|
+
* });
|
|
330
|
+
*
|
|
331
|
+
* <FillLayer fillColor={statusColorExpr} />
|
|
332
|
+
* <FillExtrusionLayer fillExtrusionColor={statusColorExpr} />
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
declare function createStatusColorExpression(statusColors: Record<string, string>, defaultColor?: string): unknown[];
|
|
336
|
+
/**
|
|
337
|
+
* Create a combined status color expression with hover/selection support
|
|
338
|
+
*
|
|
339
|
+
* This creates an expression that:
|
|
340
|
+
* 1. Uses status-based colors for the default state
|
|
341
|
+
* 2. Applies a highlight color on hover
|
|
342
|
+
* 3. Optionally applies a selection color when selected
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```tsx
|
|
346
|
+
* const colorExpr = createInteractiveStatusColorExpression(
|
|
347
|
+
* { available: '#22c55e', sold: '#ef4444' },
|
|
348
|
+
* { hoverColor: '#3b82f6', selectedColor: '#f59e0b' }
|
|
349
|
+
* );
|
|
350
|
+
*
|
|
351
|
+
* <FillLayer fillColor={colorExpr} />
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
declare function createInteractiveStatusColorExpression(statusColors: Record<string, string>, options: {
|
|
355
|
+
hoverColor: string;
|
|
356
|
+
selectedColor?: string;
|
|
357
|
+
defaultColor?: string;
|
|
358
|
+
}): unknown[];
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Formatting utilities for map data
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Format coordinates for display
|
|
366
|
+
*
|
|
367
|
+
* @param coordinates - [lng, lat] coordinate pair
|
|
368
|
+
* @param precision - Decimal places (default: 6)
|
|
369
|
+
* @param format - Output format
|
|
370
|
+
*/
|
|
371
|
+
declare function formatCoordinates(coordinates: LngLat, precision?: number, format?: 'decimal' | 'dms' | 'dd'): string;
|
|
372
|
+
/**
|
|
373
|
+
* Convert decimal degrees to DMS (degrees, minutes, seconds)
|
|
374
|
+
*/
|
|
375
|
+
declare function decimalToDMS(decimal: number, type: 'lat' | 'lng'): string;
|
|
376
|
+
/**
|
|
377
|
+
* Format distance in meters to human-readable string
|
|
378
|
+
*
|
|
379
|
+
* @param meters - Distance in meters
|
|
380
|
+
* @param unit - Unit system
|
|
381
|
+
*/
|
|
382
|
+
declare function formatDistance(meters: number, unit?: 'metric' | 'imperial'): string;
|
|
383
|
+
/**
|
|
384
|
+
* Format area in square meters to human-readable string
|
|
385
|
+
*
|
|
386
|
+
* @param sqMeters - Area in square meters
|
|
387
|
+
* @param unit - Unit system
|
|
388
|
+
*/
|
|
389
|
+
declare function formatArea(sqMeters: number, unit?: 'metric' | 'imperial'): string;
|
|
390
|
+
/**
|
|
391
|
+
* Format a bounding box for display
|
|
392
|
+
*/
|
|
393
|
+
declare function formatBounds(bounds: MapBounds | BoundsArray): string;
|
|
394
|
+
/**
|
|
395
|
+
* Format zoom level for display
|
|
396
|
+
*/
|
|
397
|
+
declare function formatZoom(zoom: number): string;
|
|
398
|
+
/**
|
|
399
|
+
* Format bearing/rotation for display
|
|
400
|
+
*/
|
|
401
|
+
declare function formatBearing(bearing: number): string;
|
|
402
|
+
/**
|
|
403
|
+
* Format pitch/tilt for display
|
|
404
|
+
*/
|
|
405
|
+
declare function formatPitch(pitch: number): string;
|
|
406
|
+
/**
|
|
407
|
+
* Format a scale value for display
|
|
408
|
+
*
|
|
409
|
+
* @param scale - Scale ratio (e.g., 50000 for 1:50,000)
|
|
410
|
+
*/
|
|
411
|
+
declare function formatScale(scale: number): string;
|
|
412
|
+
/**
|
|
413
|
+
* Approximate the scale from zoom level (rough estimate)
|
|
414
|
+
*
|
|
415
|
+
* @param zoom - Map zoom level
|
|
416
|
+
* @param latitude - Latitude (scale varies by latitude)
|
|
417
|
+
*/
|
|
418
|
+
declare function zoomToScale(zoom: number, latitude?: number): number;
|
|
419
|
+
/**
|
|
420
|
+
* Format a property value for display in popups
|
|
421
|
+
*/
|
|
422
|
+
declare function formatPropertyValue(value: unknown): string;
|
|
423
|
+
/**
|
|
424
|
+
* Create a popup content string from feature properties
|
|
425
|
+
*/
|
|
426
|
+
declare function formatFeatureProperties(properties: Record<string, unknown>, options?: {
|
|
427
|
+
exclude?: string[];
|
|
428
|
+
include?: string[];
|
|
429
|
+
labelMap?: Record<string, string>;
|
|
430
|
+
}): string;
|
|
431
|
+
/**
|
|
432
|
+
* Format a property key as a human-readable label
|
|
433
|
+
*/
|
|
434
|
+
declare function formatLabel(key: string): string;
|
|
435
|
+
/**
|
|
436
|
+
* Result of coordinate validation
|
|
437
|
+
*/
|
|
438
|
+
interface CoordinateValidationResult {
|
|
439
|
+
/** Whether the coordinate is valid */
|
|
440
|
+
valid: boolean;
|
|
441
|
+
/** Error message if invalid */
|
|
442
|
+
error?: string;
|
|
443
|
+
/** Normalized coordinate if valid */
|
|
444
|
+
normalized?: LngLat;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Validate a longitude value
|
|
448
|
+
*
|
|
449
|
+
* @param lng - Longitude value to validate
|
|
450
|
+
* @returns true if valid longitude (-180 to 180)
|
|
451
|
+
*/
|
|
452
|
+
declare function isValidLongitude(lng: unknown): lng is number;
|
|
453
|
+
/**
|
|
454
|
+
* Validate a latitude value
|
|
455
|
+
*
|
|
456
|
+
* @param lat - Latitude value to validate
|
|
457
|
+
* @returns true if valid latitude (-90 to 90)
|
|
458
|
+
*/
|
|
459
|
+
declare function isValidLatitude(lat: unknown): lat is number;
|
|
460
|
+
/**
|
|
461
|
+
* Validate a coordinate pair [lng, lat]
|
|
462
|
+
*
|
|
463
|
+
* @param coordinates - Coordinate pair to validate
|
|
464
|
+
* @returns Validation result with error details
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* const result = validateCoordinates([-122.4194, 37.7749]);
|
|
469
|
+
* if (result.valid) {
|
|
470
|
+
* console.log('Valid:', result.normalized);
|
|
471
|
+
* } else {
|
|
472
|
+
* console.error('Invalid:', result.error);
|
|
473
|
+
* }
|
|
474
|
+
* ```
|
|
475
|
+
*/
|
|
476
|
+
declare function validateCoordinates(coordinates: unknown): CoordinateValidationResult;
|
|
477
|
+
/**
|
|
478
|
+
* Validate and normalize coordinates, throwing on invalid input
|
|
479
|
+
*
|
|
480
|
+
* @param coordinates - Coordinate pair to validate
|
|
481
|
+
* @returns Normalized [lng, lat] array
|
|
482
|
+
* @throws Error if coordinates are invalid
|
|
483
|
+
*/
|
|
484
|
+
declare function ensureValidCoordinates(coordinates: unknown): LngLat;
|
|
485
|
+
/**
|
|
486
|
+
* Normalize longitude to [-180, 180] range
|
|
487
|
+
*
|
|
488
|
+
* Handles values that wrap around the antimeridian.
|
|
489
|
+
*
|
|
490
|
+
* @param lng - Longitude value (can be outside -180 to 180)
|
|
491
|
+
* @returns Normalized longitude in [-180, 180]
|
|
492
|
+
*/
|
|
493
|
+
declare function normalizeLongitude(lng: number): number;
|
|
494
|
+
/**
|
|
495
|
+
* Clamp latitude to [-90, 90] range
|
|
496
|
+
*
|
|
497
|
+
* @param lat - Latitude value
|
|
498
|
+
* @returns Clamped latitude in [-90, 90]
|
|
499
|
+
*/
|
|
500
|
+
declare function clampLatitude(lat: number): number;
|
|
501
|
+
/**
|
|
502
|
+
* Validate a bounds array [[sw_lng, sw_lat], [ne_lng, ne_lat]]
|
|
503
|
+
*
|
|
504
|
+
* @param bounds - Bounds array to validate
|
|
505
|
+
* @returns Validation result with error details
|
|
506
|
+
*/
|
|
507
|
+
declare function validateBoundsArray(bounds: unknown): {
|
|
508
|
+
valid: boolean;
|
|
509
|
+
error?: string;
|
|
510
|
+
normalized?: BoundsArray;
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Bounds calculation utilities for GeoJSON data
|
|
515
|
+
*/
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Calculate bounds from GeoJSON data
|
|
519
|
+
* @param geojson - GeoJSON FeatureCollection or Feature
|
|
520
|
+
* @returns BoundsArray [[sw_lng, sw_lat], [ne_lng, ne_lat]] or null if no valid coordinates
|
|
521
|
+
*/
|
|
522
|
+
declare function calculateBounds(geojson: GeoJSONFeatureCollection | GeoJSONFeature): BoundsArray | null;
|
|
523
|
+
/**
|
|
524
|
+
* Extend bounds to include a new point
|
|
525
|
+
* @param bounds - Existing bounds
|
|
526
|
+
* @param point - Point to include [lng, lat]
|
|
527
|
+
* @returns Extended bounds
|
|
528
|
+
*/
|
|
529
|
+
declare function extendBounds(bounds: BoundsArray, point: LngLat): BoundsArray;
|
|
530
|
+
/**
|
|
531
|
+
* Combine two bounds into one that encompasses both
|
|
532
|
+
* @param bounds1 - First bounds
|
|
533
|
+
* @param bounds2 - Second bounds
|
|
534
|
+
* @returns Combined bounds
|
|
535
|
+
*/
|
|
536
|
+
declare function combineBounds(bounds1: BoundsArray, bounds2: BoundsArray): BoundsArray;
|
|
537
|
+
/**
|
|
538
|
+
* Validate that bounds are properly formed
|
|
539
|
+
* @param bounds - Bounds to validate
|
|
540
|
+
* @returns True if bounds are valid
|
|
541
|
+
*/
|
|
542
|
+
declare function isValidBounds(bounds: BoundsArray): boolean;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Data loading and validation utilities for GeoJSON
|
|
546
|
+
*/
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Options for loading GeoJSON data
|
|
550
|
+
*/
|
|
551
|
+
interface LoadGeoJSONOptions {
|
|
552
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
553
|
+
timeout?: number;
|
|
554
|
+
/** Additional fetch options */
|
|
555
|
+
fetchOptions?: RequestInit;
|
|
556
|
+
/** Validate the GeoJSON structure after loading */
|
|
557
|
+
validate?: boolean;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Result of loading GeoJSON data
|
|
561
|
+
*/
|
|
562
|
+
interface LoadGeoJSONResult<T = GeoJSONFeatureCollection> {
|
|
563
|
+
/** The loaded data (null if error) */
|
|
564
|
+
data: T | null;
|
|
565
|
+
/** Error message if loading failed */
|
|
566
|
+
error: string | null;
|
|
567
|
+
/** Whether the request was successful */
|
|
568
|
+
success: boolean;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* GeoJSON validation result
|
|
572
|
+
*/
|
|
573
|
+
interface ValidationResult {
|
|
574
|
+
/** Whether the GeoJSON is valid */
|
|
575
|
+
valid: boolean;
|
|
576
|
+
/** List of validation errors */
|
|
577
|
+
errors: string[];
|
|
578
|
+
/** Number of features (if FeatureCollection) */
|
|
579
|
+
featureCount?: number;
|
|
580
|
+
/** Geometry types found */
|
|
581
|
+
geometryTypes?: string[];
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Load GeoJSON data from a URL
|
|
585
|
+
* @param url - URL to fetch GeoJSON from
|
|
586
|
+
* @param options - Loading options
|
|
587
|
+
* @returns Promise with load result
|
|
588
|
+
*/
|
|
589
|
+
declare function loadGeoJSON<T = GeoJSONFeatureCollection>(url: string, options?: LoadGeoJSONOptions): Promise<LoadGeoJSONResult<T>>;
|
|
590
|
+
/**
|
|
591
|
+
* Validate GeoJSON structure
|
|
592
|
+
* @param data - Data to validate
|
|
593
|
+
* @returns Validation result
|
|
594
|
+
*/
|
|
595
|
+
declare function validateGeoJSON(data: unknown): ValidationResult;
|
|
596
|
+
/**
|
|
597
|
+
* Calculate the centroid of a GeoJSON FeatureCollection or Feature
|
|
598
|
+
* @param geojson - GeoJSON data
|
|
599
|
+
* @returns Centroid as [lng, lat] or null if no coordinates
|
|
600
|
+
*/
|
|
601
|
+
declare function calculateCentroid(geojson: GeoJSONFeatureCollection | GeoJSONFeature): [number, number] | null;
|
|
602
|
+
/**
|
|
603
|
+
* Count features by geometry type in a FeatureCollection
|
|
604
|
+
* @param geojson - GeoJSON FeatureCollection
|
|
605
|
+
* @returns Object with geometry types as keys and counts as values
|
|
606
|
+
*/
|
|
607
|
+
declare function countFeaturesByType(geojson: GeoJSONFeatureCollection): Record<string, number>;
|
|
608
|
+
/**
|
|
609
|
+
* Filter features by geometry type
|
|
610
|
+
* @param geojson - GeoJSON FeatureCollection
|
|
611
|
+
* @param types - Geometry types to include
|
|
612
|
+
* @returns Filtered FeatureCollection
|
|
613
|
+
*/
|
|
614
|
+
declare function filterByGeometryType(geojson: GeoJSONFeatureCollection, types: string[]): GeoJSONFeatureCollection;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Cluster utilities for MapLibre GL
|
|
618
|
+
*
|
|
619
|
+
* These utilities help with common clustering operations like
|
|
620
|
+
* expanding clusters on click and getting cluster information.
|
|
621
|
+
*/
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Interface representing a GeoJSON source with clustering capabilities
|
|
625
|
+
*/
|
|
626
|
+
interface ClusterableGeoJSONSource {
|
|
627
|
+
/** Get the zoom level at which a cluster expands */
|
|
628
|
+
getClusterExpansionZoom: (clusterId: number) => Promise<number>;
|
|
629
|
+
/** Get immediate children of a cluster (may be points or sub-clusters) */
|
|
630
|
+
getClusterChildren: (clusterId: number) => Promise<GeoJSONFeature[]>;
|
|
631
|
+
/** Get all leaf features (individual points) of a cluster */
|
|
632
|
+
getClusterLeaves: (clusterId: number, limit: number, offset: number) => Promise<GeoJSONFeature[]>;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Minimal map interface for cluster read operations
|
|
636
|
+
*
|
|
637
|
+
* Note: getSource returns unknown to be compatible with MapLibre's Source type.
|
|
638
|
+
* The actual clustering methods are validated at runtime.
|
|
639
|
+
*/
|
|
640
|
+
interface ClusterMapReader {
|
|
641
|
+
/** Get a source by ID - returns unknown for compatibility with MapLibre types */
|
|
642
|
+
getSource: (id: string) => unknown;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Map interface for cluster expansion with easeTo
|
|
646
|
+
*/
|
|
647
|
+
interface ClusterMapExpander extends ClusterMapReader {
|
|
648
|
+
/** Animate the map to a new center/zoom */
|
|
649
|
+
easeTo: (options: {
|
|
650
|
+
center: [number, number];
|
|
651
|
+
zoom: number;
|
|
652
|
+
duration?: number;
|
|
653
|
+
animate?: boolean;
|
|
654
|
+
padding?: number | {
|
|
655
|
+
top: number;
|
|
656
|
+
bottom: number;
|
|
657
|
+
left: number;
|
|
658
|
+
right: number;
|
|
659
|
+
};
|
|
660
|
+
}) => void;
|
|
661
|
+
/** Get current zoom level */
|
|
662
|
+
getZoom: () => number;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Map interface for cluster expansion with fitBounds
|
|
666
|
+
*/
|
|
667
|
+
interface ClusterMapBoundsExpander extends ClusterMapReader {
|
|
668
|
+
/** Fit the map to bounds */
|
|
669
|
+
fitBounds: (bounds: BoundsArray, options?: {
|
|
670
|
+
padding?: number | {
|
|
671
|
+
top: number;
|
|
672
|
+
bottom: number;
|
|
673
|
+
left: number;
|
|
674
|
+
right: number;
|
|
675
|
+
};
|
|
676
|
+
duration?: number;
|
|
677
|
+
animate?: boolean;
|
|
678
|
+
maxZoom?: number;
|
|
679
|
+
}) => void;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Properties automatically added to cluster features by MapLibre GL
|
|
683
|
+
*/
|
|
684
|
+
interface ClusterFeatureProperties extends Record<string, unknown> {
|
|
685
|
+
/** Unique cluster identifier */
|
|
686
|
+
cluster_id: number;
|
|
687
|
+
/** Number of points in the cluster */
|
|
688
|
+
point_count: number;
|
|
689
|
+
/** Abbreviated point count (e.g., "1.2k") */
|
|
690
|
+
point_count_abbreviated: string;
|
|
691
|
+
/** Whether this is a cluster */
|
|
692
|
+
cluster: true;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Type guard to check if a feature is a cluster
|
|
696
|
+
*/
|
|
697
|
+
declare function isClusterFeature(feature: {
|
|
698
|
+
properties?: Record<string, unknown> | null;
|
|
699
|
+
}): feature is {
|
|
700
|
+
properties: ClusterFeatureProperties;
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* Options for cluster expansion
|
|
704
|
+
*/
|
|
705
|
+
interface ClusterExpandOptions {
|
|
706
|
+
/** Animation duration in milliseconds (default: 500) */
|
|
707
|
+
duration?: number;
|
|
708
|
+
/** Whether to animate the transition (default: true) */
|
|
709
|
+
animate?: boolean;
|
|
710
|
+
/** Padding around the expanded cluster bounds */
|
|
711
|
+
padding?: number | {
|
|
712
|
+
top: number;
|
|
713
|
+
bottom: number;
|
|
714
|
+
left: number;
|
|
715
|
+
right: number;
|
|
716
|
+
};
|
|
717
|
+
/** Maximum zoom level to expand to */
|
|
718
|
+
maxZoom?: number;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Result of getting cluster expansion zoom
|
|
722
|
+
*/
|
|
723
|
+
interface ClusterExpansionResult {
|
|
724
|
+
/** The zoom level needed to expand the cluster */
|
|
725
|
+
zoom: number;
|
|
726
|
+
/** The cluster's center coordinates */
|
|
727
|
+
center: LngLat;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Get the zoom level needed to expand a cluster
|
|
731
|
+
*
|
|
732
|
+
* This is a wrapper around MapLibre GL's getClusterExpansionZoom method
|
|
733
|
+
* that provides a cleaner async interface.
|
|
734
|
+
*
|
|
735
|
+
* @param map - MapLibre GL map instance (or any object with getSource method)
|
|
736
|
+
* @param sourceId - ID of the GeoJSON source with clustering enabled
|
|
737
|
+
* @param clusterId - The cluster_id from the cluster feature properties
|
|
738
|
+
* @returns Promise resolving to the expansion zoom level
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* const zoom = await getClusterExpansionZoom(map, 'points', clusterId);
|
|
743
|
+
* map.easeTo({ center: clusterCoords, zoom });
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
declare function getClusterExpansionZoom(map: ClusterMapReader, sourceId: string, clusterId: number): Promise<number>;
|
|
747
|
+
/**
|
|
748
|
+
* Get the children features of a cluster
|
|
749
|
+
*
|
|
750
|
+
* Returns the immediate children of a cluster, which may be
|
|
751
|
+
* individual points or other clusters.
|
|
752
|
+
*
|
|
753
|
+
* @param map - MapLibre GL map instance (or any object with getSource method)
|
|
754
|
+
* @param sourceId - ID of the GeoJSON source with clustering enabled
|
|
755
|
+
* @param clusterId - The cluster_id from the cluster feature properties
|
|
756
|
+
* @returns Promise resolving to an array of child features
|
|
757
|
+
*/
|
|
758
|
+
declare function getClusterChildren(map: ClusterMapReader, sourceId: string, clusterId: number): Promise<GeoJSONFeature[]>;
|
|
759
|
+
/**
|
|
760
|
+
* Get all leaf features (individual points) of a cluster
|
|
761
|
+
*
|
|
762
|
+
* Returns all individual points contained within a cluster,
|
|
763
|
+
* regardless of nesting level.
|
|
764
|
+
*
|
|
765
|
+
* @param map - MapLibre GL map instance (or any object with getSource method)
|
|
766
|
+
* @param sourceId - ID of the GeoJSON source with clustering enabled
|
|
767
|
+
* @param clusterId - The cluster_id from the cluster feature properties
|
|
768
|
+
* @param limit - Maximum number of features to return (default: 100)
|
|
769
|
+
* @param offset - Offset for pagination (default: 0)
|
|
770
|
+
* @returns Promise resolving to an array of leaf features
|
|
771
|
+
*/
|
|
772
|
+
declare function getClusterLeaves(map: ClusterMapReader, sourceId: string, clusterId: number, limit?: number, offset?: number): Promise<GeoJSONFeature[]>;
|
|
773
|
+
/**
|
|
774
|
+
* Expand a cluster by zooming in to show its contents
|
|
775
|
+
*
|
|
776
|
+
* This is the main utility for handling cluster click-to-expand behavior.
|
|
777
|
+
* It gets the expansion zoom level and animates the map to that zoom.
|
|
778
|
+
*
|
|
779
|
+
* @param map - MapLibre GL map instance with easeTo method
|
|
780
|
+
* @param sourceId - ID of the GeoJSON source with clustering enabled
|
|
781
|
+
* @param clusterId - The cluster_id from the cluster feature properties
|
|
782
|
+
* @param center - The cluster's center coordinates [lng, lat]
|
|
783
|
+
* @param options - Animation and zoom options
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* ```typescript
|
|
787
|
+
* // In a cluster click handler:
|
|
788
|
+
* function handleClusterClick(e) {
|
|
789
|
+
* const { cluster_id } = e.feature.properties;
|
|
790
|
+
* const [lng, lat] = e.feature.geometry.coordinates;
|
|
791
|
+
* expandCluster(map, 'points-source', cluster_id, [lng, lat]);
|
|
792
|
+
* }
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
declare function expandCluster(map: ClusterMapExpander, sourceId: string, clusterId: number, center: LngLat, options?: ClusterExpandOptions): Promise<void>;
|
|
796
|
+
/**
|
|
797
|
+
* Calculate bounds that encompass all leaves of a cluster
|
|
798
|
+
*
|
|
799
|
+
* Useful for fitting the map to show all points in a cluster.
|
|
800
|
+
*
|
|
801
|
+
* @param map - MapLibre GL map instance (or any object with getSource method)
|
|
802
|
+
* @param sourceId - ID of the GeoJSON source with clustering enabled
|
|
803
|
+
* @param clusterId - The cluster_id from the cluster feature properties
|
|
804
|
+
* @param limit - Maximum number of leaves to consider (default: 1000)
|
|
805
|
+
* @returns Promise resolving to bounds array [[sw_lng, sw_lat], [ne_lng, ne_lat]]
|
|
806
|
+
*/
|
|
807
|
+
declare function getClusterBounds(map: ClusterMapReader, sourceId: string, clusterId: number, limit?: number): Promise<BoundsArray>;
|
|
808
|
+
/**
|
|
809
|
+
* Expand a cluster by fitting to the bounds of its leaves
|
|
810
|
+
*
|
|
811
|
+
* Alternative to expandCluster that zooms to fit all points
|
|
812
|
+
* rather than using the expansion zoom level.
|
|
813
|
+
*
|
|
814
|
+
* @param map - MapLibre GL map instance with fitBounds method
|
|
815
|
+
* @param sourceId - ID of the GeoJSON source with clustering enabled
|
|
816
|
+
* @param clusterId - The cluster_id from the cluster feature properties
|
|
817
|
+
* @param options - Animation and padding options
|
|
818
|
+
*/
|
|
819
|
+
declare function expandClusterToBounds(map: ClusterMapBoundsExpander, sourceId: string, clusterId: number, options?: ClusterExpandOptions): Promise<void>;
|
|
820
|
+
/**
|
|
821
|
+
* Options for cluster circle layer style
|
|
822
|
+
*/
|
|
823
|
+
interface ClusterCircleStyleOptions {
|
|
824
|
+
/** Base color for small clusters (default: '#51bbd6') */
|
|
825
|
+
smallColor?: string;
|
|
826
|
+
/** Color for medium clusters (default: '#f1f075') */
|
|
827
|
+
mediumColor?: string;
|
|
828
|
+
/** Color for large clusters (default: '#f28cb1') */
|
|
829
|
+
largeColor?: string;
|
|
830
|
+
/** Point count threshold for medium size (default: 100) */
|
|
831
|
+
mediumThreshold?: number;
|
|
832
|
+
/** Point count threshold for large size (default: 750) */
|
|
833
|
+
largeThreshold?: number;
|
|
834
|
+
/** Base radius for small clusters (default: 20) */
|
|
835
|
+
smallRadius?: number;
|
|
836
|
+
/** Radius for medium clusters (default: 30) */
|
|
837
|
+
mediumRadius?: number;
|
|
838
|
+
/** Radius for large clusters (default: 40) */
|
|
839
|
+
largeRadius?: number;
|
|
840
|
+
/** Circle stroke color (default: '#fff') */
|
|
841
|
+
strokeColor?: string;
|
|
842
|
+
/** Circle stroke width (default: 2) */
|
|
843
|
+
strokeWidth?: number;
|
|
844
|
+
/** Circle opacity (default: 0.85) */
|
|
845
|
+
opacity?: number;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Options for cluster text layer style
|
|
849
|
+
*/
|
|
850
|
+
interface ClusterTextStyleOptions {
|
|
851
|
+
/** Text color (default: '#333') */
|
|
852
|
+
textColor?: string;
|
|
853
|
+
/** Text size (default: 12) */
|
|
854
|
+
textSize?: number;
|
|
855
|
+
/** Font stack (default: ['Open Sans Bold', 'Arial Unicode MS Bold']) */
|
|
856
|
+
fontStack?: string[];
|
|
857
|
+
/** Whether to use abbreviated count (e.g., "1.2k") (default: false) */
|
|
858
|
+
abbreviated?: boolean;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Options for unclustered point layer style
|
|
862
|
+
*/
|
|
863
|
+
interface UnclusteredPointStyleOptions {
|
|
864
|
+
/** Point color (default: '#11b4da') */
|
|
865
|
+
color?: string;
|
|
866
|
+
/** Point radius (default: 8) */
|
|
867
|
+
radius?: number;
|
|
868
|
+
/** Stroke color (default: '#fff') */
|
|
869
|
+
strokeColor?: string;
|
|
870
|
+
/** Stroke width (default: 1) */
|
|
871
|
+
strokeWidth?: number;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Complete cluster layer styles returned by createClusterStyles
|
|
875
|
+
*/
|
|
876
|
+
interface ClusterLayerStyles {
|
|
877
|
+
/** Paint properties for the cluster circle layer */
|
|
878
|
+
clusterCirclePaint: Record<string, unknown>;
|
|
879
|
+
/** Paint properties for the cluster text layer */
|
|
880
|
+
clusterTextPaint: Record<string, unknown>;
|
|
881
|
+
/** Layout properties for the cluster text layer */
|
|
882
|
+
clusterTextLayout: Record<string, unknown>;
|
|
883
|
+
/** Paint properties for the unclustered point layer */
|
|
884
|
+
unclusteredPointPaint: Record<string, unknown>;
|
|
885
|
+
/** Filter for cluster layers (only clusters) */
|
|
886
|
+
clusterFilter: unknown[];
|
|
887
|
+
/** Filter for unclustered point layer (only non-clusters) */
|
|
888
|
+
unclusteredFilter: unknown[];
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Creates complete layer styles for rendering clusters
|
|
892
|
+
*
|
|
893
|
+
* Returns paint/layout properties and filters that can be used with
|
|
894
|
+
* CircleLayer and SymbolLayer components.
|
|
895
|
+
*
|
|
896
|
+
* @param options - Customization options for colors, sizes, etc.
|
|
897
|
+
* @returns Object containing all necessary styles and filters
|
|
898
|
+
*
|
|
899
|
+
* @example
|
|
900
|
+
* ```tsx
|
|
901
|
+
* const styles = createClusterStyles({
|
|
902
|
+
* smallColor: '#3b82f6',
|
|
903
|
+
* mediumColor: '#f59e0b',
|
|
904
|
+
* largeColor: '#ef4444',
|
|
905
|
+
* });
|
|
906
|
+
*
|
|
907
|
+
* <Source id="points" type="geojson" data={data} cluster={true}>
|
|
908
|
+
* <CircleLayer
|
|
909
|
+
* id="clusters"
|
|
910
|
+
* filter={styles.clusterFilter}
|
|
911
|
+
* paint={styles.clusterCirclePaint}
|
|
912
|
+
* />
|
|
913
|
+
* <SymbolLayer
|
|
914
|
+
* id="cluster-count"
|
|
915
|
+
* filter={styles.clusterFilter}
|
|
916
|
+
* paint={styles.clusterTextPaint}
|
|
917
|
+
* layout={styles.clusterTextLayout}
|
|
918
|
+
* />
|
|
919
|
+
* <CircleLayer
|
|
920
|
+
* id="unclustered-point"
|
|
921
|
+
* filter={styles.unclusteredFilter}
|
|
922
|
+
* paint={styles.unclusteredPointPaint}
|
|
923
|
+
* />
|
|
924
|
+
* </Source>
|
|
925
|
+
* ```
|
|
926
|
+
*/
|
|
927
|
+
declare function createClusterStyles(options?: {
|
|
928
|
+
circle?: ClusterCircleStyleOptions;
|
|
929
|
+
text?: ClusterTextStyleOptions;
|
|
930
|
+
unclusteredPoint?: UnclusteredPointStyleOptions;
|
|
931
|
+
}): ClusterLayerStyles;
|
|
932
|
+
/**
|
|
933
|
+
* Creates a simple cluster circle paint style with stepped colors and sizes
|
|
934
|
+
*
|
|
935
|
+
* @param options - Customization options
|
|
936
|
+
* @returns Paint properties for a circle layer
|
|
937
|
+
*
|
|
938
|
+
* @example
|
|
939
|
+
* ```tsx
|
|
940
|
+
* <CircleLayer
|
|
941
|
+
* id="clusters"
|
|
942
|
+
* filter={['has', 'point_count']}
|
|
943
|
+
* paint={createClusterCirclePaint({ smallColor: '#3b82f6' })}
|
|
944
|
+
* />
|
|
945
|
+
* ```
|
|
946
|
+
*/
|
|
947
|
+
declare function createClusterCirclePaint(options?: ClusterCircleStyleOptions): Record<string, unknown>;
|
|
948
|
+
/**
|
|
949
|
+
* Creates cluster count text layout properties
|
|
950
|
+
*
|
|
951
|
+
* @param options - Customization options
|
|
952
|
+
* @returns Layout properties for a symbol layer
|
|
953
|
+
*/
|
|
954
|
+
declare function createClusterTextLayout(options?: ClusterTextStyleOptions): Record<string, unknown>;
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Level-of-Detail (LOD) utilities for efficient rendering of large polygon datasets
|
|
958
|
+
*
|
|
959
|
+
* These utilities help manage rendering performance by:
|
|
960
|
+
* 1. Grouping features by hierarchy (community > filing > lot)
|
|
961
|
+
* 2. Generating boundary polygons for groups when not provided
|
|
962
|
+
* 3. Supporting zoom-based visibility switching
|
|
963
|
+
*/
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Options for grouping features
|
|
967
|
+
*/
|
|
968
|
+
interface GroupFeaturesOptions {
|
|
969
|
+
/** Property name to group by */
|
|
970
|
+
groupBy: string;
|
|
971
|
+
/** Optional nested grouping property */
|
|
972
|
+
subGroupBy?: string;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* A group of features with computed metadata
|
|
976
|
+
*/
|
|
977
|
+
interface FeatureGroup {
|
|
978
|
+
/** Group identifier (property value) */
|
|
979
|
+
id: string;
|
|
980
|
+
/** Features in this group */
|
|
981
|
+
features: GeoJSONFeature[];
|
|
982
|
+
/** Bounds of all features in group */
|
|
983
|
+
bounds: BoundsArray | null;
|
|
984
|
+
/** Centroid of the group */
|
|
985
|
+
centroid: LngLat | null;
|
|
986
|
+
/** Total count of features */
|
|
987
|
+
count: number;
|
|
988
|
+
/** Sub-groups if nested grouping was used */
|
|
989
|
+
subGroups?: Map<string, FeatureGroup>;
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Group GeoJSON features by a property value
|
|
993
|
+
*
|
|
994
|
+
* @example
|
|
995
|
+
* ```ts
|
|
996
|
+
* const groups = groupFeaturesByProperty(lotsData, {
|
|
997
|
+
* groupBy: 'community',
|
|
998
|
+
* subGroupBy: 'filing',
|
|
999
|
+
* });
|
|
1000
|
+
*
|
|
1001
|
+
* // Access groups
|
|
1002
|
+
* groups.forEach((group, communityId) => {
|
|
1003
|
+
* console.log(`Community ${communityId}: ${group.count} lots`);
|
|
1004
|
+
* group.subGroups?.forEach((subGroup, filingId) => {
|
|
1005
|
+
* console.log(` Filing ${filingId}: ${subGroup.count} lots`);
|
|
1006
|
+
* });
|
|
1007
|
+
* });
|
|
1008
|
+
* ```
|
|
1009
|
+
*/
|
|
1010
|
+
declare function groupFeaturesByProperty(geojson: GeoJSONFeatureCollection, options: GroupFeaturesOptions): Map<string, FeatureGroup>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Generate a convex hull polygon from a set of features
|
|
1013
|
+
*
|
|
1014
|
+
* Uses the gift wrapping algorithm for simplicity
|
|
1015
|
+
*/
|
|
1016
|
+
declare function generateConvexHull(features: GeoJSONFeature[]): GeoJSONPolygon | null;
|
|
1017
|
+
/**
|
|
1018
|
+
* Generate a bounding box polygon from features
|
|
1019
|
+
* Simpler alternative to convex hull
|
|
1020
|
+
*/
|
|
1021
|
+
declare function generateBoundingPolygon(features: GeoJSONFeature[], padding?: number): GeoJSONPolygon | null;
|
|
1022
|
+
/**
|
|
1023
|
+
* Convert bounds to a polygon
|
|
1024
|
+
*/
|
|
1025
|
+
declare function boundsToPolygon(bounds: BoundsArray, padding?: number): GeoJSONPolygon;
|
|
1026
|
+
/**
|
|
1027
|
+
* Simplify a GeoJSON polygon geometry
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```ts
|
|
1031
|
+
* const simplified = simplifyPolygon(polygon, 0.0001);
|
|
1032
|
+
* console.log(`Reduced from ${original.coordinates[0].length} to ${simplified.coordinates[0].length} points`);
|
|
1033
|
+
* ```
|
|
1034
|
+
*/
|
|
1035
|
+
declare function simplifyPolygon(polygon: GeoJSONPolygon, tolerance: number): GeoJSONPolygon;
|
|
1036
|
+
/**
|
|
1037
|
+
* Simplify a GeoJSON feature's geometry
|
|
1038
|
+
*
|
|
1039
|
+
* Supports Point, Polygon, and MultiPolygon geometries.
|
|
1040
|
+
* Points are returned unchanged. Lines could be added if needed.
|
|
1041
|
+
*/
|
|
1042
|
+
declare function simplifyFeature(feature: GeoJSONFeature, tolerance: number): GeoJSONFeature;
|
|
1043
|
+
/**
|
|
1044
|
+
* Simplify all features in a GeoJSON FeatureCollection
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* ```ts
|
|
1048
|
+
* const simplified = simplifyFeatureCollection(features, 0.0001);
|
|
1049
|
+
* // Polygon vertices reduced by ~50-80%
|
|
1050
|
+
* ```
|
|
1051
|
+
*/
|
|
1052
|
+
declare function simplifyFeatureCollection(collection: GeoJSONFeatureCollection, tolerance: number): GeoJSONFeatureCollection;
|
|
1053
|
+
/**
|
|
1054
|
+
* Calculate simplification statistics
|
|
1055
|
+
*/
|
|
1056
|
+
interface SimplificationStats {
|
|
1057
|
+
/** Original total vertex count */
|
|
1058
|
+
originalVertices: number;
|
|
1059
|
+
/** Simplified total vertex count */
|
|
1060
|
+
simplifiedVertices: number;
|
|
1061
|
+
/** Percentage of vertices removed */
|
|
1062
|
+
reductionPercent: number;
|
|
1063
|
+
/** Number of features processed */
|
|
1064
|
+
featureCount: number;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Simplify a feature collection and return with statistics
|
|
1068
|
+
*/
|
|
1069
|
+
declare function simplifyFeatureCollectionWithStats(collection: GeoJSONFeatureCollection, tolerance: number): {
|
|
1070
|
+
data: GeoJSONFeatureCollection;
|
|
1071
|
+
stats: SimplificationStats;
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* Simplification threshold configuration
|
|
1075
|
+
*/
|
|
1076
|
+
interface SimplificationThreshold {
|
|
1077
|
+
/** Maximum zoom level to apply this simplification */
|
|
1078
|
+
maxZoom: number;
|
|
1079
|
+
/** Tolerance in degrees - higher = more simplification */
|
|
1080
|
+
tolerance: number;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Options for generating LOD data
|
|
1084
|
+
*/
|
|
1085
|
+
interface GenerateLODOptions {
|
|
1086
|
+
/** Property to group by at the top level (e.g., 'community') */
|
|
1087
|
+
groupBy: string;
|
|
1088
|
+
/** Property to group by at the second level (e.g., 'filing') */
|
|
1089
|
+
subGroupBy?: string;
|
|
1090
|
+
/** Pre-provided boundary for top-level groups (keyed by group ID) */
|
|
1091
|
+
groupBoundaries?: Map<string, GeoJSONPolygon>;
|
|
1092
|
+
/** Pre-provided boundary for sub-groups (keyed by "groupId:subGroupId") */
|
|
1093
|
+
subGroupBoundaries?: Map<string, GeoJSONPolygon>;
|
|
1094
|
+
/** Use convex hull (true) or bounding box (false) for auto-generated boundaries */
|
|
1095
|
+
useConvexHull?: boolean;
|
|
1096
|
+
/** Padding to add around auto-generated bounding boxes (in degrees) */
|
|
1097
|
+
boundaryPadding?: number;
|
|
1098
|
+
/** Additional properties to aggregate for group features */
|
|
1099
|
+
aggregateProperties?: string[];
|
|
1100
|
+
/**
|
|
1101
|
+
* Simplification thresholds for reducing polygon complexity at lower zoom levels
|
|
1102
|
+
* @example [{ maxZoom: 12, tolerance: 0.0001 }, { maxZoom: 10, tolerance: 0.0005 }]
|
|
1103
|
+
*/
|
|
1104
|
+
simplificationThresholds?: SimplificationThreshold[];
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Result of LOD generation
|
|
1108
|
+
*/
|
|
1109
|
+
interface LODData {
|
|
1110
|
+
/** Top-level group boundaries (communities) */
|
|
1111
|
+
groupBoundaries: GeoJSONFeatureCollection;
|
|
1112
|
+
/** Second-level group boundaries (filings) */
|
|
1113
|
+
subGroupBoundaries: GeoJSONFeatureCollection | null;
|
|
1114
|
+
/** Original features with group info */
|
|
1115
|
+
features: GeoJSONFeatureCollection;
|
|
1116
|
+
/** Recommended zoom thresholds */
|
|
1117
|
+
zoomThresholds: {
|
|
1118
|
+
/** Show groups below this zoom */
|
|
1119
|
+
groupMaxZoom: number;
|
|
1120
|
+
/** Show sub-groups between groupMaxZoom and this */
|
|
1121
|
+
subGroupMaxZoom: number;
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Generate Level-of-Detail data from a feature collection
|
|
1126
|
+
*
|
|
1127
|
+
* Creates boundary polygons for each group level that can be shown
|
|
1128
|
+
* at different zoom levels for better performance.
|
|
1129
|
+
*
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```tsx
|
|
1132
|
+
* const lodData = generateLODData(lotsData, {
|
|
1133
|
+
* groupBy: 'community',
|
|
1134
|
+
* subGroupBy: 'filing',
|
|
1135
|
+
* useConvexHull: true,
|
|
1136
|
+
* });
|
|
1137
|
+
*
|
|
1138
|
+
* // Use in map
|
|
1139
|
+
* <Source id="communities" data={lodData.groupBoundaries} />
|
|
1140
|
+
* <FillLayer
|
|
1141
|
+
* id="communities-fill"
|
|
1142
|
+
* source="communities"
|
|
1143
|
+
* maxZoom={lodData.zoomThresholds.groupMaxZoom}
|
|
1144
|
+
* />
|
|
1145
|
+
*
|
|
1146
|
+
* <Source id="filings" data={lodData.subGroupBoundaries} />
|
|
1147
|
+
* <FillLayer
|
|
1148
|
+
* id="filings-fill"
|
|
1149
|
+
* source="filings"
|
|
1150
|
+
* minZoom={lodData.zoomThresholds.groupMaxZoom}
|
|
1151
|
+
* maxZoom={lodData.zoomThresholds.subGroupMaxZoom}
|
|
1152
|
+
* />
|
|
1153
|
+
*
|
|
1154
|
+
* <Source id="lots" data={lodData.features} />
|
|
1155
|
+
* <FillLayer
|
|
1156
|
+
* id="lots-fill"
|
|
1157
|
+
* source="lots"
|
|
1158
|
+
* minZoom={lodData.zoomThresholds.subGroupMaxZoom}
|
|
1159
|
+
* />
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
declare function generateLODData(geojson: GeoJSONFeatureCollection, options: GenerateLODOptions): LODData;
|
|
1163
|
+
/**
|
|
1164
|
+
* Extended LOD data with pre-simplified versions
|
|
1165
|
+
*/
|
|
1166
|
+
interface LODDataWithSimplification extends LODData {
|
|
1167
|
+
/** Simplified versions of features for different zoom levels */
|
|
1168
|
+
simplifiedFeatures?: Map<number, GeoJSONFeatureCollection>;
|
|
1169
|
+
/** Simplification statistics */
|
|
1170
|
+
simplificationStats?: Map<number, SimplificationStats>;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Generate LOD data with optional polygon simplification
|
|
1174
|
+
*
|
|
1175
|
+
* When simplificationThresholds are provided, creates pre-simplified
|
|
1176
|
+
* versions of features that can be swapped in at lower zoom levels.
|
|
1177
|
+
*
|
|
1178
|
+
* @example
|
|
1179
|
+
* ```tsx
|
|
1180
|
+
* const lodData = generateLODDataWithSimplification(lotsData, {
|
|
1181
|
+
* groupBy: 'community',
|
|
1182
|
+
* subGroupBy: 'filing',
|
|
1183
|
+
* useConvexHull: true,
|
|
1184
|
+
* simplificationThresholds: [
|
|
1185
|
+
* { maxZoom: 14, tolerance: 0.00005 }, // Light simplification
|
|
1186
|
+
* { maxZoom: 12, tolerance: 0.0002 }, // Medium simplification
|
|
1187
|
+
* { maxZoom: 10, tolerance: 0.0005 }, // Heavy simplification
|
|
1188
|
+
* ],
|
|
1189
|
+
* });
|
|
1190
|
+
*
|
|
1191
|
+
* // Use appropriate data based on zoom
|
|
1192
|
+
* const featureData = zoom < 12
|
|
1193
|
+
* ? lodData.simplifiedFeatures?.get(10)
|
|
1194
|
+
* : zoom < 14
|
|
1195
|
+
* ? lodData.simplifiedFeatures?.get(12)
|
|
1196
|
+
* : lodData.features;
|
|
1197
|
+
* ```
|
|
1198
|
+
*/
|
|
1199
|
+
declare function generateLODDataWithSimplification(geojson: GeoJSONFeatureCollection, options: GenerateLODOptions): LODDataWithSimplification;
|
|
1200
|
+
/**
|
|
1201
|
+
* Get the appropriate feature collection for a given zoom level
|
|
1202
|
+
*
|
|
1203
|
+
* @param lodData LOD data with simplification
|
|
1204
|
+
* @param zoom Current zoom level
|
|
1205
|
+
* @returns The most appropriate feature collection for the zoom level
|
|
1206
|
+
*/
|
|
1207
|
+
declare function getSimplifiedFeaturesForZoom(lodData: LODDataWithSimplification, zoom: number): GeoJSONFeatureCollection;
|
|
1208
|
+
/**
|
|
1209
|
+
* Calculate appropriate zoom thresholds based on feature density
|
|
1210
|
+
*/
|
|
1211
|
+
declare function calculateZoomThresholds(groups: Map<string, FeatureGroup>, options?: {
|
|
1212
|
+
/** Target max features visible at any time */
|
|
1213
|
+
targetMaxFeatures?: number;
|
|
1214
|
+
/** Minimum zoom difference between levels */
|
|
1215
|
+
minZoomGap?: number;
|
|
1216
|
+
}): {
|
|
1217
|
+
groupMaxZoom: number;
|
|
1218
|
+
subGroupMaxZoom: number;
|
|
1219
|
+
};
|
|
1220
|
+
/**
|
|
1221
|
+
* Options for dynamic LOD threshold management
|
|
1222
|
+
*/
|
|
1223
|
+
interface DynamicLODOptions {
|
|
1224
|
+
/** Base thresholds to start from */
|
|
1225
|
+
baseThresholds: {
|
|
1226
|
+
groupMaxZoom: number;
|
|
1227
|
+
subGroupMaxZoom: number;
|
|
1228
|
+
};
|
|
1229
|
+
/** Target FPS to maintain. Default: 50 */
|
|
1230
|
+
targetFps?: number;
|
|
1231
|
+
/** FPS threshold below which to start adjusting. Default: 40 */
|
|
1232
|
+
adjustBelowFps?: number;
|
|
1233
|
+
/** Maximum zoom adjustment allowed. Default: 3 */
|
|
1234
|
+
maxAdjustment?: number;
|
|
1235
|
+
/** Adjustment step per FPS drop. Default: 0.5 */
|
|
1236
|
+
adjustmentStep?: number;
|
|
1237
|
+
/** Smoothing factor for FPS averaging (0-1). Default: 0.3 */
|
|
1238
|
+
smoothingFactor?: number;
|
|
1239
|
+
/** Minimum time between adjustments in ms. Default: 1000 */
|
|
1240
|
+
adjustmentCooldown?: number;
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Current state of dynamic LOD thresholds
|
|
1244
|
+
*/
|
|
1245
|
+
interface DynamicLODState {
|
|
1246
|
+
/** Current adjusted thresholds */
|
|
1247
|
+
thresholds: {
|
|
1248
|
+
groupMaxZoom: number;
|
|
1249
|
+
subGroupMaxZoom: number;
|
|
1250
|
+
};
|
|
1251
|
+
/** Current smoothed FPS */
|
|
1252
|
+
averageFps: number;
|
|
1253
|
+
/** Current adjustment level */
|
|
1254
|
+
adjustment: number;
|
|
1255
|
+
/** Whether thresholds are currently elevated */
|
|
1256
|
+
isAdjusted: boolean;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Create a dynamic LOD threshold manager
|
|
1260
|
+
*
|
|
1261
|
+
* Automatically adjusts LOD zoom thresholds based on FPS to maintain
|
|
1262
|
+
* smooth performance. When FPS drops, thresholds are raised to show
|
|
1263
|
+
* aggregated views longer.
|
|
1264
|
+
*
|
|
1265
|
+
* @example
|
|
1266
|
+
* ```tsx
|
|
1267
|
+
* const lodManager = createDynamicLODManager({
|
|
1268
|
+
* baseThresholds: { groupMaxZoom: 12, subGroupMaxZoom: 14 },
|
|
1269
|
+
* targetFps: 50,
|
|
1270
|
+
* });
|
|
1271
|
+
*
|
|
1272
|
+
* // In render loop or animation frame:
|
|
1273
|
+
* useEffect(() => {
|
|
1274
|
+
* let frameCount = 0;
|
|
1275
|
+
* let lastTime = performance.now();
|
|
1276
|
+
*
|
|
1277
|
+
* const measure = () => {
|
|
1278
|
+
* frameCount++;
|
|
1279
|
+
* const now = performance.now();
|
|
1280
|
+
* if (now - lastTime >= 1000) {
|
|
1281
|
+
* const fps = frameCount;
|
|
1282
|
+
* const state = lodManager.update(fps);
|
|
1283
|
+
* setThresholds(state.thresholds);
|
|
1284
|
+
* frameCount = 0;
|
|
1285
|
+
* lastTime = now;
|
|
1286
|
+
* }
|
|
1287
|
+
* requestAnimationFrame(measure);
|
|
1288
|
+
* };
|
|
1289
|
+
*
|
|
1290
|
+
* const id = requestAnimationFrame(measure);
|
|
1291
|
+
* return () => cancelAnimationFrame(id);
|
|
1292
|
+
* }, []);
|
|
1293
|
+
* ```
|
|
1294
|
+
*/
|
|
1295
|
+
declare function createDynamicLODManager(options: DynamicLODOptions): {
|
|
1296
|
+
/** Update with current FPS and get adjusted thresholds */
|
|
1297
|
+
update: (currentFps: number) => DynamicLODState;
|
|
1298
|
+
/** Force reset to base thresholds */
|
|
1299
|
+
reset: () => DynamicLODState;
|
|
1300
|
+
/** Get current state without updating */
|
|
1301
|
+
getState: () => DynamicLODState;
|
|
1302
|
+
};
|
|
1303
|
+
/**
|
|
1304
|
+
* Get recommended simplification tolerance for a zoom level
|
|
1305
|
+
*
|
|
1306
|
+
* Returns an appropriate tolerance value for polygon simplification
|
|
1307
|
+
* based on the current zoom level. Lower zoom = more simplification.
|
|
1308
|
+
*
|
|
1309
|
+
* @param zoom Current zoom level
|
|
1310
|
+
* @param baseToleranceAtZoom14 Base tolerance to use at zoom 14. Default: 0.00002
|
|
1311
|
+
* @returns Tolerance value in degrees
|
|
1312
|
+
*/
|
|
1313
|
+
declare function getSimplificationToleranceForZoom(zoom: number, baseToleranceAtZoom14?: number): number;
|
|
1314
|
+
/**
|
|
1315
|
+
* Suggested default simplification thresholds
|
|
1316
|
+
*/
|
|
1317
|
+
declare const DEFAULT_SIMPLIFICATION_THRESHOLDS: SimplificationThreshold[];
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Fast O(1) fingerprinting utilities for GeoJSON data equality checking.
|
|
1321
|
+
*
|
|
1322
|
+
* Instead of deep comparing potentially 100k+ features, we compare:
|
|
1323
|
+
* - Feature count
|
|
1324
|
+
* - First feature ID
|
|
1325
|
+
* - Last feature ID
|
|
1326
|
+
*
|
|
1327
|
+
* This provides a fast, reliable check for most data update scenarios.
|
|
1328
|
+
*/
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Fingerprint structure for quick GeoJSON comparison
|
|
1332
|
+
*/
|
|
1333
|
+
interface GeoJSONFingerprint {
|
|
1334
|
+
/** Total number of features */
|
|
1335
|
+
count: number;
|
|
1336
|
+
/** ID of the first feature (undefined if no features or no ID) */
|
|
1337
|
+
firstId: string | number | undefined;
|
|
1338
|
+
/** ID of the last feature (undefined if no features or no ID) */
|
|
1339
|
+
lastId: string | number | undefined;
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Creates a fast O(1) fingerprint for a GeoJSON FeatureCollection.
|
|
1343
|
+
*
|
|
1344
|
+
* @param data - GeoJSON data to fingerprint
|
|
1345
|
+
* @returns Fingerprint object or null if data is not a FeatureCollection
|
|
1346
|
+
*/
|
|
1347
|
+
declare function createGeoJSONFingerprint(data: GeoJSONFeatureCollection | GeoJSON.GeoJSON | string | null | undefined): GeoJSONFingerprint | null;
|
|
1348
|
+
/**
|
|
1349
|
+
* Compares two GeoJSON fingerprints for equality.
|
|
1350
|
+
*
|
|
1351
|
+
* @param a - First fingerprint
|
|
1352
|
+
* @param b - Second fingerprint
|
|
1353
|
+
* @returns true if fingerprints match (data likely unchanged)
|
|
1354
|
+
*/
|
|
1355
|
+
declare function fingerprintEqual(a: GeoJSONFingerprint | null, b: GeoJSONFingerprint | null): boolean;
|
|
1356
|
+
/**
|
|
1357
|
+
* Checks if two GeoJSON data objects are equal based on their fingerprints.
|
|
1358
|
+
* This is a fast O(1) check that works for most practical scenarios.
|
|
1359
|
+
*
|
|
1360
|
+
* @param a - First GeoJSON data
|
|
1361
|
+
* @param b - Second GeoJSON data
|
|
1362
|
+
* @returns true if data is likely unchanged based on fingerprints
|
|
1363
|
+
*/
|
|
1364
|
+
declare function geoJSONEqual(a: GeoJSONFeatureCollection | GeoJSON.GeoJSON | string | null | undefined, b: GeoJSONFeatureCollection | GeoJSON.GeoJSON | string | null | undefined): boolean;
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Equality and delta detection utilities for MapLibre properties.
|
|
1368
|
+
*
|
|
1369
|
+
* These utilities help prevent redundant MapLibre API calls by:
|
|
1370
|
+
* - Detecting which paint properties actually changed
|
|
1371
|
+
* - Comparing filter expressions efficiently
|
|
1372
|
+
* - Tracking visibility state changes
|
|
1373
|
+
*/
|
|
1374
|
+
/**
|
|
1375
|
+
* Deep equality check for simple values (primitives, arrays, objects).
|
|
1376
|
+
* Works for MapLibre expressions and paint property values.
|
|
1377
|
+
*/
|
|
1378
|
+
declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
1379
|
+
/**
|
|
1380
|
+
* Paint property object type
|
|
1381
|
+
*/
|
|
1382
|
+
type PaintProps = Record<string, unknown>;
|
|
1383
|
+
/**
|
|
1384
|
+
* Checks if two paint property objects are equal.
|
|
1385
|
+
*
|
|
1386
|
+
* @param prev - Previous paint properties
|
|
1387
|
+
* @param next - Next paint properties
|
|
1388
|
+
* @returns true if all properties are equal
|
|
1389
|
+
*/
|
|
1390
|
+
declare function paintPropsEqual(prev: PaintProps | undefined, next: PaintProps | undefined): boolean;
|
|
1391
|
+
/**
|
|
1392
|
+
* Result of paint property diff
|
|
1393
|
+
*/
|
|
1394
|
+
interface PaintPropsDiff {
|
|
1395
|
+
/** Properties that were added or changed */
|
|
1396
|
+
changed: PaintProps;
|
|
1397
|
+
/** Property names that were removed */
|
|
1398
|
+
removed: string[];
|
|
1399
|
+
/** Whether there are any changes */
|
|
1400
|
+
hasChanges: boolean;
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Gets only the paint properties that changed between two states.
|
|
1404
|
+
* This allows for targeted setPaintProperty calls instead of updating everything.
|
|
1405
|
+
*
|
|
1406
|
+
* @param prev - Previous paint properties
|
|
1407
|
+
* @param next - Next paint properties
|
|
1408
|
+
* @returns Object containing only changed properties
|
|
1409
|
+
*/
|
|
1410
|
+
declare function getChangedPaintProps(prev: PaintProps | undefined, next: PaintProps | undefined): PaintPropsDiff;
|
|
1411
|
+
/**
|
|
1412
|
+
* MapLibre filter expression operators
|
|
1413
|
+
*/
|
|
1414
|
+
type FilterOperator = 'has' | '!has' | '==' | '!=' | '>' | '>=' | '<' | '<=' | 'in' | '!in' | 'all' | 'any' | 'none' | 'geometry-type' | 'case' | 'match' | 'coalesce' | 'step' | 'interpolate' | 'let' | 'var' | 'literal' | 'get' | 'at' | 'length' | 'boolean' | 'number' | 'string' | 'to-boolean' | 'to-number' | 'to-string' | 'typeof' | '!' | 'within' | 'distance';
|
|
1415
|
+
/**
|
|
1416
|
+
* Filter expression value types
|
|
1417
|
+
*/
|
|
1418
|
+
type FilterValue = string | number | boolean | null;
|
|
1419
|
+
/**
|
|
1420
|
+
* MapLibre filter expression type
|
|
1421
|
+
*
|
|
1422
|
+
* Filters are arrays where the first element is an operator string,
|
|
1423
|
+
* followed by arguments that can be property names, values, or nested expressions.
|
|
1424
|
+
*
|
|
1425
|
+
* Note: We use `unknown[]` for the array type to avoid circular reference issues
|
|
1426
|
+
* while still providing the FilterOperator type for documentation and discoverability.
|
|
1427
|
+
*
|
|
1428
|
+
* @example
|
|
1429
|
+
* // Simple equality filter
|
|
1430
|
+
* ['==', 'type', 'residential']
|
|
1431
|
+
*
|
|
1432
|
+
* // Combining filters
|
|
1433
|
+
* ['all', ['==', 'type', 'residential'], ['>', 'area', 1000]]
|
|
1434
|
+
*
|
|
1435
|
+
* // Expression-based filter
|
|
1436
|
+
* ['case', ['has', 'name'], true, false]
|
|
1437
|
+
*/
|
|
1438
|
+
type FilterExpression = [FilterOperator, ...unknown[]] | unknown[] | undefined | null;
|
|
1439
|
+
/**
|
|
1440
|
+
* Checks if two filter expressions are equal.
|
|
1441
|
+
*
|
|
1442
|
+
* @param prev - Previous filter
|
|
1443
|
+
* @param next - Next filter
|
|
1444
|
+
* @returns true if filters are equal
|
|
1445
|
+
*/
|
|
1446
|
+
declare function filterEqual(prev: FilterExpression, next: FilterExpression): boolean;
|
|
1447
|
+
/**
|
|
1448
|
+
* Serializes a filter expression for comparison.
|
|
1449
|
+
* Useful for storing last-applied filter state.
|
|
1450
|
+
*
|
|
1451
|
+
* @param filter - Filter expression
|
|
1452
|
+
* @returns JSON string or empty string if no filter
|
|
1453
|
+
*/
|
|
1454
|
+
declare function serializeFilter(filter: FilterExpression): string;
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Marker CSS Protection Utilities
|
|
1458
|
+
*
|
|
1459
|
+
* NOTE: DOM-based markers (maplibregl.Marker) are susceptible to CSS framework
|
|
1460
|
+
* interference that can cause visual sliding during map pan/rotate operations.
|
|
1461
|
+
* For production use cases requiring markers, consider using SymbolLayer instead,
|
|
1462
|
+
* which renders on the GPU canvas and is immune to CSS interference.
|
|
1463
|
+
*
|
|
1464
|
+
* This module provides best-effort CSS protection for DOM markers, but it may not
|
|
1465
|
+
* fully prevent sliding in all environments due to CSS specificity and timing issues.
|
|
1466
|
+
*/
|
|
1467
|
+
/**
|
|
1468
|
+
* Marker protection class name - used for CSS targeting
|
|
1469
|
+
*/
|
|
1470
|
+
declare const MARKER_PROTECTION_CLASS = "ct-marker-protected";
|
|
1471
|
+
/**
|
|
1472
|
+
* Apply CSS protection to a marker element.
|
|
1473
|
+
*
|
|
1474
|
+
* This sets inline styles with !important to attempt to block CSS transitions.
|
|
1475
|
+
* Note: This may not work in all environments - use SymbolLayer for guaranteed
|
|
1476
|
+
* immunity from CSS interference.
|
|
1477
|
+
*
|
|
1478
|
+
* @param element - The marker's root HTMLElement (from marker.getElement())
|
|
1479
|
+
*/
|
|
1480
|
+
declare function applyMarkerProtection(element: HTMLElement): void;
|
|
1481
|
+
/**
|
|
1482
|
+
* Remove protection from a marker element (cleanup function).
|
|
1483
|
+
*/
|
|
1484
|
+
declare function removeMarkerProtection(element: HTMLElement): void;
|
|
1485
|
+
/**
|
|
1486
|
+
* Apply CSS protection to custom marker content (children/slots).
|
|
1487
|
+
*/
|
|
1488
|
+
declare function applyMarkerChildProtection(element: HTMLElement): void;
|
|
1489
|
+
|
|
1490
|
+
export { extendBounds as $, formatCoordinates as A, decimalToDMS as B, type ColorExpression as C, formatDistance as D, type ExtrusionHeightOptions as E, formatArea as F, formatBounds as G, formatZoom as H, formatBearing as I, formatPitch as J, KEYBOARD_CONTROLS as K, type LotFillStyleOptions as L, formatScale as M, type NumberExpression as N, zoomToScale as O, formatPropertyValue as P, formatFeatureProperties as Q, formatLabel as R, isValidLongitude as S, isValidLatitude as T, validateCoordinates as U, ensureValidCoordinates as V, normalizeLongitude as W, clampLatitude as X, validateBoundsArray as Y, type CoordinateValidationResult as Z, calculateBounds as _, generateMapDescription as a, serializeFilter as a$, combineBounds as a0, isValidBounds as a1, loadGeoJSON as a2, validateGeoJSON as a3, calculateCentroid as a4, countFeaturesByType as a5, filterByGeometryType as a6, type LoadGeoJSONOptions as a7, type LoadGeoJSONResult as a8, type ValidationResult as a9, calculateZoomThresholds as aA, simplifyPolygon as aB, simplifyFeature as aC, simplifyFeatureCollection as aD, simplifyFeatureCollectionWithStats as aE, generateLODDataWithSimplification as aF, getSimplifiedFeaturesForZoom as aG, createDynamicLODManager as aH, getSimplificationToleranceForZoom as aI, DEFAULT_SIMPLIFICATION_THRESHOLDS as aJ, type GroupFeaturesOptions as aK, type FeatureGroup as aL, type GenerateLODOptions as aM, type LODData as aN, type SimplificationThreshold as aO, type SimplificationStats as aP, type LODDataWithSimplification as aQ, type DynamicLODOptions as aR, type DynamicLODState as aS, createGeoJSONFingerprint as aT, fingerprintEqual as aU, geoJSONEqual as aV, type GeoJSONFingerprint as aW, deepEqual as aX, paintPropsEqual as aY, getChangedPaintProps as aZ, filterEqual as a_, isClusterFeature as aa, getClusterExpansionZoom as ab, getClusterChildren as ac, getClusterLeaves as ad, expandCluster as ae, getClusterBounds as af, expandClusterToBounds as ag, createClusterStyles as ah, createClusterCirclePaint as ai, createClusterTextLayout as aj, type ClusterFeatureProperties as ak, type ClusterExpandOptions as al, type ClusterExpansionResult as am, type ClusterableGeoJSONSource as an, type ClusterMapReader as ao, type ClusterMapExpander as ap, type ClusterMapBoundsExpander as aq, type ClusterCircleStyleOptions as ar, type ClusterTextStyleOptions as as, type UnclusteredPointStyleOptions as at, type ClusterLayerStyles as au, groupFeaturesByProperty as av, generateConvexHull as aw, generateBoundingPolygon as ax, boundsToPolygon as ay, generateLODData as az, generateFeatureCollectionDescription as b, type PaintProps as b0, type PaintPropsDiff as b1, type FilterExpression as b2, type FilterOperator as b3, type FilterValue as b4, applyMarkerProtection as b5, applyMarkerChildProtection as b6, removeMarkerProtection as b7, MARKER_PROTECTION_CLASS as b8, generateMarkersDescription as c, generateFeatureTable as d, generateMarkerList as e, generateMoveAnnouncement as f, generateKeyboardControlsDescription as g, createFillStyle as h, createLineStyle as i, createCircleStyle as j, createExtrusionStyle as k, createHeatmapStyle as l, createHoverExpression as m, createSelectionExpression as n, createInteractiveExpression as o, createCategoricalColorExpression as p, createContinuousColorExpression as q, createZoomExpression as r, getHighlightStyle as s, getSelectionStyle as t, createLotFillStyle as u, createLotOutlineStyle as v, createExtrusionHeightExpression as w, createStatusColorExpression as x, createInteractiveStatusColorExpression as y, type LotOutlineStyleOptions as z };
|