@classic-homes/maps-core 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,1240 +1,13 @@
1
- import { MapTheme } from './theme/index.cjs';
2
- export { MapDataColors, MapStyleSpec, MapThemeColors, THEME_DARK, THEME_LIGHT, darkBasicStyle, darkTheme, generateBasicStyle, generateDarkColors, generateDarkDataColors, generateDarkTheme, generateLightColors, generateLightDataColors, generateLightTheme, generateVectorStyle, getBasicStyle, getTheme, getTypography, lightBasicStyle, lightTheme } from './theme/index.cjs';
3
- import { L as LngLat, G as GeoJSONFeatureCollection, b as MarkerData, M as MapBounds, B as BoundsArray, a as GeoJSONFeature, c as GeoJSONPolygon } from './data-DDS6ok7I.cjs';
4
- export { C as ClusterConfig, E as ExtrusionData, e as GeoJSONGeometry, h as GeoJSONLineString, i as GeoJSONMultiLineString, g as GeoJSONMultiPoint, j as GeoJSONMultiPolygon, f as GeoJSONPoint, H as HeatmapPoint, k as MapSourceData, d as MapViewport } from './data-DDS6ok7I.cjs';
1
+ export { m as MapDataColors, M as MapTheme, k as MapThemeColors, a as THEME_DARK, T as THEME_LIGHT, j as darkTheme, d as generateDarkColors, f as generateDarkDataColors, b as generateDarkTheme, c as generateLightColors, e as generateLightDataColors, g as generateLightTheme, i as getTheme, h as getTypography, l as lightTheme } from './generator-CGfqiHvG.cjs';
2
+ export { MapStyleSpec, darkBasicStyle, generateBasicStyle, generateVectorStyle, getBasicStyle, lightBasicStyle } from './theme/index.cjs';
3
+ import { G as GeoJSONFeatureCollection } from './data-k7o-Rne0.cjs';
4
+ export { B as BoundsArray, C as ClusterConfig, E as ExtrusionData, a as GeoJSONFeature, c as GeoJSONGeometry, f as GeoJSONLineString, g as GeoJSONMultiLineString, e as GeoJSONMultiPoint, i as GeoJSONMultiPolygon, d as GeoJSONPoint, h as GeoJSONPolygon, H as HeatmapPoint, L as LngLat, M as MapBounds, k as MapSourceData, b as MapViewport, j as MarkerData } from './data-k7o-Rne0.cjs';
5
5
  import { BasemapDefinition, BasemapApiKeys, MapStyleSpec } from './types/index.cjs';
6
- export { BaseControlProps, BaseLayerProps, BaseMapEventParams, BaseMapProps, BasemapCategory, BasemapProvider, BasemapSwitcherProps, CircleLayerProps, ControlPosition, CoordinateDisplayProps, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeolocateControlProps, GradientStop, HeatmapLayerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, MapClickEventParams, MapErrorEventParams, MapHoverEventParams, MapLoadEventParams, MapMoveEventParams, MapProps, MarkerClickEventParams, MarkerDragEventParams, MarkerProps, NavigationControlProps, PopupEventParams, PopupProps, RasterLayerProps, ScaleControlProps, SourceProps, SymbolLayerProps } from './types/index.cjs';
7
- export { o as BuildRTreeIndexOptions, B as BuildSpatialIndexOptions, I as IdleViewportManagerOptions, r as IdleViewportResult, P as PanVelocity, p as PredictiveViewportResult, k as QuerySpatialIndexOptions, Q as QueryStats, n as RTreeIndex, m as RTreeItem, R as RTreeQueryStats, S as SpatialIndex, V as ViewportManagedDataOptions, l as ViewportManagedResult, e as buildRTreeIndex, b as buildSpatialIndex, j as createIdleViewportManager, i as createPredictiveViewportManager, h as createRTreeViewportManager, d as createViewportManager, c as createViewportQuery, q as queryByBounds, a as queryByBoundsWithStats, f as queryRTreeByBounds, g as queryRTreeByBoundsWithStats } from './spatial-J48Btm8f.cjs';
6
+ export { BaseControlProps, BaseLayerProps, BaseMapEventParams, BaseMapProps, BasemapCategory, BasemapProvider, BasemapSwitcherProps, CircleLayerProps, ControlPosition, CoordinateDisplayProps, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeolocateControlProps, GradientStop, HeatmapLayerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, MapClickEventParams, MapErrorEventParams, MapHoverEventParams, MapLayerSpecBase, MapLoadEventParams, MapMoveEventParams, MapProps, MapSourceSpec, MarkerClickEventParams, MarkerDragEventParams, MarkerProps, NavigationControlProps, PopupEventParams, PopupProps, RasterLayerProps, ScaleControlProps, SourceProps, SymbolLayerProps } from './types/index.cjs';
7
+ export { ar as ClusterCircleStyleOptions, al as ClusterExpandOptions, am as ClusterExpansionResult, ak as ClusterFeatureProperties, au as ClusterLayerStyles, as as ClusterTextStyleOptions, C as ColorExpression, Z as CoordinateValidationResult, aJ as DEFAULT_SIMPLIFICATION_THRESHOLDS, aR as DynamicLODOptions, aS as DynamicLODState, E as ExtrusionHeightOptions, aL as FeatureGroup, b2 as FilterExpression, b3 as FilterOperator, b4 as FilterValue, aM as GenerateLODOptions, aW as GeoJSONFingerprint, aK as GroupFeaturesOptions, K as KEYBOARD_CONTROLS, aN as LODData, aQ as LODDataWithSimplification, a7 as LoadGeoJSONOptions, a8 as LoadGeoJSONResult, L as LotFillStyleOptions, z as LotOutlineStyleOptions, b8 as MARKER_PROTECTION_CLASS, N as NumberExpression, b0 as PaintProps, b1 as PaintPropsDiff, aP as SimplificationStats, aO as SimplificationThreshold, at as UnclusteredPointStyleOptions, a9 as ValidationResult, b6 as applyMarkerChildProtection, b5 as applyMarkerProtection, ay as boundsToPolygon, _ as calculateBounds, a4 as calculateCentroid, aA as calculateZoomThresholds, X as clampLatitude, a0 as combineBounds, a5 as countFeaturesByType, p as createCategoricalColorExpression, j as createCircleStyle, ai as createClusterCirclePaint, ah as createClusterStyles, aj as createClusterTextLayout, q as createContinuousColorExpression, aH as createDynamicLODManager, w as createExtrusionHeightExpression, k as createExtrusionStyle, h as createFillStyle, aT as createGeoJSONFingerprint, l as createHeatmapStyle, m as createHoverExpression, o as createInteractiveExpression, y as createInteractiveStatusColorExpression, i as createLineStyle, u as createLotFillStyle, v as createLotOutlineStyle, n as createSelectionExpression, x as createStatusColorExpression, r as createZoomExpression, B as decimalToDMS, aX as deepEqual, V as ensureValidCoordinates, ae as expandCluster, ag as expandClusterToBounds, $ as extendBounds, a6 as filterByGeometryType, a_ as filterEqual, aU as fingerprintEqual, F as formatArea, I as formatBearing, G as formatBounds, A as formatCoordinates, D as formatDistance, Q as formatFeatureProperties, R as formatLabel, J as formatPitch, P as formatPropertyValue, M as formatScale, H as formatZoom, ax as generateBoundingPolygon, aw as generateConvexHull, b as generateFeatureCollectionDescription, d as generateFeatureTable, g as generateKeyboardControlsDescription, az as generateLODData, aF as generateLODDataWithSimplification, a as generateMapDescription, e as generateMarkerList, c as generateMarkersDescription, f as generateMoveAnnouncement, aV as geoJSONEqual, aZ as getChangedPaintProps, af as getClusterBounds, ac as getClusterChildren, ab as getClusterExpansionZoom, ad as getClusterLeaves, s as getHighlightStyle, t as getSelectionStyle, aI as getSimplificationToleranceForZoom, aG as getSimplifiedFeaturesForZoom, av as groupFeaturesByProperty, aa as isClusterFeature, a1 as isValidBounds, T as isValidLatitude, S as isValidLongitude, a2 as loadGeoJSON, W as normalizeLongitude, aY as paintPropsEqual, b7 as removeMarkerProtection, a$ as serializeFilter, aC as simplifyFeature, aD as simplifyFeatureCollection, aE as simplifyFeatureCollectionWithStats, aB as simplifyPolygon, Y as validateBoundsArray, U as validateCoordinates, a3 as validateGeoJSON, O as zoomToScale } from './marker-zuhH2WoS.cjs';
8
+ export { n as BuildRTreeIndexOptions, B as BuildSpatialIndexOptions, I as IdleViewportManagerOptions, r as IdleViewportResult, P as PanVelocity, p as PredictiveViewportResult, Q as QuerySpatialIndexOptions, k as QueryStats, m as RTreeIndex, R as RTreeItem, o as RTreeQueryStats, S as SpatialIndex, V as ViewportManagedDataOptions, l as ViewportManagedResult, e as buildRTreeIndex, b as buildSpatialIndex, j as createIdleViewportManager, i as createPredictiveViewportManager, h as createRTreeViewportManager, d as createViewportManager, c as createViewportQuery, q as queryByBounds, a as queryByBoundsWithStats, f as queryRTreeByBounds, g as queryRTreeByBoundsWithStats } from './spatial-CU60awl8.cjs';
8
9
  import 'rbush';
9
10
 
10
- /**
11
- * Accessibility utilities for maps
12
- *
13
- * Provides screen reader support and keyboard navigation guidance
14
- */
15
-
16
- /**
17
- * Keyboard controls documentation for screen readers
18
- */
19
- declare const KEYBOARD_CONTROLS: {
20
- readonly pan: {
21
- readonly up: "Arrow Up";
22
- readonly down: "Arrow Down";
23
- readonly left: "Arrow Left";
24
- readonly right: "Arrow Right";
25
- };
26
- readonly zoom: {
27
- readonly in: "Plus (+) or Equals (=)";
28
- readonly out: "Minus (-)";
29
- };
30
- readonly rotate: {
31
- readonly left: "Shift + Arrow Left";
32
- readonly right: "Shift + Arrow Right";
33
- };
34
- readonly pitch: {
35
- readonly increase: "Shift + Arrow Up";
36
- readonly decrease: "Shift + Arrow Down";
37
- };
38
- readonly reset: {
39
- readonly bearing: "N key (reset north)";
40
- readonly view: "R key (reset view)";
41
- };
42
- };
43
- /**
44
- * Generate a text description of keyboard controls
45
- */
46
- declare function generateKeyboardControlsDescription(): string;
47
- /**
48
- * Generate an accessible description for a map
49
- */
50
- declare function generateMapDescription(title: string, options?: {
51
- center?: LngLat;
52
- zoom?: number;
53
- featureCount?: number;
54
- markerCount?: number;
55
- layerTypes?: string[];
56
- }): string;
57
- /**
58
- * Generate description for GeoJSON features
59
- */
60
- declare function generateFeatureCollectionDescription(title: string, data: GeoJSONFeatureCollection): string;
61
- /**
62
- * Generate description for markers
63
- */
64
- declare function generateMarkersDescription(title: string, markers: MarkerData[]): string;
65
- /**
66
- * Generate a hidden data table for screen readers
67
- */
68
- declare function generateFeatureTable(features: GeoJSONFeatureCollection, propertyKeys: string[]): string;
69
- /**
70
- * Generate a hidden marker list for screen readers
71
- */
72
- declare function generateMarkerList(markers: MarkerData[]): string;
73
- /**
74
- * Generate live region announcement for map changes
75
- */
76
- declare function generateMoveAnnouncement(center: LngLat, zoom: number, action: 'pan' | 'zoom' | 'move'): string;
77
-
78
- /**
79
- * Style utilities for map layers
80
- *
81
- * Helper functions for creating MapLibre paint and layout expressions
82
- */
83
-
84
- /**
85
- * Color expression for data-driven styling
86
- */
87
- type ColorExpression = string | unknown[];
88
- /**
89
- * Number expression for data-driven styling
90
- */
91
- type NumberExpression = number | unknown[];
92
- /**
93
- * Create a solid polygon/fill style
94
- */
95
- declare function createFillStyle(options: {
96
- color: ColorExpression;
97
- opacity?: NumberExpression;
98
- outlineColor?: ColorExpression;
99
- }): {
100
- paint: Record<string, unknown>;
101
- };
102
- /**
103
- * Create a line style
104
- */
105
- declare function createLineStyle(options: {
106
- color: ColorExpression;
107
- width: NumberExpression;
108
- opacity?: NumberExpression;
109
- dashArray?: number[];
110
- cap?: 'butt' | 'round' | 'square';
111
- join?: 'bevel' | 'round' | 'miter';
112
- }): {
113
- paint: Record<string, unknown>;
114
- layout: Record<string, unknown>;
115
- };
116
- /**
117
- * Create a circle/point style
118
- */
119
- declare function createCircleStyle(options: {
120
- radius: NumberExpression;
121
- color: ColorExpression;
122
- opacity?: NumberExpression;
123
- strokeWidth?: NumberExpression;
124
- strokeColor?: ColorExpression;
125
- blur?: number;
126
- }): {
127
- paint: Record<string, unknown>;
128
- };
129
- /**
130
- * Create a 3D extrusion style for buildings
131
- */
132
- declare function createExtrusionStyle(options: {
133
- height: NumberExpression;
134
- baseHeight?: NumberExpression;
135
- color: ColorExpression;
136
- opacity?: number;
137
- verticalGradient?: boolean;
138
- }): {
139
- paint: Record<string, unknown>;
140
- };
141
- /**
142
- * Create a heatmap style
143
- */
144
- declare function createHeatmapStyle(options: {
145
- weight?: NumberExpression;
146
- intensity?: NumberExpression;
147
- radius?: NumberExpression;
148
- opacity?: NumberExpression;
149
- colorRamp?: string[];
150
- }): {
151
- paint: Record<string, unknown>;
152
- };
153
- /**
154
- * Create a hover expression for highlighting features
155
- *
156
- * @param baseValue - The default value
157
- * @param hoverValue - The value when hovered (feature-state hover = true)
158
- * @param featureStateName - The feature state property name (default: 'hover')
159
- */
160
- declare function createHoverExpression(baseValue: unknown, hoverValue: unknown, featureStateName?: string): unknown[];
161
- /**
162
- * Create a selection expression for highlighting selected features
163
- */
164
- declare function createSelectionExpression(baseValue: unknown, selectedValue: unknown, featureStateName?: string): unknown[];
165
- /**
166
- * Create a combined hover and selection expression
167
- */
168
- declare function createInteractiveExpression(baseValue: unknown, hoverValue: unknown, selectedValue: unknown): unknown[];
169
- /**
170
- * Create a data-driven color expression based on a property
171
- *
172
- * @param property - The feature property name
173
- * @param colorMap - Map of property values to colors
174
- * @param defaultColor - Default color for unmapped values
175
- */
176
- declare function createCategoricalColorExpression(property: string, colorMap: Record<string, string>, defaultColor: string): unknown[];
177
- /**
178
- * Create a continuous color ramp expression
179
- *
180
- * @param property - The feature property name
181
- * @param stops - Array of [value, color] pairs
182
- * @param interpolation - Interpolation type ('linear', 'exponential', 'cubic-bezier')
183
- */
184
- declare function createContinuousColorExpression(property: string, stops: [number, string][], interpolation?: 'linear' | 'exponential' | ['cubic-bezier', number, number, number, number]): unknown[];
185
- /**
186
- * Create a zoom-based interpolation expression
187
- *
188
- * @param stops - Array of [zoom, value] pairs
189
- */
190
- declare function createZoomExpression(stops: [number, number][]): unknown[];
191
- /**
192
- * Get pre-configured highlight style for the active theme
193
- */
194
- declare function getHighlightStyle(theme?: MapTheme): {
195
- fill: Record<string, unknown>;
196
- line: Record<string, unknown>;
197
- circle: Record<string, unknown>;
198
- };
199
- /**
200
- * Get pre-configured selection style for the active theme
201
- */
202
- declare function getSelectionStyle(theme?: MapTheme): {
203
- fill: Record<string, unknown>;
204
- line: Record<string, unknown>;
205
- circle: Record<string, unknown>;
206
- };
207
- /**
208
- * Options for creating lot fill styles
209
- */
210
- interface LotFillStyleOptions {
211
- /** Default fill color */
212
- defaultColor: string;
213
- /** Color when hovered */
214
- hoverColor: string;
215
- /** Color when selected (optional) */
216
- selectedColor?: string;
217
- /** Fill opacity (0-1, default: 0.7) */
218
- opacity?: number;
219
- }
220
- /**
221
- * Create fill + hover style for polygon lots
222
- *
223
- * @example
224
- * ```tsx
225
- * const fillStyle = createLotFillStyle({
226
- * defaultColor: '#22c55e',
227
- * hoverColor: '#3b82f6',
228
- * selectedColor: '#f59e0b',
229
- * opacity: 0.7,
230
- * });
231
- *
232
- * <FillLayer
233
- * fillColor={fillStyle['fill-color']}
234
- * fillOpacity={fillStyle['fill-opacity']}
235
- * />
236
- * ```
237
- */
238
- declare function createLotFillStyle(options: LotFillStyleOptions): {
239
- 'fill-color': unknown[];
240
- 'fill-opacity': number;
241
- };
242
- /**
243
- * Options for creating lot outline styles
244
- */
245
- interface LotOutlineStyleOptions {
246
- /** Default outline color */
247
- defaultColor: string;
248
- /** Color when hovered */
249
- hoverColor: string;
250
- /** Color when selected (optional) */
251
- selectedColor?: string;
252
- /** Default line width in pixels (default: 1) */
253
- defaultWidth?: number;
254
- /** Line width when hovered (default: 2) */
255
- hoverWidth?: number;
256
- /** Line width when selected (default: 3) */
257
- selectedWidth?: number;
258
- }
259
- /**
260
- * Create outline style with hover highlighting for polygon lots
261
- *
262
- * @example
263
- * ```tsx
264
- * const outlineStyle = createLotOutlineStyle({
265
- * defaultColor: '#333',
266
- * hoverColor: '#1d4ed8',
267
- * defaultWidth: 1,
268
- * hoverWidth: 2,
269
- * });
270
- *
271
- * <LineLayer
272
- * lineColor={outlineStyle['line-color']}
273
- * lineWidth={outlineStyle['line-width']}
274
- * />
275
- * ```
276
- */
277
- declare function createLotOutlineStyle(options: LotOutlineStyleOptions): {
278
- 'line-color': unknown[];
279
- 'line-width': unknown[];
280
- };
281
- /**
282
- * Options for creating extrusion height expressions
283
- */
284
- interface ExtrusionHeightOptions {
285
- /** Scale factor to multiply property value by (default: 1) */
286
- scale?: number;
287
- /** Minimum height in meters (default: 0) */
288
- minHeight?: number;
289
- /** Maximum height cap in meters (optional) */
290
- maxHeight?: number;
291
- /** Default height when property is missing (default: 0) */
292
- defaultHeight?: number;
293
- }
294
- /**
295
- * Create data-driven extrusion height expression from a feature property
296
- *
297
- * This is useful for visualizing property values like price, square footage,
298
- * or density as 3D heights on a map.
299
- *
300
- * @param property - The feature property name to use for height
301
- * @param options - Configuration options for height calculation
302
- *
303
- * @example
304
- * ```tsx
305
- * // Simple height based on price (scaled down)
306
- * const heightExpr = createExtrusionHeightExpression('price', {
307
- * scale: 0.0001, // $100,000 = 10m height
308
- * minHeight: 5,
309
- * maxHeight: 100,
310
- * });
311
- *
312
- * <FillExtrusionLayer
313
- * fillExtrusionHeight={heightExpr}
314
- * fillExtrusionBase={0}
315
- * />
316
- * ```
317
- */
318
- declare function createExtrusionHeightExpression(property: string, options?: ExtrusionHeightOptions): unknown[];
319
- /**
320
- * Create categorical color expression for lot status
321
- *
322
- * This creates a match expression that maps status values to colors.
323
- * Commonly used for real estate lot statuses like available, sold, pending.
324
- *
325
- * @param statusColors - Map of status values to colors
326
- * @param defaultColor - Fallback color for unknown statuses (default: '#888888')
327
- *
328
- * @example
329
- * ```tsx
330
- * const statusColorExpr = createStatusColorExpression({
331
- * available: '#22c55e', // green
332
- * pending: '#f59e0b', // amber
333
- * sold: '#ef4444', // red
334
- * reserved: '#3b82f6', // blue
335
- * });
336
- *
337
- * <FillLayer fillColor={statusColorExpr} />
338
- * <FillExtrusionLayer fillExtrusionColor={statusColorExpr} />
339
- * ```
340
- */
341
- declare function createStatusColorExpression(statusColors: Record<string, string>, defaultColor?: string): unknown[];
342
- /**
343
- * Create a combined status color expression with hover/selection support
344
- *
345
- * This creates an expression that:
346
- * 1. Uses status-based colors for the default state
347
- * 2. Applies a highlight color on hover
348
- * 3. Optionally applies a selection color when selected
349
- *
350
- * @example
351
- * ```tsx
352
- * const colorExpr = createInteractiveStatusColorExpression(
353
- * { available: '#22c55e', sold: '#ef4444' },
354
- * { hoverColor: '#3b82f6', selectedColor: '#f59e0b' }
355
- * );
356
- *
357
- * <FillLayer fillColor={colorExpr} />
358
- * ```
359
- */
360
- declare function createInteractiveStatusColorExpression(statusColors: Record<string, string>, options: {
361
- hoverColor: string;
362
- selectedColor?: string;
363
- defaultColor?: string;
364
- }): unknown[];
365
-
366
- /**
367
- * Formatting utilities for map data
368
- */
369
-
370
- /**
371
- * Format coordinates for display
372
- *
373
- * @param coordinates - [lng, lat] coordinate pair
374
- * @param precision - Decimal places (default: 6)
375
- * @param format - Output format
376
- */
377
- declare function formatCoordinates(coordinates: LngLat, precision?: number, format?: 'decimal' | 'dms' | 'dd'): string;
378
- /**
379
- * Convert decimal degrees to DMS (degrees, minutes, seconds)
380
- */
381
- declare function decimalToDMS(decimal: number, type: 'lat' | 'lng'): string;
382
- /**
383
- * Format distance in meters to human-readable string
384
- *
385
- * @param meters - Distance in meters
386
- * @param unit - Unit system
387
- */
388
- declare function formatDistance(meters: number, unit?: 'metric' | 'imperial'): string;
389
- /**
390
- * Format area in square meters to human-readable string
391
- *
392
- * @param sqMeters - Area in square meters
393
- * @param unit - Unit system
394
- */
395
- declare function formatArea(sqMeters: number, unit?: 'metric' | 'imperial'): string;
396
- /**
397
- * Format a bounding box for display
398
- */
399
- declare function formatBounds(bounds: MapBounds | BoundsArray): string;
400
- /**
401
- * Format zoom level for display
402
- */
403
- declare function formatZoom(zoom: number): string;
404
- /**
405
- * Format bearing/rotation for display
406
- */
407
- declare function formatBearing(bearing: number): string;
408
- /**
409
- * Format pitch/tilt for display
410
- */
411
- declare function formatPitch(pitch: number): string;
412
- /**
413
- * Format a scale value for display
414
- *
415
- * @param scale - Scale ratio (e.g., 50000 for 1:50,000)
416
- */
417
- declare function formatScale(scale: number): string;
418
- /**
419
- * Approximate the scale from zoom level (rough estimate)
420
- *
421
- * @param zoom - Map zoom level
422
- * @param latitude - Latitude (scale varies by latitude)
423
- */
424
- declare function zoomToScale(zoom: number, latitude?: number): number;
425
- /**
426
- * Format a property value for display in popups
427
- */
428
- declare function formatPropertyValue(value: unknown): string;
429
- /**
430
- * Create a popup content string from feature properties
431
- */
432
- declare function formatFeatureProperties(properties: Record<string, unknown>, options?: {
433
- exclude?: string[];
434
- include?: string[];
435
- labelMap?: Record<string, string>;
436
- }): string;
437
- /**
438
- * Format a property key as a human-readable label
439
- */
440
- declare function formatLabel(key: string): string;
441
-
442
- /**
443
- * Bounds calculation utilities for GeoJSON data
444
- */
445
-
446
- /**
447
- * Calculate bounds from GeoJSON data
448
- * @param geojson - GeoJSON FeatureCollection or Feature
449
- * @returns BoundsArray [[sw_lng, sw_lat], [ne_lng, ne_lat]] or null if no valid coordinates
450
- */
451
- declare function calculateBounds(geojson: GeoJSONFeatureCollection | GeoJSONFeature): BoundsArray | null;
452
- /**
453
- * Extend bounds to include a new point
454
- * @param bounds - Existing bounds
455
- * @param point - Point to include [lng, lat]
456
- * @returns Extended bounds
457
- */
458
- declare function extendBounds(bounds: BoundsArray, point: LngLat): BoundsArray;
459
- /**
460
- * Combine two bounds into one that encompasses both
461
- * @param bounds1 - First bounds
462
- * @param bounds2 - Second bounds
463
- * @returns Combined bounds
464
- */
465
- declare function combineBounds(bounds1: BoundsArray, bounds2: BoundsArray): BoundsArray;
466
- /**
467
- * Validate that bounds are properly formed
468
- * @param bounds - Bounds to validate
469
- * @returns True if bounds are valid
470
- */
471
- declare function isValidBounds(bounds: BoundsArray): boolean;
472
-
473
- /**
474
- * Data loading and validation utilities for GeoJSON
475
- */
476
-
477
- /**
478
- * Options for loading GeoJSON data
479
- */
480
- interface LoadGeoJSONOptions {
481
- /** Request timeout in milliseconds (default: 30000) */
482
- timeout?: number;
483
- /** Additional fetch options */
484
- fetchOptions?: RequestInit;
485
- /** Validate the GeoJSON structure after loading */
486
- validate?: boolean;
487
- }
488
- /**
489
- * Result of loading GeoJSON data
490
- */
491
- interface LoadGeoJSONResult<T = GeoJSONFeatureCollection> {
492
- /** The loaded data (null if error) */
493
- data: T | null;
494
- /** Error message if loading failed */
495
- error: string | null;
496
- /** Whether the request was successful */
497
- success: boolean;
498
- }
499
- /**
500
- * GeoJSON validation result
501
- */
502
- interface ValidationResult {
503
- /** Whether the GeoJSON is valid */
504
- valid: boolean;
505
- /** List of validation errors */
506
- errors: string[];
507
- /** Number of features (if FeatureCollection) */
508
- featureCount?: number;
509
- /** Geometry types found */
510
- geometryTypes?: string[];
511
- }
512
- /**
513
- * Load GeoJSON data from a URL
514
- * @param url - URL to fetch GeoJSON from
515
- * @param options - Loading options
516
- * @returns Promise with load result
517
- */
518
- declare function loadGeoJSON<T = GeoJSONFeatureCollection>(url: string, options?: LoadGeoJSONOptions): Promise<LoadGeoJSONResult<T>>;
519
- /**
520
- * Validate GeoJSON structure
521
- * @param data - Data to validate
522
- * @returns Validation result
523
- */
524
- declare function validateGeoJSON(data: unknown): ValidationResult;
525
- /**
526
- * Calculate the centroid of a GeoJSON FeatureCollection or Feature
527
- * @param geojson - GeoJSON data
528
- * @returns Centroid as [lng, lat] or null if no coordinates
529
- */
530
- declare function calculateCentroid(geojson: GeoJSONFeatureCollection | GeoJSONFeature): [number, number] | null;
531
- /**
532
- * Count features by geometry type in a FeatureCollection
533
- * @param geojson - GeoJSON FeatureCollection
534
- * @returns Object with geometry types as keys and counts as values
535
- */
536
- declare function countFeaturesByType(geojson: GeoJSONFeatureCollection): Record<string, number>;
537
- /**
538
- * Filter features by geometry type
539
- * @param geojson - GeoJSON FeatureCollection
540
- * @param types - Geometry types to include
541
- * @returns Filtered FeatureCollection
542
- */
543
- declare function filterByGeometryType(geojson: GeoJSONFeatureCollection, types: string[]): GeoJSONFeatureCollection;
544
-
545
- /**
546
- * Cluster utilities for MapLibre GL
547
- *
548
- * These utilities help with common clustering operations like
549
- * expanding clusters on click and getting cluster information.
550
- */
551
-
552
- /**
553
- * Properties automatically added to cluster features by MapLibre GL
554
- */
555
- interface ClusterFeatureProperties extends Record<string, unknown> {
556
- /** Unique cluster identifier */
557
- cluster_id: number;
558
- /** Number of points in the cluster */
559
- point_count: number;
560
- /** Abbreviated point count (e.g., "1.2k") */
561
- point_count_abbreviated: string;
562
- /** Whether this is a cluster */
563
- cluster: true;
564
- }
565
- /**
566
- * Type guard to check if a feature is a cluster
567
- */
568
- declare function isClusterFeature(feature: {
569
- properties?: Record<string, unknown> | null;
570
- }): feature is {
571
- properties: ClusterFeatureProperties;
572
- };
573
- /**
574
- * Options for cluster expansion
575
- */
576
- interface ClusterExpandOptions {
577
- /** Animation duration in milliseconds (default: 500) */
578
- duration?: number;
579
- /** Whether to animate the transition (default: true) */
580
- animate?: boolean;
581
- /** Padding around the expanded cluster bounds */
582
- padding?: number | {
583
- top: number;
584
- bottom: number;
585
- left: number;
586
- right: number;
587
- };
588
- /** Maximum zoom level to expand to */
589
- maxZoom?: number;
590
- }
591
- /**
592
- * Result of getting cluster expansion zoom
593
- */
594
- interface ClusterExpansionResult {
595
- /** The zoom level needed to expand the cluster */
596
- zoom: number;
597
- /** The cluster's center coordinates */
598
- center: LngLat;
599
- }
600
- /**
601
- * Get the zoom level needed to expand a cluster
602
- *
603
- * This is a wrapper around MapLibre GL's getClusterExpansionZoom method
604
- * that provides a cleaner async interface.
605
- *
606
- * @param map - MapLibre GL map instance
607
- * @param sourceId - ID of the GeoJSON source with clustering enabled
608
- * @param clusterId - The cluster_id from the cluster feature properties
609
- * @returns Promise resolving to the expansion zoom level
610
- *
611
- * @example
612
- * ```typescript
613
- * const zoom = await getClusterExpansionZoom(map, 'points', clusterId);
614
- * map.easeTo({ center: clusterCoords, zoom });
615
- * ```
616
- */
617
- declare function getClusterExpansionZoom(map: {
618
- getSource: (id: string) => unknown;
619
- }, sourceId: string, clusterId: number): Promise<number>;
620
- /**
621
- * Get the children features of a cluster
622
- *
623
- * Returns the immediate children of a cluster, which may be
624
- * individual points or other clusters.
625
- *
626
- * @param map - MapLibre GL map instance
627
- * @param sourceId - ID of the GeoJSON source with clustering enabled
628
- * @param clusterId - The cluster_id from the cluster feature properties
629
- * @returns Promise resolving to an array of child features
630
- */
631
- declare function getClusterChildren(map: {
632
- getSource: (id: string) => unknown;
633
- }, sourceId: string, clusterId: number): Promise<GeoJSONFeature[]>;
634
- /**
635
- * Get all leaf features (individual points) of a cluster
636
- *
637
- * Returns all individual points contained within a cluster,
638
- * regardless of nesting level.
639
- *
640
- * @param map - MapLibre GL map instance
641
- * @param sourceId - ID of the GeoJSON source with clustering enabled
642
- * @param clusterId - The cluster_id from the cluster feature properties
643
- * @param limit - Maximum number of features to return (default: 100)
644
- * @param offset - Offset for pagination (default: 0)
645
- * @returns Promise resolving to an array of leaf features
646
- */
647
- declare function getClusterLeaves(map: {
648
- getSource: (id: string) => unknown;
649
- }, sourceId: string, clusterId: number, limit?: number, offset?: number): Promise<GeoJSONFeature[]>;
650
- /**
651
- * Expand a cluster by zooming in to show its contents
652
- *
653
- * This is the main utility for handling cluster click-to-expand behavior.
654
- * It gets the expansion zoom level and animates the map to that zoom.
655
- *
656
- * @param map - MapLibre GL map instance with easeTo method
657
- * @param sourceId - ID of the GeoJSON source with clustering enabled
658
- * @param clusterId - The cluster_id from the cluster feature properties
659
- * @param center - The cluster's center coordinates [lng, lat]
660
- * @param options - Animation and zoom options
661
- *
662
- * @example
663
- * ```typescript
664
- * // In a cluster click handler:
665
- * function handleClusterClick(e) {
666
- * const { cluster_id } = e.feature.properties;
667
- * const [lng, lat] = e.feature.geometry.coordinates;
668
- * expandCluster(map, 'points-source', cluster_id, [lng, lat]);
669
- * }
670
- * ```
671
- */
672
- declare function expandCluster(map: {
673
- getSource: (id: string) => unknown;
674
- easeTo: (options: {
675
- center: [number, number];
676
- zoom: number;
677
- duration?: number;
678
- animate?: boolean;
679
- padding?: number | {
680
- top: number;
681
- bottom: number;
682
- left: number;
683
- right: number;
684
- };
685
- }) => void;
686
- getZoom: () => number;
687
- }, sourceId: string, clusterId: number, center: LngLat, options?: ClusterExpandOptions): Promise<void>;
688
- /**
689
- * Calculate bounds that encompass all leaves of a cluster
690
- *
691
- * Useful for fitting the map to show all points in a cluster.
692
- *
693
- * @param map - MapLibre GL map instance
694
- * @param sourceId - ID of the GeoJSON source with clustering enabled
695
- * @param clusterId - The cluster_id from the cluster feature properties
696
- * @param limit - Maximum number of leaves to consider (default: 1000)
697
- * @returns Promise resolving to bounds array [[sw_lng, sw_lat], [ne_lng, ne_lat]]
698
- */
699
- declare function getClusterBounds(map: {
700
- getSource: (id: string) => unknown;
701
- }, sourceId: string, clusterId: number, limit?: number): Promise<BoundsArray>;
702
- /**
703
- * Expand a cluster by fitting to the bounds of its leaves
704
- *
705
- * Alternative to expandCluster that zooms to fit all points
706
- * rather than using the expansion zoom level.
707
- *
708
- * @param map - MapLibre GL map instance with fitBounds method
709
- * @param sourceId - ID of the GeoJSON source with clustering enabled
710
- * @param clusterId - The cluster_id from the cluster feature properties
711
- * @param options - Animation and padding options
712
- */
713
- declare function expandClusterToBounds(map: {
714
- getSource: (id: string) => unknown;
715
- fitBounds: (bounds: BoundsArray, options?: {
716
- padding?: number | {
717
- top: number;
718
- bottom: number;
719
- left: number;
720
- right: number;
721
- };
722
- duration?: number;
723
- animate?: boolean;
724
- maxZoom?: number;
725
- }) => void;
726
- }, sourceId: string, clusterId: number, options?: ClusterExpandOptions): Promise<void>;
727
-
728
- /**
729
- * Level-of-Detail (LOD) utilities for efficient rendering of large polygon datasets
730
- *
731
- * These utilities help manage rendering performance by:
732
- * 1. Grouping features by hierarchy (community > filing > lot)
733
- * 2. Generating boundary polygons for groups when not provided
734
- * 3. Supporting zoom-based visibility switching
735
- */
736
-
737
- /**
738
- * Options for grouping features
739
- */
740
- interface GroupFeaturesOptions {
741
- /** Property name to group by */
742
- groupBy: string;
743
- /** Optional nested grouping property */
744
- subGroupBy?: string;
745
- }
746
- /**
747
- * A group of features with computed metadata
748
- */
749
- interface FeatureGroup {
750
- /** Group identifier (property value) */
751
- id: string;
752
- /** Features in this group */
753
- features: GeoJSONFeature[];
754
- /** Bounds of all features in group */
755
- bounds: BoundsArray | null;
756
- /** Centroid of the group */
757
- centroid: LngLat | null;
758
- /** Total count of features */
759
- count: number;
760
- /** Sub-groups if nested grouping was used */
761
- subGroups?: Map<string, FeatureGroup>;
762
- }
763
- /**
764
- * Group GeoJSON features by a property value
765
- *
766
- * @example
767
- * ```ts
768
- * const groups = groupFeaturesByProperty(lotsData, {
769
- * groupBy: 'community',
770
- * subGroupBy: 'filing',
771
- * });
772
- *
773
- * // Access groups
774
- * groups.forEach((group, communityId) => {
775
- * console.log(`Community ${communityId}: ${group.count} lots`);
776
- * group.subGroups?.forEach((subGroup, filingId) => {
777
- * console.log(` Filing ${filingId}: ${subGroup.count} lots`);
778
- * });
779
- * });
780
- * ```
781
- */
782
- declare function groupFeaturesByProperty(geojson: GeoJSONFeatureCollection, options: GroupFeaturesOptions): Map<string, FeatureGroup>;
783
- /**
784
- * Generate a convex hull polygon from a set of features
785
- *
786
- * Uses the gift wrapping algorithm for simplicity
787
- */
788
- declare function generateConvexHull(features: GeoJSONFeature[]): GeoJSONPolygon | null;
789
- /**
790
- * Generate a bounding box polygon from features
791
- * Simpler alternative to convex hull
792
- */
793
- declare function generateBoundingPolygon(features: GeoJSONFeature[], padding?: number): GeoJSONPolygon | null;
794
- /**
795
- * Convert bounds to a polygon
796
- */
797
- declare function boundsToPolygon(bounds: BoundsArray, padding?: number): GeoJSONPolygon;
798
- /**
799
- * Simplify a GeoJSON polygon geometry
800
- *
801
- * @example
802
- * ```ts
803
- * const simplified = simplifyPolygon(polygon, 0.0001);
804
- * console.log(`Reduced from ${original.coordinates[0].length} to ${simplified.coordinates[0].length} points`);
805
- * ```
806
- */
807
- declare function simplifyPolygon(polygon: GeoJSONPolygon, tolerance: number): GeoJSONPolygon;
808
- /**
809
- * Simplify a GeoJSON feature's geometry
810
- *
811
- * Supports Point, Polygon, and MultiPolygon geometries.
812
- * Points are returned unchanged. Lines could be added if needed.
813
- */
814
- declare function simplifyFeature(feature: GeoJSONFeature, tolerance: number): GeoJSONFeature;
815
- /**
816
- * Simplify all features in a GeoJSON FeatureCollection
817
- *
818
- * @example
819
- * ```ts
820
- * const simplified = simplifyFeatureCollection(features, 0.0001);
821
- * // Polygon vertices reduced by ~50-80%
822
- * ```
823
- */
824
- declare function simplifyFeatureCollection(collection: GeoJSONFeatureCollection, tolerance: number): GeoJSONFeatureCollection;
825
- /**
826
- * Calculate simplification statistics
827
- */
828
- interface SimplificationStats {
829
- /** Original total vertex count */
830
- originalVertices: number;
831
- /** Simplified total vertex count */
832
- simplifiedVertices: number;
833
- /** Percentage of vertices removed */
834
- reductionPercent: number;
835
- /** Number of features processed */
836
- featureCount: number;
837
- }
838
- /**
839
- * Simplify a feature collection and return with statistics
840
- */
841
- declare function simplifyFeatureCollectionWithStats(collection: GeoJSONFeatureCollection, tolerance: number): {
842
- data: GeoJSONFeatureCollection;
843
- stats: SimplificationStats;
844
- };
845
- /**
846
- * Simplification threshold configuration
847
- */
848
- interface SimplificationThreshold {
849
- /** Maximum zoom level to apply this simplification */
850
- maxZoom: number;
851
- /** Tolerance in degrees - higher = more simplification */
852
- tolerance: number;
853
- }
854
- /**
855
- * Options for generating LOD data
856
- */
857
- interface GenerateLODOptions {
858
- /** Property to group by at the top level (e.g., 'community') */
859
- groupBy: string;
860
- /** Property to group by at the second level (e.g., 'filing') */
861
- subGroupBy?: string;
862
- /** Pre-provided boundary for top-level groups (keyed by group ID) */
863
- groupBoundaries?: Map<string, GeoJSONPolygon>;
864
- /** Pre-provided boundary for sub-groups (keyed by "groupId:subGroupId") */
865
- subGroupBoundaries?: Map<string, GeoJSONPolygon>;
866
- /** Use convex hull (true) or bounding box (false) for auto-generated boundaries */
867
- useConvexHull?: boolean;
868
- /** Padding to add around auto-generated bounding boxes (in degrees) */
869
- boundaryPadding?: number;
870
- /** Additional properties to aggregate for group features */
871
- aggregateProperties?: string[];
872
- /**
873
- * Simplification thresholds for reducing polygon complexity at lower zoom levels
874
- * @example [{ maxZoom: 12, tolerance: 0.0001 }, { maxZoom: 10, tolerance: 0.0005 }]
875
- */
876
- simplificationThresholds?: SimplificationThreshold[];
877
- }
878
- /**
879
- * Result of LOD generation
880
- */
881
- interface LODData {
882
- /** Top-level group boundaries (communities) */
883
- groupBoundaries: GeoJSONFeatureCollection;
884
- /** Second-level group boundaries (filings) */
885
- subGroupBoundaries: GeoJSONFeatureCollection | null;
886
- /** Original features with group info */
887
- features: GeoJSONFeatureCollection;
888
- /** Recommended zoom thresholds */
889
- zoomThresholds: {
890
- /** Show groups below this zoom */
891
- groupMaxZoom: number;
892
- /** Show sub-groups between groupMaxZoom and this */
893
- subGroupMaxZoom: number;
894
- };
895
- }
896
- /**
897
- * Generate Level-of-Detail data from a feature collection
898
- *
899
- * Creates boundary polygons for each group level that can be shown
900
- * at different zoom levels for better performance.
901
- *
902
- * @example
903
- * ```tsx
904
- * const lodData = generateLODData(lotsData, {
905
- * groupBy: 'community',
906
- * subGroupBy: 'filing',
907
- * useConvexHull: true,
908
- * });
909
- *
910
- * // Use in map
911
- * <Source id="communities" data={lodData.groupBoundaries} />
912
- * <FillLayer
913
- * id="communities-fill"
914
- * source="communities"
915
- * maxZoom={lodData.zoomThresholds.groupMaxZoom}
916
- * />
917
- *
918
- * <Source id="filings" data={lodData.subGroupBoundaries} />
919
- * <FillLayer
920
- * id="filings-fill"
921
- * source="filings"
922
- * minZoom={lodData.zoomThresholds.groupMaxZoom}
923
- * maxZoom={lodData.zoomThresholds.subGroupMaxZoom}
924
- * />
925
- *
926
- * <Source id="lots" data={lodData.features} />
927
- * <FillLayer
928
- * id="lots-fill"
929
- * source="lots"
930
- * minZoom={lodData.zoomThresholds.subGroupMaxZoom}
931
- * />
932
- * ```
933
- */
934
- declare function generateLODData(geojson: GeoJSONFeatureCollection, options: GenerateLODOptions): LODData;
935
- /**
936
- * Extended LOD data with pre-simplified versions
937
- */
938
- interface LODDataWithSimplification extends LODData {
939
- /** Simplified versions of features for different zoom levels */
940
- simplifiedFeatures?: Map<number, GeoJSONFeatureCollection>;
941
- /** Simplification statistics */
942
- simplificationStats?: Map<number, SimplificationStats>;
943
- }
944
- /**
945
- * Generate LOD data with optional polygon simplification
946
- *
947
- * When simplificationThresholds are provided, creates pre-simplified
948
- * versions of features that can be swapped in at lower zoom levels.
949
- *
950
- * @example
951
- * ```tsx
952
- * const lodData = generateLODDataWithSimplification(lotsData, {
953
- * groupBy: 'community',
954
- * subGroupBy: 'filing',
955
- * useConvexHull: true,
956
- * simplificationThresholds: [
957
- * { maxZoom: 14, tolerance: 0.00005 }, // Light simplification
958
- * { maxZoom: 12, tolerance: 0.0002 }, // Medium simplification
959
- * { maxZoom: 10, tolerance: 0.0005 }, // Heavy simplification
960
- * ],
961
- * });
962
- *
963
- * // Use appropriate data based on zoom
964
- * const featureData = zoom < 12
965
- * ? lodData.simplifiedFeatures?.get(10)
966
- * : zoom < 14
967
- * ? lodData.simplifiedFeatures?.get(12)
968
- * : lodData.features;
969
- * ```
970
- */
971
- declare function generateLODDataWithSimplification(geojson: GeoJSONFeatureCollection, options: GenerateLODOptions): LODDataWithSimplification;
972
- /**
973
- * Get the appropriate feature collection for a given zoom level
974
- *
975
- * @param lodData LOD data with simplification
976
- * @param zoom Current zoom level
977
- * @returns The most appropriate feature collection for the zoom level
978
- */
979
- declare function getSimplifiedFeaturesForZoom(lodData: LODDataWithSimplification, zoom: number): GeoJSONFeatureCollection;
980
- /**
981
- * Calculate appropriate zoom thresholds based on feature density
982
- */
983
- declare function calculateZoomThresholds(groups: Map<string, FeatureGroup>, options?: {
984
- /** Target max features visible at any time */
985
- targetMaxFeatures?: number;
986
- /** Minimum zoom difference between levels */
987
- minZoomGap?: number;
988
- }): {
989
- groupMaxZoom: number;
990
- subGroupMaxZoom: number;
991
- };
992
- /**
993
- * Options for dynamic LOD threshold management
994
- */
995
- interface DynamicLODOptions {
996
- /** Base thresholds to start from */
997
- baseThresholds: {
998
- groupMaxZoom: number;
999
- subGroupMaxZoom: number;
1000
- };
1001
- /** Target FPS to maintain. Default: 50 */
1002
- targetFps?: number;
1003
- /** FPS threshold below which to start adjusting. Default: 40 */
1004
- adjustBelowFps?: number;
1005
- /** Maximum zoom adjustment allowed. Default: 3 */
1006
- maxAdjustment?: number;
1007
- /** Adjustment step per FPS drop. Default: 0.5 */
1008
- adjustmentStep?: number;
1009
- /** Smoothing factor for FPS averaging (0-1). Default: 0.3 */
1010
- smoothingFactor?: number;
1011
- /** Minimum time between adjustments in ms. Default: 1000 */
1012
- adjustmentCooldown?: number;
1013
- }
1014
- /**
1015
- * Current state of dynamic LOD thresholds
1016
- */
1017
- interface DynamicLODState {
1018
- /** Current adjusted thresholds */
1019
- thresholds: {
1020
- groupMaxZoom: number;
1021
- subGroupMaxZoom: number;
1022
- };
1023
- /** Current smoothed FPS */
1024
- averageFps: number;
1025
- /** Current adjustment level */
1026
- adjustment: number;
1027
- /** Whether thresholds are currently elevated */
1028
- isAdjusted: boolean;
1029
- }
1030
- /**
1031
- * Create a dynamic LOD threshold manager
1032
- *
1033
- * Automatically adjusts LOD zoom thresholds based on FPS to maintain
1034
- * smooth performance. When FPS drops, thresholds are raised to show
1035
- * aggregated views longer.
1036
- *
1037
- * @example
1038
- * ```tsx
1039
- * const lodManager = createDynamicLODManager({
1040
- * baseThresholds: { groupMaxZoom: 12, subGroupMaxZoom: 14 },
1041
- * targetFps: 50,
1042
- * });
1043
- *
1044
- * // In render loop or animation frame:
1045
- * useEffect(() => {
1046
- * let frameCount = 0;
1047
- * let lastTime = performance.now();
1048
- *
1049
- * const measure = () => {
1050
- * frameCount++;
1051
- * const now = performance.now();
1052
- * if (now - lastTime >= 1000) {
1053
- * const fps = frameCount;
1054
- * const state = lodManager.update(fps);
1055
- * setThresholds(state.thresholds);
1056
- * frameCount = 0;
1057
- * lastTime = now;
1058
- * }
1059
- * requestAnimationFrame(measure);
1060
- * };
1061
- *
1062
- * const id = requestAnimationFrame(measure);
1063
- * return () => cancelAnimationFrame(id);
1064
- * }, []);
1065
- * ```
1066
- */
1067
- declare function createDynamicLODManager(options: DynamicLODOptions): {
1068
- /** Update with current FPS and get adjusted thresholds */
1069
- update: (currentFps: number) => DynamicLODState;
1070
- /** Force reset to base thresholds */
1071
- reset: () => DynamicLODState;
1072
- /** Get current state without updating */
1073
- getState: () => DynamicLODState;
1074
- };
1075
- /**
1076
- * Get recommended simplification tolerance for a zoom level
1077
- *
1078
- * Returns an appropriate tolerance value for polygon simplification
1079
- * based on the current zoom level. Lower zoom = more simplification.
1080
- *
1081
- * @param zoom Current zoom level
1082
- * @param baseToleranceAtZoom14 Base tolerance to use at zoom 14. Default: 0.00002
1083
- * @returns Tolerance value in degrees
1084
- */
1085
- declare function getSimplificationToleranceForZoom(zoom: number, baseToleranceAtZoom14?: number): number;
1086
- /**
1087
- * Suggested default simplification thresholds
1088
- */
1089
- declare const DEFAULT_SIMPLIFICATION_THRESHOLDS: SimplificationThreshold[];
1090
-
1091
- /**
1092
- * Fast O(1) fingerprinting utilities for GeoJSON data equality checking.
1093
- *
1094
- * Instead of deep comparing potentially 100k+ features, we compare:
1095
- * - Feature count
1096
- * - First feature ID
1097
- * - Last feature ID
1098
- *
1099
- * This provides a fast, reliable check for most data update scenarios.
1100
- */
1101
-
1102
- /**
1103
- * Fingerprint structure for quick GeoJSON comparison
1104
- */
1105
- interface GeoJSONFingerprint {
1106
- /** Total number of features */
1107
- count: number;
1108
- /** ID of the first feature (undefined if no features or no ID) */
1109
- firstId: string | number | undefined;
1110
- /** ID of the last feature (undefined if no features or no ID) */
1111
- lastId: string | number | undefined;
1112
- }
1113
- /**
1114
- * Creates a fast O(1) fingerprint for a GeoJSON FeatureCollection.
1115
- *
1116
- * @param data - GeoJSON data to fingerprint
1117
- * @returns Fingerprint object or null if data is not a FeatureCollection
1118
- */
1119
- declare function createGeoJSONFingerprint(data: GeoJSONFeatureCollection | GeoJSON.GeoJSON | string | null | undefined): GeoJSONFingerprint | null;
1120
- /**
1121
- * Compares two GeoJSON fingerprints for equality.
1122
- *
1123
- * @param a - First fingerprint
1124
- * @param b - Second fingerprint
1125
- * @returns true if fingerprints match (data likely unchanged)
1126
- */
1127
- declare function fingerprintEqual(a: GeoJSONFingerprint | null, b: GeoJSONFingerprint | null): boolean;
1128
- /**
1129
- * Checks if two GeoJSON data objects are equal based on their fingerprints.
1130
- * This is a fast O(1) check that works for most practical scenarios.
1131
- *
1132
- * @param a - First GeoJSON data
1133
- * @param b - Second GeoJSON data
1134
- * @returns true if data is likely unchanged based on fingerprints
1135
- */
1136
- declare function geoJSONEqual(a: GeoJSONFeatureCollection | GeoJSON.GeoJSON | string | null | undefined, b: GeoJSONFeatureCollection | GeoJSON.GeoJSON | string | null | undefined): boolean;
1137
-
1138
- /**
1139
- * Equality and delta detection utilities for MapLibre properties.
1140
- *
1141
- * These utilities help prevent redundant MapLibre API calls by:
1142
- * - Detecting which paint properties actually changed
1143
- * - Comparing filter expressions efficiently
1144
- * - Tracking visibility state changes
1145
- */
1146
- /**
1147
- * Deep equality check for simple values (primitives, arrays, objects).
1148
- * Works for MapLibre expressions and paint property values.
1149
- */
1150
- declare function deepEqual(a: unknown, b: unknown): boolean;
1151
- /**
1152
- * Paint property object type
1153
- */
1154
- type PaintProps = Record<string, unknown>;
1155
- /**
1156
- * Checks if two paint property objects are equal.
1157
- *
1158
- * @param prev - Previous paint properties
1159
- * @param next - Next paint properties
1160
- * @returns true if all properties are equal
1161
- */
1162
- declare function paintPropsEqual(prev: PaintProps | undefined, next: PaintProps | undefined): boolean;
1163
- /**
1164
- * Result of paint property diff
1165
- */
1166
- interface PaintPropsDiff {
1167
- /** Properties that were added or changed */
1168
- changed: PaintProps;
1169
- /** Property names that were removed */
1170
- removed: string[];
1171
- /** Whether there are any changes */
1172
- hasChanges: boolean;
1173
- }
1174
- /**
1175
- * Gets only the paint properties that changed between two states.
1176
- * This allows for targeted setPaintProperty calls instead of updating everything.
1177
- *
1178
- * @param prev - Previous paint properties
1179
- * @param next - Next paint properties
1180
- * @returns Object containing only changed properties
1181
- */
1182
- declare function getChangedPaintProps(prev: PaintProps | undefined, next: PaintProps | undefined): PaintPropsDiff;
1183
- /**
1184
- * Filter expression type (MapLibre filter)
1185
- */
1186
- type FilterExpression = unknown[] | undefined | null;
1187
- /**
1188
- * Checks if two filter expressions are equal.
1189
- *
1190
- * @param prev - Previous filter
1191
- * @param next - Next filter
1192
- * @returns true if filters are equal
1193
- */
1194
- declare function filterEqual(prev: FilterExpression, next: FilterExpression): boolean;
1195
- /**
1196
- * Serializes a filter expression for comparison.
1197
- * Useful for storing last-applied filter state.
1198
- *
1199
- * @param filter - Filter expression
1200
- * @returns JSON string or empty string if no filter
1201
- */
1202
- declare function serializeFilter(filter: FilterExpression): string;
1203
-
1204
- /**
1205
- * Marker CSS Protection Utilities
1206
- *
1207
- * NOTE: DOM-based markers (maplibregl.Marker) are susceptible to CSS framework
1208
- * interference that can cause visual sliding during map pan/rotate operations.
1209
- * For production use cases requiring markers, consider using SymbolLayer instead,
1210
- * which renders on the GPU canvas and is immune to CSS interference.
1211
- *
1212
- * This module provides best-effort CSS protection for DOM markers, but it may not
1213
- * fully prevent sliding in all environments due to CSS specificity and timing issues.
1214
- */
1215
- /**
1216
- * Marker protection class name - used for CSS targeting
1217
- */
1218
- declare const MARKER_PROTECTION_CLASS = "ct-marker-protected";
1219
- /**
1220
- * Apply CSS protection to a marker element.
1221
- *
1222
- * This sets inline styles with !important to attempt to block CSS transitions.
1223
- * Note: This may not work in all environments - use SymbolLayer for guaranteed
1224
- * immunity from CSS interference.
1225
- *
1226
- * @param element - The marker's root HTMLElement (from marker.getElement())
1227
- */
1228
- declare function applyMarkerProtection(element: HTMLElement): void;
1229
- /**
1230
- * Remove protection from a marker element (cleanup function).
1231
- */
1232
- declare function removeMarkerProtection(element: HTMLElement): void;
1233
- /**
1234
- * Apply CSS protection to custom marker content (children/slots).
1235
- */
1236
- declare function applyMarkerChildProtection(element: HTMLElement): void;
1237
-
1238
11
  /**
1239
12
  * Built-in basemap definitions and utilities
1240
13
  */
@@ -1969,4 +742,4 @@ declare const clusterColorExpression: unknown[];
1969
742
  */
1970
743
  declare function createMatchedColorExpression(baseColorExpression: unknown[], matchedProperty?: string): unknown[];
1971
744
 
1972
- export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BasemapApiKeys, BasemapDefinition, BoundsArray, CATEGORY_META, CITY_LIMITS, CLASSIC_DARK, CLASSIC_LIGHT, type ClusterExpandOptions, type ClusterExpansionResult, type ClusterFeatureProperties, type ColorExpression, type ControlBoundingBox, type ControlDimensions, type ControlOffset, type ControlPriority, type ControlRegistration, type ControlType, type ControlUpdateOptions, type CoordinatorEvent, type CoordinatorEventType, type CoordinatorListener, DEFAULT_BASEMAP, DEFAULT_SIMPLIFICATION_THRESHOLDS, type DynamicLODOptions, type DynamicLODState, EDGE_MARGIN, type ExtendedControlPosition, type ExtrusionHeightOptions, FLOOD_ZONES, FREE_BASEMAPS, type FeatureGroup, type FilterExpression, type GenerateLODOptions, GeoJSONFeature, GeoJSONFeatureCollection, type GeoJSONFingerprint, GeoJSONPolygon, type GroupFeaturesOptions, type InventoryStatus, KEYBOARD_CONTROLS, type LODData, type LODDataWithSimplification, type LayerManagerProps, LngLat, type LoadGeoJSONOptions, type LoadGeoJSONResult, type LotAvailability, type LotFillStyleOptions, type LotOutlineStyleOptions, type LotSize, MAPTILER_BASIC, MAPTILER_OUTDOOR, MAPTILER_SATELLITE, MAPTILER_STREETS, MARKER_PROTECTION_CLASS, MapBounds, type MapDimensions, MapTheme, MarkerData, type NumberExpression, OSM_STANDARD, type OverlayApiKeys, type OverlayDataSource, type OverlayLayerCategory, type OverlayLayerCategoryMeta, type OverlayLayerDefinition, type OverlayLayerLegend, type OverlayLayerState, type OverlayLayerStyle, type OverlayLegendItem, PARKS, PRIMARY_BASEMAPS, PRIORITY_ORDER, type PaintProps, type PaintPropsDiff, type PositionConfig, PositioningCoordinator, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, STACK_GAP, STADIA_ALIDADE_DARK, STADIA_ALIDADE_SMOOTH, STADIA_STAMEN_TERRAIN, STADIA_STAMEN_TONER, STADIA_STAMEN_WATERCOLOR, type SimplificationStats, type SimplificationThreshold, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, type ValidationResult, WATERSHEDS, type ZIndexLayer, ZONING_DISTRICTS, Z_INDEX_LAYERS, applyMarkerChildProtection, applyMarkerProtection, boundaryColors, boundsToPolygon, calculateBounds, calculateCentroid, calculateZoomThresholds, clusterColorExpression, clusterColors, combineBounds, countFeaturesByType, createCategoricalColorExpression, createCircleStyle, createContinuousColorExpression, createDynamicLODManager, createExtrusionHeightExpression, createExtrusionStyle, createFillStyle, createGeoJSONFingerprint, createHeatmapStyle, createHoverExpression, createInitialLayerStates, createInteractiveExpression, createInteractiveStatusColorExpression, createLineStyle, createLotFillStyle, createLotOutlineStyle, createMatchedColorExpression, createPositioningCoordinator, createSelectionExpression, createStatusColorExpression, createZoomExpression, decimalToDMS, deepEqual, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, filterEqual, fingerprintEqual, formatArea, formatBearing, formatBounds, formatCoordinates, formatDistance, formatFeatureProperties, formatLabel, formatPitch, formatPropertyValue, formatScale, formatZoom, generateBoundingPolygon, generateConvexHull, generateFeatureCollectionDescription, generateFeatureTable, generateKeyboardControlsDescription, generateLODData, generateLODDataWithSimplification, generateMapDescription, generateMarkerList, generateMarkersDescription, generateMoveAnnouncement, geoJSONEqual, getAvailabilityColor, getAvailableBasemaps, getChangedPaintProps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getContrastTextColor, getHighlightStyle, getLayerCategories, getLayerStatesArray, getLayerStyleForTheme, getLayersByCategory, getLayersWithErrors, getSelectionStyle, getSimplificationToleranceForZoom, getSimplifiedFeaturesForZoom, getSizeColor, getVisibleLayerIds, groupFeaturesByProperty, groupLayersByCategory, hideAllLayers, inventoryStatusColorExpression, inventoryStatusColors, isAnyLayerLoading, isClusterFeature, isValidBounds, loadGeoJSON, lotAvailabilityColorExpression, lotAvailabilityColors, lotSizeColorExpression, lotSizeColors, nonMatchedColor, paintPropsEqual, removeMarkerProtection, reorderLayers, resolveBasemapStyle, resolveBasemapThumbnail, resolveLayerSourceUrl, salesOfficeColor, searchLayers, serializeFilter, setLayerError, setLayerLoading, setLayerOpacity, showAllLayers, simplifyFeature, simplifyFeatureCollection, simplifyFeatureCollectionWithStats, simplifyPolygon, toggleLayerVisibility, updateLayerState, validateGeoJSON, zoomToScale };
745
+ export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BasemapApiKeys, BasemapDefinition, CATEGORY_META, CITY_LIMITS, CLASSIC_DARK, CLASSIC_LIGHT, type ControlBoundingBox, type ControlDimensions, type ControlOffset, type ControlPriority, type ControlRegistration, type ControlType, type ControlUpdateOptions, type CoordinatorEvent, type CoordinatorEventType, type CoordinatorListener, DEFAULT_BASEMAP, EDGE_MARGIN, type ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, GeoJSONFeatureCollection, type InventoryStatus, type LayerManagerProps, type LotAvailability, type LotSize, MAPTILER_BASIC, MAPTILER_OUTDOOR, MAPTILER_SATELLITE, MAPTILER_STREETS, type MapDimensions, OSM_STANDARD, type OverlayApiKeys, type OverlayDataSource, type OverlayLayerCategory, type OverlayLayerCategoryMeta, type OverlayLayerDefinition, type OverlayLayerLegend, type OverlayLayerState, type OverlayLayerStyle, type OverlayLegendItem, PARKS, PRIMARY_BASEMAPS, PRIORITY_ORDER, type PositionConfig, PositioningCoordinator, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, STACK_GAP, STADIA_ALIDADE_DARK, STADIA_ALIDADE_SMOOTH, STADIA_STAMEN_TERRAIN, STADIA_STAMEN_TONER, STADIA_STAMEN_WATERCOLOR, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, WATERSHEDS, type ZIndexLayer, ZONING_DISTRICTS, Z_INDEX_LAYERS, boundaryColors, clusterColorExpression, clusterColors, createInitialLayerStates, createMatchedColorExpression, createPositioningCoordinator, getAvailabilityColor, getAvailableBasemaps, getContrastTextColor, getLayerCategories, getLayerStatesArray, getLayerStyleForTheme, getLayersByCategory, getLayersWithErrors, getSizeColor, getVisibleLayerIds, groupLayersByCategory, hideAllLayers, inventoryStatusColorExpression, inventoryStatusColors, isAnyLayerLoading, lotAvailabilityColorExpression, lotAvailabilityColors, lotSizeColorExpression, lotSizeColors, nonMatchedColor, reorderLayers, resolveBasemapStyle, resolveBasemapThumbnail, resolveLayerSourceUrl, salesOfficeColor, searchLayers, setLayerError, setLayerLoading, setLayerOpacity, showAllLayers, toggleLayerVisibility, updateLayerState };