@accelint/map-toolkit 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/catalog-info.yaml +4 -4
- package/dist/camera/events.js +1 -1
- package/dist/camera/index.d.ts +1 -1
- package/dist/camera/index.js +1 -1
- package/dist/camera/store.d.ts +1 -1
- package/dist/camera/store.js +3 -5
- package/dist/camera/store.js.map +1 -1
- package/dist/camera/types.d.ts +1 -1
- package/dist/camera/types.js +1 -1
- package/dist/cursor-coordinates/constants.js +1 -1
- package/dist/cursor-coordinates/index.d.ts +1 -1
- package/dist/cursor-coordinates/index.js +1 -1
- package/dist/cursor-coordinates/store.d.ts +1 -1
- package/dist/cursor-coordinates/store.js +1 -1
- package/dist/cursor-coordinates/types.d.ts +1 -1
- package/dist/cursor-coordinates/types.js +1 -1
- package/dist/cursor-coordinates/use-cursor-coordinates.d.ts +1 -1
- package/dist/cursor-coordinates/use-cursor-coordinates.js +4 -9
- package/dist/cursor-coordinates/use-cursor-coordinates.js.map +1 -1
- package/dist/deckgl/base-map/constants.js +1 -1
- package/dist/deckgl/base-map/controls.d.ts +1 -1
- package/dist/deckgl/base-map/controls.js +1 -1
- package/dist/deckgl/base-map/events.js +1 -1
- package/dist/deckgl/base-map/index.d.ts +1 -1
- package/dist/deckgl/base-map/index.js +1 -1
- package/dist/deckgl/base-map/provider.d.ts +3 -3
- package/dist/deckgl/base-map/provider.js +1 -1
- package/dist/deckgl/base-map/types.d.ts +1 -1
- package/dist/deckgl/base-map/types.js +1 -1
- package/dist/deckgl/index.d.ts +4 -4
- package/dist/deckgl/index.js +1 -1
- package/dist/deckgl/saved-viewports/index.d.ts +1 -1
- package/dist/deckgl/saved-viewports/index.js +1 -1
- package/dist/deckgl/saved-viewports/storage.d.ts +1 -1
- package/dist/deckgl/saved-viewports/storage.js +5 -10
- package/dist/deckgl/saved-viewports/storage.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/constants.js +66 -13
- package/dist/deckgl/shapes/display-shape-layer/constants.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/fiber.d.ts +1 -1
- package/dist/deckgl/shapes/display-shape-layer/fiber.js +1 -1
- package/dist/deckgl/shapes/display-shape-layer/index.d.ts +74 -35
- package/dist/deckgl/shapes/display-shape-layer/index.js +381 -154
- package/dist/deckgl/shapes/display-shape-layer/index.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/shape-label-layer.js +1 -1
- package/dist/deckgl/shapes/display-shape-layer/store.js +1 -1
- package/dist/deckgl/shapes/display-shape-layer/types.d.ts +108 -19
- package/dist/deckgl/shapes/display-shape-layer/types.js +1 -1
- package/dist/deckgl/shapes/display-shape-layer/use-select-shape.d.ts +1 -1
- package/dist/deckgl/shapes/display-shape-layer/use-select-shape.js +1 -1
- package/dist/deckgl/shapes/display-shape-layer/utils/display-style.js +66 -36
- package/dist/deckgl/shapes/display-shape-layer/utils/display-style.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/utils/elevation.js +407 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/elevation.js.map +1 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/icon-config.js +151 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/icon-config.js.map +1 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/interaction.js +50 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/interaction.js.map +1 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/labels.d.ts +1 -1
- package/dist/deckgl/shapes/display-shape-layer/utils/labels.js +28 -39
- package/dist/deckgl/shapes/display-shape-layer/utils/labels.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/constants.js +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/events.d.ts +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/events.js +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/fiber.js +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/index.d.ts +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/index.js +4 -14
- package/dist/deckgl/shapes/draw-shape-layer/index.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js +2 -3
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js +2 -19
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js +2 -32
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js +9 -10
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/index.js +2 -32
- package/dist/deckgl/shapes/draw-shape-layer/modes/index.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/store.js +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/types.d.ts +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/types.js +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.d.ts +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.js +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/utils/feature-conversion.js +3 -8
- package/dist/deckgl/shapes/draw-shape-layer/utils/feature-conversion.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/constants.js +17 -2
- package/dist/deckgl/shapes/edit-shape-layer/constants.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/events.d.ts +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/events.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/fiber.d.ts +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/fiber.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/index.d.ts +5 -2
- package/dist/deckgl/shapes/edit-shape-layer/index.js +51 -20
- package/dist/deckgl/shapes/edit-shape-layer/index.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/base-transform-mode.js +4 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/base-transform-mode.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/index.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/point-translate-mode.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/point-translate-mode.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/rotate-mode-with-snap.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/rotate-mode-with-snap.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/scale-mode-with-free-transform.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/scale-mode-with-free-transform.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/vertex-transform-mode.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/vertex-transform-mode.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/store.js +70 -12
- package/dist/deckgl/shapes/edit-shape-layer/store.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/types.d.ts +14 -2
- package/dist/deckgl/shapes/edit-shape-layer/types.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.d.ts +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js +1 -1
- package/dist/deckgl/shapes/index.d.ts +4 -4
- package/dist/deckgl/shapes/index.js +1 -1
- package/dist/deckgl/shapes/shared/constants.d.ts +4 -3
- package/dist/deckgl/shapes/shared/constants.js +50 -10
- package/dist/deckgl/shapes/shared/constants.js.map +1 -1
- package/dist/deckgl/shapes/shared/events.d.ts +5 -1
- package/dist/deckgl/shapes/shared/events.js +1 -1
- package/dist/deckgl/shapes/shared/events.js.map +1 -1
- package/dist/deckgl/shapes/shared/hooks/use-shift-zoom-disable.js +19 -16
- package/dist/deckgl/shapes/shared/hooks/use-shift-zoom-disable.js.map +1 -1
- package/dist/deckgl/shapes/shared/types.d.ts +174 -53
- package/dist/deckgl/shapes/shared/types.js +155 -2
- package/dist/deckgl/shapes/shared/types.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/geometry-measurements.js +29 -24
- package/dist/deckgl/shapes/shared/utils/geometry-measurements.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/layer-config.js +8 -5
- package/dist/deckgl/shapes/shared/utils/layer-config.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/mode-utils.js +50 -20
- package/dist/deckgl/shapes/shared/utils/mode-utils.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/pick-filtering.js +22 -15
- package/dist/deckgl/shapes/shared/utils/pick-filtering.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/style-utils.d.ts +38 -14
- package/dist/deckgl/shapes/shared/utils/style-utils.js +43 -32
- package/dist/deckgl/shapes/shared/utils/style-utils.js.map +1 -1
- package/dist/deckgl/symbol-layer/fiber.d.ts +1 -1
- package/dist/deckgl/symbol-layer/fiber.js +1 -1
- package/dist/deckgl/symbol-layer/index.d.ts +1 -1
- package/dist/deckgl/symbol-layer/index.js +1 -1
- package/dist/deckgl/text-layer/character-sets.js +1 -1
- package/dist/deckgl/text-layer/default-settings.d.ts +1 -1
- package/dist/deckgl/text-layer/default-settings.js +1 -1
- package/dist/deckgl/text-layer/fiber.d.ts +1 -1
- package/dist/deckgl/text-layer/fiber.js +1 -1
- package/dist/deckgl/text-layer/index.d.ts +1 -1
- package/dist/deckgl/text-layer/index.js +1 -1
- package/dist/deckgl/text-settings.d.ts +3 -3
- package/dist/deckgl/text-settings.js +1 -1
- package/dist/map-cursor/events.js +1 -1
- package/dist/map-cursor/index.d.ts +1 -1
- package/dist/map-cursor/index.js +1 -1
- package/dist/map-cursor/store.d.ts +1 -1
- package/dist/map-cursor/store.js +1 -1
- package/dist/map-cursor/types.d.ts +1 -1
- package/dist/map-cursor/types.js +1 -1
- package/dist/map-cursor/use-map-cursor.d.ts +1 -1
- package/dist/map-cursor/use-map-cursor.js +1 -1
- package/dist/map-mode/events.js +1 -1
- package/dist/map-mode/index.d.ts +1 -1
- package/dist/map-mode/index.js +1 -1
- package/dist/map-mode/store.d.ts +1 -1
- package/dist/map-mode/store.js +3 -8
- package/dist/map-mode/store.js.map +1 -1
- package/dist/map-mode/types.d.ts +1 -1
- package/dist/map-mode/types.js +1 -1
- package/dist/map-mode/use-map-mode.d.ts +1 -1
- package/dist/map-mode/use-map-mode.js +1 -1
- package/dist/maplibre/hooks/use-maplibre.d.ts +1 -1
- package/dist/maplibre/hooks/use-maplibre.js +1 -1
- package/dist/maplibre/index.d.ts +1 -1
- package/dist/maplibre/index.js +1 -1
- package/dist/shared/cleanup.d.ts +1 -1
- package/dist/shared/cleanup.js +1 -1
- package/dist/shared/constants.js +1 -1
- package/dist/shared/create-map-store.d.ts +1 -1
- package/dist/shared/create-map-store.js +1 -1
- package/dist/shared/logger.js +31 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/units.js +1 -1
- package/dist/viewport/index.d.ts +1 -1
- package/dist/viewport/index.js +1 -1
- package/dist/viewport/store.d.ts +1 -1
- package/dist/viewport/store.js +1 -1
- package/dist/viewport/types.d.ts +1 -1
- package/dist/viewport/types.js +1 -1
- package/dist/viewport/utils.d.ts +1 -1
- package/dist/viewport/utils.js +1 -1
- package/dist/viewport/viewport-size.d.ts +3 -3
- package/dist/viewport/viewport-size.js +1 -1
- package/package.json +22 -20
- package/dist/hotkey-manager/dist/react/use-hotkey.js +0 -39
- package/dist/hotkey-manager/dist/react/use-hotkey.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -28,6 +28,9 @@ const ShapeFeatureType = {
|
|
|
28
28
|
/**
|
|
29
29
|
* Type guard for Circle shapes.
|
|
30
30
|
*
|
|
31
|
+
* @param shape - The shape to test.
|
|
32
|
+
* @returns True if shape is a CircleShape.
|
|
33
|
+
*
|
|
31
34
|
* @example
|
|
32
35
|
* ```typescript
|
|
33
36
|
* if (isCircleShape(shape)) {
|
|
@@ -42,6 +45,9 @@ function isCircleShape(shape) {
|
|
|
42
45
|
/**
|
|
43
46
|
* Type guard for Ellipse shapes.
|
|
44
47
|
*
|
|
48
|
+
* @param shape - The shape to test.
|
|
49
|
+
* @returns True if shape is an EllipseShape.
|
|
50
|
+
*
|
|
45
51
|
* @example
|
|
46
52
|
* ```typescript
|
|
47
53
|
* if (isEllipseShape(shape)) {
|
|
@@ -55,29 +61,176 @@ function isEllipseShape(shape) {
|
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* Type guard for Polygon shapes.
|
|
64
|
+
*
|
|
65
|
+
* @param shape - The shape to test
|
|
66
|
+
* @returns True if shape is a PolygonShape
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* if (isPolygonShape(shape)) {
|
|
70
|
+
* // TypeScript narrows shape to PolygonShape
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
58
73
|
*/
|
|
59
74
|
function isPolygonShape(shape) {
|
|
60
75
|
return shape.shape === ShapeFeatureType.Polygon;
|
|
61
76
|
}
|
|
62
77
|
/**
|
|
63
78
|
* Type guard for Rectangle shapes.
|
|
79
|
+
*
|
|
80
|
+
* @param shape - The shape to test
|
|
81
|
+
* @returns True if shape is a RectangleShape
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* if (isRectangleShape(shape)) {
|
|
85
|
+
* // TypeScript narrows shape to RectangleShape
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
64
88
|
*/
|
|
65
89
|
function isRectangleShape(shape) {
|
|
66
90
|
return shape.shape === ShapeFeatureType.Rectangle;
|
|
67
91
|
}
|
|
68
92
|
/**
|
|
69
93
|
* Type guard for LineString shapes.
|
|
94
|
+
*
|
|
95
|
+
* @param shape - The shape to test
|
|
96
|
+
* @returns True if shape is a LineStringShape
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* if (isLineStringShape(shape)) {
|
|
100
|
+
* // TypeScript narrows shape to LineStringShape
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
70
103
|
*/
|
|
71
104
|
function isLineStringShape(shape) {
|
|
72
105
|
return shape.shape === ShapeFeatureType.LineString;
|
|
73
106
|
}
|
|
74
107
|
/**
|
|
75
108
|
* Type guard for Point shapes.
|
|
109
|
+
*
|
|
110
|
+
* @param shape - The shape to test
|
|
111
|
+
* @returns True if shape is a PointShape
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* if (isPointShape(shape)) {
|
|
115
|
+
* // TypeScript narrows shape to PointShape
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
76
118
|
*/
|
|
77
119
|
function isPointShape(shape) {
|
|
78
120
|
return shape.shape === ShapeFeatureType.Point;
|
|
79
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Narrow a GeoJSON geometry to the Point type.
|
|
124
|
+
*
|
|
125
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
126
|
+
* @returns True if the geometry is a Point.
|
|
127
|
+
*/
|
|
128
|
+
function isPointType(geometry) {
|
|
129
|
+
return geometry.type === "Point";
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Narrow a GeoJSON geometry to the MultiPoint type.
|
|
133
|
+
*
|
|
134
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
135
|
+
* @returns True if the geometry is a MultiPoint.
|
|
136
|
+
*/
|
|
137
|
+
function isMultiPointType(geometry) {
|
|
138
|
+
return geometry.type === "MultiPoint";
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Narrow a GeoJSON geometry to the LineString type.
|
|
142
|
+
*
|
|
143
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
144
|
+
* @returns True if the geometry is a LineString.
|
|
145
|
+
*/
|
|
146
|
+
function isLineStringType(geometry) {
|
|
147
|
+
return geometry.type === "LineString";
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Narrow a GeoJSON geometry to the MultiLineString type.
|
|
151
|
+
*
|
|
152
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
153
|
+
* @returns True if the geometry is a MultiLineString.
|
|
154
|
+
*/
|
|
155
|
+
function isMultiLineStringType(geometry) {
|
|
156
|
+
return geometry.type === "MultiLineString";
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Narrow a GeoJSON geometry to the Polygon type.
|
|
160
|
+
*
|
|
161
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
162
|
+
* @returns True if the geometry is a Polygon.
|
|
163
|
+
*/
|
|
164
|
+
function isPolygonType(geometry) {
|
|
165
|
+
return geometry.type === "Polygon";
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Narrow a GeoJSON geometry to the MultiPolygon type.
|
|
169
|
+
*
|
|
170
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
171
|
+
* @returns True if the geometry is a MultiPolygon.
|
|
172
|
+
*/
|
|
173
|
+
function isMultiPolygonType(geometry) {
|
|
174
|
+
return geometry.type === "MultiPolygon";
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Narrow a GeoJSON geometry to the GeometryCollection type.
|
|
178
|
+
*
|
|
179
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
180
|
+
* @returns True if the geometry is a GeometryCollection.
|
|
181
|
+
*/
|
|
182
|
+
function isGeometryCollectionType(geometry) {
|
|
183
|
+
return geometry.type === "GeometryCollection";
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Narrow a GeoJSON geometry to polygon-like types (Polygon or MultiPolygon).
|
|
187
|
+
*
|
|
188
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
189
|
+
* @returns True if the geometry is a Polygon or MultiPolygon.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* if (isPolygonGeometry(feature.geometry)) {
|
|
194
|
+
* // geometry narrowed to Polygon | MultiPolygon
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
function isPolygonGeometry(geometry) {
|
|
199
|
+
return geometry.type === "Polygon" || geometry.type === "MultiPolygon";
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Narrow a GeoJSON geometry to line-like types (LineString or MultiLineString).
|
|
203
|
+
*
|
|
204
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
205
|
+
* @returns True if the geometry is a LineString or MultiLineString.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* if (isLineGeometry(feature.geometry)) {
|
|
210
|
+
* // geometry narrowed to LineString | MultiLineString
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
function isLineGeometry(geometry) {
|
|
215
|
+
return geometry.type === "LineString" || geometry.type === "MultiLineString";
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Narrow a GeoJSON geometry to point-like types (Point or MultiPoint).
|
|
219
|
+
*
|
|
220
|
+
* @param geometry - The GeoJSON geometry to test.
|
|
221
|
+
* @returns True if the geometry is a Point or MultiPoint.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* if (isPointGeometry(feature.geometry)) {
|
|
226
|
+
* // geometry narrowed to Point | MultiPoint
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
function isPointGeometry(geometry) {
|
|
231
|
+
return geometry.type === "Point" || geometry.type === "MultiPoint";
|
|
232
|
+
}
|
|
80
233
|
|
|
81
234
|
//#endregion
|
|
82
|
-
export { ShapeFeatureType, isCircleShape, isEllipseShape, isLineStringShape, isPointShape, isPolygonShape, isRectangleShape };
|
|
235
|
+
export { ShapeFeatureType, isCircleShape, isEllipseShape, isGeometryCollectionType, isLineGeometry, isLineStringShape, isLineStringType, isMultiLineStringType, isMultiPointType, isMultiPolygonType, isPointGeometry, isPointShape, isPointType, isPolygonGeometry, isPolygonShape, isPolygonType, isRectangleShape };
|
|
83
236
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/deckgl/shapes/shared/types.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\n\nimport type { UniqueId } from '@accelint/core';\nimport type { Color } from '@deck.gl/core';\nimport type { Feature, LineString, Point, Polygon } from 'geojson';\nimport type { DistanceUnit } from '@/shared/units';\n\n/**\n * Supported shape types\n */\nexport const ShapeFeatureType = {\n Circle: 'Circle',\n Ellipse: 'Ellipse',\n Polygon: 'Polygon',\n Rectangle: 'Rectangle',\n LineString: 'LineString',\n Point: 'Point',\n} as const;\n\nexport type ShapeFeatureType =\n (typeof ShapeFeatureType)[keyof typeof ShapeFeatureType];\n\n/**\n * Shape ID type - uses UniqueId from core\n */\nexport type ShapeId = UniqueId;\n\n/**\n * Border/outline width options (in pixels).\n * Controls the width of shape outlines.\n */\nexport type LineWidth = 1 | 2 | 4 | 8;\n\n/**\n * Border/outline pattern options.\n * Controls how shape outlines are rendered.\n */\nexport type LinePattern = 'solid' | 'dashed' | 'dotted';\n\n/**\n * Style properties for rendering shapes\n */\nexport interface StyleProperties {\n /** Fill color as RGBA array [r, g, b, a] where each value is 0-255 */\n fillColor: Color;\n /** Border/outline color as RGBA array [r, g, b, a] where each value is 0-255 */\n lineColor: Color;\n /** Border/outline width in pixels */\n lineWidth: LineWidth;\n /** Border/outline pattern (solid, dashed, or dotted) */\n linePattern: LinePattern;\n /** Optional icon properties for Point geometries */\n icon?: {\n /** Icon atlas URL or data */\n atlas?: string;\n /** Icon mapping (name to position in atlas) */\n mapping?: Record<\n string,\n { x: number; y: number; width: number; height: number; mask?: boolean }\n >;\n /** Icon name to use from mapping */\n name?: string;\n /** Icon size in pixels */\n size?: number;\n };\n /** Optional custom label pixel offset [x, y] */\n labelOffset?: [number, number];\n /** Optional custom label vertical anchor */\n labelVerticalAnchor?: 'top' | 'middle' | 'bottom';\n /** Optional custom label horizontal anchor */\n labelHorizontalAnchor?: 'left' | 'center' | 'right';\n /** Optional custom label coordinate anchor (position along geometry) */\n labelCoordinateAnchor?:\n | 'center'\n | 'start'\n | 'middle'\n | 'end'\n | 'top'\n | 'right'\n | 'bottom'\n | 'left';\n}\n\n/**\n * Circle-specific properties for precise rendering\n * Stored alongside the polygon approximation\n */\nexport interface CircleProperties {\n /** Center point as [longitude, latitude] */\n center: [number, number];\n /** Radius with value and units */\n radius: {\n /** Radius value */\n value: number;\n /** Units for the radius measurement */\n units: DistanceUnit;\n };\n}\n\n/**\n * Ellipse-specific properties for precise rendering\n * Stored alongside the polygon approximation\n */\nexport interface EllipseProperties {\n /** Center point as [longitude, latitude] */\n center: [number, number];\n /** X semi-axis (horizontal radius) with value and units */\n xSemiAxis: {\n /** X semi-axis value */\n value: number;\n /** Units for the measurement */\n units: DistanceUnit;\n };\n /** Y semi-axis (vertical radius) with value and units */\n ySemiAxis: {\n /** Y semi-axis value */\n value: number;\n /** Units for the measurement */\n units: DistanceUnit;\n };\n /** Rotation angle in degrees */\n angle: number;\n}\n\n/**\n * Custom geometry types supported\n */\nexport type CustomGeometry = Point | LineString | Polygon;\n\n/**\n * Properties for styled features.\n *\n * Note: circleProperties and ellipseProperties are optional at the type level\n * but are guaranteed to be present for their respective shape types.\n * Use the type guards (isCircleShape, isEllipseShape) for type narrowing.\n */\nexport interface StyledFeatureProperties {\n /** Style properties for rendering */\n styleProperties: StyleProperties;\n /** Shape ID for correlation */\n shapeId?: ShapeId;\n /** Circle properties (present for Circle shapes) */\n circleProperties?: CircleProperties;\n /** Ellipse properties (present for Ellipse shapes) */\n ellipseProperties?: EllipseProperties;\n}\n\n/**\n * Feature properties for Circle shapes (circleProperties required).\n * Used by CircleShape for better type narrowing.\n */\nexport interface CircleFeatureProperties extends StyledFeatureProperties {\n /** Circle properties (required for Circle shapes) */\n circleProperties: CircleProperties;\n}\n\n/**\n * Feature properties for Ellipse shapes (ellipseProperties required).\n * Used by EllipseShape for better type narrowing.\n */\nexport interface EllipseFeatureProperties extends StyledFeatureProperties {\n /** Ellipse properties (required for Ellipse shapes) */\n ellipseProperties: EllipseProperties;\n}\n\n/**\n * GeoJSON Feature with style properties\n */\nexport interface StyledFeature extends Feature {\n properties: StyledFeatureProperties;\n}\n\n/**\n * Base shape properties shared by all shapes\n */\ninterface BaseShape {\n /** Unique identifier */\n id: ShapeId;\n /** Full shape name used internally and in UI */\n name: string;\n /**\n * Optional short display label shown on the map\n * If not provided, the `name` property will be used instead\n * Useful for showing abbreviated text on the map (e.g., \"NYC\" vs \"New York City Office\")\n */\n label?: string;\n /** GeoJSON feature with geometry and style properties */\n feature: ShapeFeature;\n /** UTC timestamp (only set when saved) */\n lastUpdated?: number;\n /**\n * Whether the shape is locked for editing\n * Locked shapes cannot be modified due to data restrictions or user preference\n */\n locked?: boolean;\n}\n\n/**\n * Circle shape with required circleProperties\n */\nexport interface CircleShape extends BaseShape {\n shape: typeof ShapeFeatureType.Circle;\n feature: StyledFeature & { properties: CircleFeatureProperties };\n}\n\n/**\n * Ellipse shape with required ellipseProperties\n */\nexport interface EllipseShape extends BaseShape {\n shape: typeof ShapeFeatureType.Ellipse;\n feature: StyledFeature & { properties: EllipseFeatureProperties };\n}\n\n/**\n * Polygon shape\n */\nexport interface PolygonShape extends BaseShape {\n shape: typeof ShapeFeatureType.Polygon;\n feature: StyledFeature;\n}\n\n/**\n * Rectangle shape\n */\nexport interface RectangleShape extends BaseShape {\n shape: typeof ShapeFeatureType.Rectangle;\n feature: StyledFeature;\n}\n\n/**\n * LineString shape\n */\nexport interface LineStringShape extends BaseShape {\n shape: typeof ShapeFeatureType.LineString;\n feature: StyledFeature;\n}\n\n/**\n * Point shape\n */\nexport interface PointShape extends BaseShape {\n shape: typeof ShapeFeatureType.Point;\n feature: StyledFeature;\n}\n\n/**\n * Discriminated union of all shape types.\n *\n * Use this for type narrowing based on shape:\n * @example\n * ```typescript\n * function handleShape(shape: Shape) {\n * if (shape.shape === 'Circle') {\n * // TypeScript knows shape.feature.properties.circleProperties exists\n * const { center, radius } = shape.feature.properties.circleProperties;\n * }\n * }\n * ```\n */\nexport type Shape =\n | CircleShape\n | EllipseShape\n | PolygonShape\n | RectangleShape\n | LineStringShape\n | PointShape;\n\n/**\n * Alias for ShapeFeatureType values\n */\nexport type ShapeFeatureTypeValues = ShapeFeatureType;\n\n/**\n * Alias for StyledFeature (shape feature)\n */\nexport type ShapeFeature = StyledFeature;\n\n/**\n * Alias for StyledFeature properties\n */\nexport type ShapeFeatureProperties = StyledFeature['properties'];\n\n/**\n * Circle radius type\n */\nexport type CircleRadius = CircleProperties['radius'];\n\n/**\n * Coordinate as [longitude, latitude]\n */\nexport type Coordinate = [number, number];\n\n/**\n * Function type for subscription (useSyncExternalStore pattern).\n * Used by draw-shape-layer and edit-shape-layer stores.\n */\nexport type Subscription = (onStoreChange: () => void) => () => void;\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\n/**\n * Type guard for Circle shapes.\n *\n * @example\n * ```typescript\n * if (isCircleShape(shape)) {\n * // shape.feature.properties.circleProperties is available\n * const { center, radius } = shape.feature.properties.circleProperties;\n * }\n * ```\n */\nexport function isCircleShape(shape: Shape): shape is CircleShape {\n return shape.shape === ShapeFeatureType.Circle;\n}\n\n/**\n * Type guard for Ellipse shapes.\n *\n * @example\n * ```typescript\n * if (isEllipseShape(shape)) {\n * // shape.feature.properties.ellipseProperties is available\n * const { center, xSemiAxis, ySemiAxis } = shape.feature.properties.ellipseProperties;\n * }\n * ```\n */\nexport function isEllipseShape(shape: Shape): shape is EllipseShape {\n return shape.shape === ShapeFeatureType.Ellipse;\n}\n\n/**\n * Type guard for Polygon shapes.\n */\nexport function isPolygonShape(shape: Shape): shape is PolygonShape {\n return shape.shape === ShapeFeatureType.Polygon;\n}\n\n/**\n * Type guard for Rectangle shapes.\n */\nexport function isRectangleShape(shape: Shape): shape is RectangleShape {\n return shape.shape === ShapeFeatureType.Rectangle;\n}\n\n/**\n * Type guard for LineString shapes.\n */\nexport function isLineStringShape(shape: Shape): shape is LineStringShape {\n return shape.shape === ShapeFeatureType.LineString;\n}\n\n/**\n * Type guard for Point shapes.\n */\nexport function isPointShape(shape: Shape): shape is PointShape {\n return shape.shape === ShapeFeatureType.Point;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,SAAS;CACT,SAAS;CACT,WAAW;CACX,YAAY;CACZ,OAAO;CACR;;;;;;;;;;;;AAwSD,SAAgB,cAAc,OAAoC;AAChE,QAAO,MAAM,UAAU,iBAAiB;;;;;;;;;;;;;AAc1C,SAAgB,eAAe,OAAqC;AAClE,QAAO,MAAM,UAAU,iBAAiB;;;;;AAM1C,SAAgB,eAAe,OAAqC;AAClE,QAAO,MAAM,UAAU,iBAAiB;;;;;AAM1C,SAAgB,iBAAiB,OAAuC;AACtE,QAAO,MAAM,UAAU,iBAAiB;;;;;AAM1C,SAAgB,kBAAkB,OAAwC;AACxE,QAAO,MAAM,UAAU,iBAAiB;;;;;AAM1C,SAAgB,aAAa,OAAmC;AAC9D,QAAO,MAAM,UAAU,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/deckgl/shapes/shared/types.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\n\nimport type { UniqueId } from '@accelint/core';\nimport type { Color } from '@deck.gl/core';\nimport type {\n Feature,\n Geometry,\n GeometryCollection,\n LineString,\n MultiLineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from 'geojson';\nimport type { DistanceUnit } from '@/shared/units';\n\n/**\n * Supported shape types\n */\nexport const ShapeFeatureType = {\n Circle: 'Circle',\n Ellipse: 'Ellipse',\n Polygon: 'Polygon',\n Rectangle: 'Rectangle',\n LineString: 'LineString',\n Point: 'Point',\n} as const;\n\n/** Union of all supported shape feature type string literals. */\nexport type ShapeFeatureType =\n (typeof ShapeFeatureType)[keyof typeof ShapeFeatureType];\n\n/**\n * Shape ID type - uses UniqueId from core\n */\nexport type ShapeId = UniqueId;\n\n/**\n * Border/outline width options (in pixels).\n * Controls the width of shape outlines.\n */\nexport type LineWidth = 1 | 2 | 4 | 8;\n\n/**\n * Border/outline pattern options.\n * Controls how shape outlines are rendered.\n */\nexport type LinePattern = 'solid' | 'dashed' | 'dotted';\n\n/**\n * Style properties for rendering shapes\n */\nexport type StyleProperties = {\n /** Fill color as RGBA array [r, g, b, a] where each value is 0-255 */\n fillColor: Color;\n /** Border/outline color as RGBA array [r, g, b, a] where each value is 0-255 */\n lineColor: Color;\n /** Border/outline width in pixels */\n lineWidth: LineWidth;\n /** Border/outline pattern (solid, dashed, or dotted) */\n linePattern: LinePattern;\n /** Optional icon properties for Point geometries */\n icon?: {\n /** Icon atlas URL or data */\n atlas?: string;\n /** Icon mapping (name to position in atlas) */\n mapping?: Record<\n string,\n { x: number; y: number; width: number; height: number; mask?: boolean }\n >;\n /** Icon name to use from mapping */\n name?: string;\n /** Icon size in pixels */\n size?: number;\n };\n /** Optional custom label pixel offset [x, y] */\n labelOffset?: [number, number];\n /** Optional custom label vertical anchor */\n labelVerticalAnchor?: 'top' | 'middle' | 'bottom';\n /** Optional custom label horizontal anchor */\n labelHorizontalAnchor?: 'left' | 'center' | 'right';\n /** Optional custom label coordinate anchor (position along geometry) */\n labelCoordinateAnchor?:\n | 'center'\n | 'start'\n | 'middle'\n | 'end'\n | 'top'\n | 'right'\n | 'bottom'\n | 'left';\n};\n\n/**\n * Circle-specific properties for precise rendering\n * Stored alongside the polygon approximation\n */\nexport type CircleProperties = {\n /** Center point as [longitude, latitude] or [longitude, latitude, elevation] */\n center: [number, number, number?];\n /** Radius with value and units */\n radius: {\n /** Radius value */\n value: number;\n /** Units for the radius measurement */\n units: DistanceUnit;\n };\n};\n\n/**\n * Ellipse-specific properties for precise rendering\n * Stored alongside the polygon approximation\n */\nexport type EllipseProperties = {\n /** Center point as [longitude, latitude] or [longitude, latitude, elevation] */\n center: [number, number, number?];\n /** X semi-axis (horizontal radius) with value and units */\n xSemiAxis: {\n /** X semi-axis value */\n value: number;\n /** Units for the measurement */\n units: DistanceUnit;\n };\n /** Y semi-axis (vertical radius) with value and units */\n ySemiAxis: {\n /** Y semi-axis value */\n value: number;\n /** Units for the measurement */\n units: DistanceUnit;\n };\n /** Rotation angle in degrees */\n angle: number;\n};\n\n/**\n * Properties for styled features.\n *\n * Note: circleProperties and ellipseProperties are optional at the type level\n * but are guaranteed to be present for their respective shape types.\n * Use the type guards (isCircleShape, isEllipseShape) for type narrowing.\n */\nexport type StyledFeatureProperties = {\n /** Style properties for rendering */\n styleProperties: StyleProperties;\n /** Shape ID for correlation */\n shapeId?: ShapeId;\n /** Circle properties (present for Circle shapes) */\n circleProperties?: CircleProperties;\n /** Ellipse properties (present for Ellipse shapes) */\n ellipseProperties?: EllipseProperties;\n /** Minimum elevation in meters (optional) */\n minElevation?: number;\n /** Maximum elevation in meters (optional) */\n maxElevation?: number;\n};\n\n/**\n * Feature properties for Circle shapes (circleProperties required).\n * Used by CircleShape for better type narrowing.\n */\nexport type CircleFeatureProperties = StyledFeatureProperties & {\n /** Circle properties (required for Circle shapes) */\n circleProperties: CircleProperties;\n};\n\n/**\n * Feature properties for Ellipse shapes (ellipseProperties required).\n * Used by EllipseShape for better type narrowing.\n */\nexport type EllipseFeatureProperties = StyledFeatureProperties & {\n /** Ellipse properties (required for Ellipse shapes) */\n ellipseProperties: EllipseProperties;\n};\n\n/**\n * GeoJSON Feature with style properties\n */\nexport type StyledFeature = Feature & {\n properties: StyledFeatureProperties;\n};\n\n/**\n * Base shape properties shared by all shapes.\n */\ntype BaseShape = {\n /** Unique identifier */\n id: ShapeId;\n /** Full shape name used internally and in UI */\n name: string;\n /**\n * Optional short display label shown on the map\n * If not provided, the `name` property will be used instead\n * Useful for showing abbreviated text on the map (e.g., \"NYC\" vs \"New York City Office\")\n */\n label?: string;\n /** GeoJSON feature with geometry and style properties */\n feature: ShapeFeature;\n /** UTC timestamp (only set when saved) */\n lastUpdated?: number;\n /**\n * Whether the shape is locked for editing\n * Locked shapes cannot be modified due to data restrictions or user preference\n */\n locked?: boolean;\n};\n\n/**\n * Circle shape with required circleProperties\n */\nexport type CircleShape = BaseShape & {\n shape: typeof ShapeFeatureType.Circle;\n feature: StyledFeature & { properties: CircleFeatureProperties };\n};\n\n/**\n * Ellipse shape with required ellipseProperties\n */\nexport type EllipseShape = BaseShape & {\n shape: typeof ShapeFeatureType.Ellipse;\n feature: StyledFeature & { properties: EllipseFeatureProperties };\n};\n\n/**\n * Polygon shape\n */\nexport type PolygonShape = BaseShape & {\n shape: typeof ShapeFeatureType.Polygon;\n feature: StyledFeature;\n};\n\n/**\n * Rectangle shape\n */\nexport type RectangleShape = BaseShape & {\n shape: typeof ShapeFeatureType.Rectangle;\n feature: StyledFeature;\n};\n\n/**\n * LineString shape\n */\nexport type LineStringShape = BaseShape & {\n shape: typeof ShapeFeatureType.LineString;\n feature: StyledFeature;\n};\n\n/**\n * Point shape\n */\nexport type PointShape = BaseShape & {\n shape: typeof ShapeFeatureType.Point;\n feature: StyledFeature;\n};\n\n/**\n * Discriminated union of all shape types.\n *\n * Use this for type narrowing based on shape:\n * @example\n * ```typescript\n * function handleShape(shape: Shape) {\n * if (shape.shape === 'Circle') {\n * // TypeScript knows shape.feature.properties.circleProperties exists\n * const { center, radius } = shape.feature.properties.circleProperties;\n * }\n * }\n * ```\n */\nexport type Shape =\n | CircleShape\n | EllipseShape\n | PolygonShape\n | RectangleShape\n | LineStringShape\n | PointShape;\n\n/**\n * Alias for StyledFeature (shape feature)\n */\nexport type ShapeFeature = StyledFeature;\n\n/**\n * Alias for StyledFeature properties\n */\nexport type ShapeFeatureProperties = StyledFeature['properties'];\n\n/**\n * Circle radius type\n */\nexport type CircleRadius = CircleProperties['radius'];\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\n/**\n * Type guard for Circle shapes.\n *\n * @param shape - The shape to test.\n * @returns True if shape is a CircleShape.\n *\n * @example\n * ```typescript\n * if (isCircleShape(shape)) {\n * // shape.feature.properties.circleProperties is available\n * const { center, radius } = shape.feature.properties.circleProperties;\n * }\n * ```\n */\nexport function isCircleShape(shape: Shape): shape is CircleShape {\n return shape.shape === ShapeFeatureType.Circle;\n}\n\n/**\n * Type guard for Ellipse shapes.\n *\n * @param shape - The shape to test.\n * @returns True if shape is an EllipseShape.\n *\n * @example\n * ```typescript\n * if (isEllipseShape(shape)) {\n * // shape.feature.properties.ellipseProperties is available\n * const { center, xSemiAxis, ySemiAxis } = shape.feature.properties.ellipseProperties;\n * }\n * ```\n */\nexport function isEllipseShape(shape: Shape): shape is EllipseShape {\n return shape.shape === ShapeFeatureType.Ellipse;\n}\n\n/**\n * Type guard for Polygon shapes.\n *\n * @param shape - The shape to test\n * @returns True if shape is a PolygonShape\n * @example\n * ```typescript\n * if (isPolygonShape(shape)) {\n * // TypeScript narrows shape to PolygonShape\n * }\n * ```\n */\nexport function isPolygonShape(shape: Shape): shape is PolygonShape {\n return shape.shape === ShapeFeatureType.Polygon;\n}\n\n/**\n * Type guard for Rectangle shapes.\n *\n * @param shape - The shape to test\n * @returns True if shape is a RectangleShape\n * @example\n * ```typescript\n * if (isRectangleShape(shape)) {\n * // TypeScript narrows shape to RectangleShape\n * }\n * ```\n */\nexport function isRectangleShape(shape: Shape): shape is RectangleShape {\n return shape.shape === ShapeFeatureType.Rectangle;\n}\n\n/**\n * Type guard for LineString shapes.\n *\n * @param shape - The shape to test\n * @returns True if shape is a LineStringShape\n * @example\n * ```typescript\n * if (isLineStringShape(shape)) {\n * // TypeScript narrows shape to LineStringShape\n * }\n * ```\n */\nexport function isLineStringShape(shape: Shape): shape is LineStringShape {\n return shape.shape === ShapeFeatureType.LineString;\n}\n\n/**\n * Type guard for Point shapes.\n *\n * @param shape - The shape to test\n * @returns True if shape is a PointShape\n * @example\n * ```typescript\n * if (isPointShape(shape)) {\n * // TypeScript narrows shape to PointShape\n * }\n * ```\n */\nexport function isPointShape(shape: Shape): shape is PointShape {\n return shape.shape === ShapeFeatureType.Point;\n}\n\n// =============================================================================\n// Geometry Type Predicates\n// =============================================================================\n// These narrow GeoJSON Geometry unions (e.g. Polygon, MultiPolygon),\n// distinct from the Shape type guards above which check shape.shape ('Circle', etc.).\n\n// --- Granular geometry predicates (single GeoJSON type) ---\n\n/**\n * Narrow a GeoJSON geometry to the Point type.\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a Point.\n */\nexport function isPointType(geometry: Geometry): geometry is Point {\n return geometry.type === 'Point';\n}\n\n/**\n * Narrow a GeoJSON geometry to the MultiPoint type.\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a MultiPoint.\n */\nexport function isMultiPointType(geometry: Geometry): geometry is MultiPoint {\n return geometry.type === 'MultiPoint';\n}\n\n/**\n * Narrow a GeoJSON geometry to the LineString type.\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a LineString.\n */\nexport function isLineStringType(geometry: Geometry): geometry is LineString {\n return geometry.type === 'LineString';\n}\n\n/**\n * Narrow a GeoJSON geometry to the MultiLineString type.\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a MultiLineString.\n */\nexport function isMultiLineStringType(\n geometry: Geometry,\n): geometry is MultiLineString {\n return geometry.type === 'MultiLineString';\n}\n\n/**\n * Narrow a GeoJSON geometry to the Polygon type.\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a Polygon.\n */\nexport function isPolygonType(geometry: Geometry): geometry is Polygon {\n return geometry.type === 'Polygon';\n}\n\n/**\n * Narrow a GeoJSON geometry to the MultiPolygon type.\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a MultiPolygon.\n */\nexport function isMultiPolygonType(\n geometry: Geometry,\n): geometry is MultiPolygon {\n return geometry.type === 'MultiPolygon';\n}\n\n/**\n * Narrow a GeoJSON geometry to the GeometryCollection type.\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a GeometryCollection.\n */\nexport function isGeometryCollectionType(\n geometry: Geometry,\n): geometry is GeometryCollection {\n return geometry.type === 'GeometryCollection';\n}\n\n// --- Composite geometry predicates (multiple GeoJSON types) ---\n\n/**\n * Narrow a GeoJSON geometry to polygon-like types (Polygon or MultiPolygon).\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a Polygon or MultiPolygon.\n *\n * @example\n * ```typescript\n * if (isPolygonGeometry(feature.geometry)) {\n * // geometry narrowed to Polygon | MultiPolygon\n * }\n * ```\n */\nexport function isPolygonGeometry(\n geometry: Geometry,\n): geometry is Polygon | MultiPolygon {\n return geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n}\n\n/**\n * Narrow a GeoJSON geometry to line-like types (LineString or MultiLineString).\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a LineString or MultiLineString.\n *\n * @example\n * ```typescript\n * if (isLineGeometry(feature.geometry)) {\n * // geometry narrowed to LineString | MultiLineString\n * }\n * ```\n */\nexport function isLineGeometry(\n geometry: Geometry,\n): geometry is LineString | MultiLineString {\n return geometry.type === 'LineString' || geometry.type === 'MultiLineString';\n}\n\n/**\n * Narrow a GeoJSON geometry to point-like types (Point or MultiPoint).\n *\n * @param geometry - The GeoJSON geometry to test.\n * @returns True if the geometry is a Point or MultiPoint.\n *\n * @example\n * ```typescript\n * if (isPointGeometry(feature.geometry)) {\n * // geometry narrowed to Point | MultiPoint\n * }\n * ```\n */\nexport function isPointGeometry(\n geometry: Geometry,\n): geometry is Point | MultiPoint {\n return geometry.type === 'Point' || geometry.type === 'MultiPoint';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,SAAS;CACT,SAAS;CACT,WAAW;CACX,YAAY;CACZ,OAAO;CACR;;;;;;;;;;;;;;;AA2RD,SAAgB,cAAc,OAAoC;AAChE,QAAO,MAAM,UAAU,iBAAiB;;;;;;;;;;;;;;;;AAiB1C,SAAgB,eAAe,OAAqC;AAClE,QAAO,MAAM,UAAU,iBAAiB;;;;;;;;;;;;;;AAe1C,SAAgB,eAAe,OAAqC;AAClE,QAAO,MAAM,UAAU,iBAAiB;;;;;;;;;;;;;;AAe1C,SAAgB,iBAAiB,OAAuC;AACtE,QAAO,MAAM,UAAU,iBAAiB;;;;;;;;;;;;;;AAe1C,SAAgB,kBAAkB,OAAwC;AACxE,QAAO,MAAM,UAAU,iBAAiB;;;;;;;;;;;;;;AAe1C,SAAgB,aAAa,OAAmC;AAC9D,QAAO,MAAM,UAAU,iBAAiB;;;;;;;;AAiB1C,SAAgB,YAAY,UAAuC;AACjE,QAAO,SAAS,SAAS;;;;;;;;AAS3B,SAAgB,iBAAiB,UAA4C;AAC3E,QAAO,SAAS,SAAS;;;;;;;;AAS3B,SAAgB,iBAAiB,UAA4C;AAC3E,QAAO,SAAS,SAAS;;;;;;;;AAS3B,SAAgB,sBACd,UAC6B;AAC7B,QAAO,SAAS,SAAS;;;;;;;;AAS3B,SAAgB,cAAc,UAAyC;AACrE,QAAO,SAAS,SAAS;;;;;;;;AAS3B,SAAgB,mBACd,UAC0B;AAC1B,QAAO,SAAS,SAAS;;;;;;;;AAS3B,SAAgB,yBACd,UACgC;AAChC,QAAO,SAAS,SAAS;;;;;;;;;;;;;;;AAkB3B,SAAgB,kBACd,UACoC;AACpC,QAAO,SAAS,SAAS,aAAa,SAAS,SAAS;;;;;;;;;;;;;;;AAgB1D,SAAgB,eACd,UAC0C;AAC1C,QAAO,SAAS,SAAS,gBAAgB,SAAS,SAAS;;;;;;;;;;;;;;;AAgB7D,SAAgB,gBACd,UACgC;AAChC,QAAO,SAAS,SAAS,WAAW,SAAS,SAAS"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -11,18 +11,16 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { distance, point } from "@turf/turf";
|
|
14
|
+
import { distance } from "@turf/turf";
|
|
17
15
|
|
|
18
16
|
//#region src/deckgl/shapes/shared/utils/geometry-measurements.ts
|
|
19
17
|
/**
|
|
20
18
|
* Compute circle measurements from center and edge point.
|
|
21
19
|
*
|
|
22
|
-
* @param center - Center point as [longitude, latitude]
|
|
23
|
-
* @param edgePoint - Point on the circle's edge as [longitude, latitude]
|
|
24
|
-
* @param units - Distance units for the measurements
|
|
25
|
-
* @returns Circle measurements including radius, diameter, and area
|
|
20
|
+
* @param center - Center point as [longitude, latitude].
|
|
21
|
+
* @param edgePoint - Point on the circle's edge as [longitude, latitude].
|
|
22
|
+
* @param units - Distance units for the measurements.
|
|
23
|
+
* @returns Circle measurements including radius, diameter, and area.
|
|
26
24
|
*
|
|
27
25
|
* @example
|
|
28
26
|
* ```typescript
|
|
@@ -49,11 +47,11 @@ function computeCircleMeasurements(center, edgePoint, units) {
|
|
|
49
47
|
* - corner0 to corner1 defines one edge (width)
|
|
50
48
|
* - corner1 to corner2 defines the adjacent edge (height)
|
|
51
49
|
*
|
|
52
|
-
* @param corner0 - First corner as [longitude, latitude]
|
|
53
|
-
* @param corner1 - Adjacent corner as [longitude, latitude]
|
|
54
|
-
* @param corner2 - Corner adjacent to corner1 as [longitude, latitude]
|
|
55
|
-
* @param units - Distance units for the measurements
|
|
56
|
-
* @returns Rectangle measurements including width, height, and area
|
|
50
|
+
* @param corner0 - First corner as [longitude, latitude].
|
|
51
|
+
* @param corner1 - Adjacent corner as [longitude, latitude].
|
|
52
|
+
* @param corner2 - Corner adjacent to corner1 as [longitude, latitude].
|
|
53
|
+
* @param units - Distance units for the measurements.
|
|
54
|
+
* @returns Rectangle measurements including width, height, and area.
|
|
57
55
|
*
|
|
58
56
|
* @example
|
|
59
57
|
* ```typescript
|
|
@@ -67,8 +65,9 @@ function computeCircleMeasurements(center, edgePoint, units) {
|
|
|
67
65
|
* ```
|
|
68
66
|
*/
|
|
69
67
|
function computeRectangleMeasurementsFromCorners(corner0, corner1, corner2, units) {
|
|
70
|
-
const
|
|
71
|
-
const
|
|
68
|
+
const options = { units };
|
|
69
|
+
const width = distance(corner0, corner1, options);
|
|
70
|
+
const height = distance(corner1, corner2, options);
|
|
72
71
|
return {
|
|
73
72
|
width,
|
|
74
73
|
height,
|
|
@@ -81,9 +80,9 @@ function computeRectangleMeasurementsFromCorners(corner0, corner1, corner2, unit
|
|
|
81
80
|
* For an ellipse approximated as a polygon, calculates the major and minor axes
|
|
82
81
|
* by measuring distances between opposite points on the perimeter.
|
|
83
82
|
*
|
|
84
|
-
* @param coordinates - Polygon ring coordinates as [[lon, lat], ...]
|
|
85
|
-
* @param units - Distance units for the measurements
|
|
86
|
-
* @returns Ellipse measurements including axes and area
|
|
83
|
+
* @param coordinates - Polygon ring coordinates as [[lon, lat], ...].
|
|
84
|
+
* @param units - Distance units for the measurements.
|
|
85
|
+
* @returns Ellipse measurements including axes and area.
|
|
87
86
|
*
|
|
88
87
|
* @example
|
|
89
88
|
* ```typescript
|
|
@@ -95,20 +94,24 @@ function computeRectangleMeasurementsFromCorners(corner0, corner1, corner2, unit
|
|
|
95
94
|
* ```
|
|
96
95
|
*/
|
|
97
96
|
function computeEllipseMeasurementsFromPolygon(coordinates, units) {
|
|
98
|
-
const
|
|
99
|
-
|
|
97
|
+
const len = coordinates.length;
|
|
98
|
+
const pointCount = len > 0 && coordinates[0]?.[0] === coordinates[len - 1]?.[0] && coordinates[0]?.[1] === coordinates[len - 1]?.[1] ? len - 1 : len;
|
|
99
|
+
if (pointCount < 4) return {
|
|
100
|
+
xSemiAxis: 0,
|
|
101
|
+
ySemiAxis: 0,
|
|
100
102
|
majorAxis: 0,
|
|
101
103
|
minorAxis: 0,
|
|
102
104
|
area: 0
|
|
103
105
|
};
|
|
104
|
-
const halfLen = Math.floor(
|
|
106
|
+
const halfLen = Math.floor(pointCount / 2);
|
|
107
|
+
const options = { units };
|
|
105
108
|
let maxDist = 0;
|
|
106
109
|
let minDist = Number.POSITIVE_INFINITY;
|
|
107
110
|
for (let i = 0; i < halfLen; i++) {
|
|
108
|
-
const p1 =
|
|
109
|
-
const p2 =
|
|
111
|
+
const p1 = coordinates[i];
|
|
112
|
+
const p2 = coordinates[i + halfLen];
|
|
110
113
|
if (!(p1 && p2)) continue;
|
|
111
|
-
const dist = distance(
|
|
114
|
+
const dist = distance(p1, p2, options);
|
|
112
115
|
if (dist > maxDist) maxDist = dist;
|
|
113
116
|
if (dist < minDist) minDist = dist;
|
|
114
117
|
}
|
|
@@ -117,6 +120,8 @@ function computeEllipseMeasurementsFromPolygon(coordinates, units) {
|
|
|
117
120
|
const semiMajor = majorAxis / 2;
|
|
118
121
|
const semiMinor = minorAxis / 2;
|
|
119
122
|
return {
|
|
123
|
+
xSemiAxis: semiMajor,
|
|
124
|
+
ySemiAxis: semiMinor,
|
|
120
125
|
majorAxis,
|
|
121
126
|
minorAxis,
|
|
122
127
|
area: Math.PI * semiMajor * semiMinor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-measurements.js","names":[],"sources":["../../../../../src/deckgl/shapes/shared/utils/geometry-measurements.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\
|
|
1
|
+
{"version":3,"file":"geometry-measurements.js","names":[],"sources":["../../../../../src/deckgl/shapes/shared/utils/geometry-measurements.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { distance } from '@turf/turf';\nimport type { DistanceUnit } from '@/shared/units';\n\n/**\n * Circle measurement result containing radius, diameter, and area.\n */\nexport type CircleMeasurements = {\n /** Radius in the specified units. */\n radius: number;\n /** Diameter (radius * 2) in the specified units. */\n diameter: number;\n /** Area (π * radius²) in the specified units squared. */\n area: number;\n};\n\n/**\n * Ellipse measurement result containing semi-axes and area.\n */\nexport type EllipseMeasurements = {\n /** X semi-axis (horizontal radius) in the specified units. */\n xSemiAxis: number;\n /** Y semi-axis (vertical radius) in the specified units. */\n ySemiAxis: number;\n /** Major axis (full length of longer axis) in the specified units. */\n majorAxis: number;\n /** Minor axis (full length of shorter axis) in the specified units. */\n minorAxis: number;\n /** Area (π * xSemiAxis * ySemiAxis) in the specified units squared. */\n area: number;\n};\n\n/**\n * Rectangle measurement result containing width, height, and area.\n */\nexport type RectangleMeasurements = {\n /** Width in the specified units. */\n width: number;\n /** Height in the specified units. */\n height: number;\n /** Area (width * height) in the specified units squared. */\n area: number;\n};\n\n/**\n * Compute circle measurements from center and edge point.\n *\n * @param center - Center point as [longitude, latitude].\n * @param edgePoint - Point on the circle's edge as [longitude, latitude].\n * @param units - Distance units for the measurements.\n * @returns Circle measurements including radius, diameter, and area.\n *\n * @example\n * ```typescript\n * const { radius, diameter, area } = computeCircleMeasurements(\n * [-122.4, 37.8],\n * [-122.3, 37.8],\n * 'kilometers'\n * );\n * ```\n */\nexport function computeCircleMeasurements(\n center: [number, number],\n edgePoint: [number, number],\n units: DistanceUnit,\n): CircleMeasurements {\n const radius = distance(center, edgePoint, { units });\n const diameter = radius * 2;\n const area = Math.PI * radius ** 2;\n\n return { radius, diameter, area };\n}\n\n/**\n * Compute ellipse measurements from semi-axis lengths.\n *\n * @param xSemiAxis - X semi-axis (horizontal radius) in the specified units.\n * @param ySemiAxis - Y semi-axis (vertical radius) in the specified units.\n * @returns Ellipse measurements including axes and area.\n *\n * @example\n * ```typescript\n * const { majorAxis, minorAxis, area } = computeEllipseMeasurementsFromAxes(100, 50);\n * ```\n */\nexport function computeEllipseMeasurementsFromAxes(\n xSemiAxis: number,\n ySemiAxis: number,\n): EllipseMeasurements {\n const majorAxis = Math.max(xSemiAxis, ySemiAxis) * 2;\n const minorAxis = Math.min(xSemiAxis, ySemiAxis) * 2;\n const area = Math.PI * xSemiAxis * ySemiAxis;\n\n return { xSemiAxis, ySemiAxis, majorAxis, minorAxis, area };\n}\n\n/**\n * Compute rectangle measurements from adjacent corner points.\n *\n * Uses geodesic distance calculations for accurate measurements on Earth's surface.\n * Corners should be provided in order: corner0 -> corner1 -> corner2 where:\n * - corner0 to corner1 defines one edge (width)\n * - corner1 to corner2 defines the adjacent edge (height)\n *\n * @param corner0 - First corner as [longitude, latitude].\n * @param corner1 - Adjacent corner as [longitude, latitude].\n * @param corner2 - Corner adjacent to corner1 as [longitude, latitude].\n * @param units - Distance units for the measurements.\n * @returns Rectangle measurements including width, height, and area.\n *\n * @example\n * ```typescript\n * const coords = polygon.geometry.coordinates[0];\n * const { width, height, area } = computeRectangleMeasurementsFromCorners(\n * coords[0] as [number, number],\n * coords[1] as [number, number],\n * coords[2] as [number, number],\n * 'kilometers'\n * );\n * ```\n */\nexport function computeRectangleMeasurementsFromCorners(\n corner0: [number, number],\n corner1: [number, number],\n corner2: [number, number],\n units: DistanceUnit,\n): RectangleMeasurements {\n const options = { units };\n const width = distance(corner0, corner1, options);\n const height = distance(corner1, corner2, options);\n const area = width * height;\n\n return { width, height, area };\n}\n\n/**\n * Compute ellipse measurements from polygon coordinates.\n *\n * For an ellipse approximated as a polygon, calculates the major and minor axes\n * by measuring distances between opposite points on the perimeter.\n *\n * @param coordinates - Polygon ring coordinates as [[lon, lat], ...].\n * @param units - Distance units for the measurements.\n * @returns Ellipse measurements including axes and area.\n *\n * @example\n * ```typescript\n * const coords = polygon.geometry.coordinates[0];\n * const { majorAxis, minorAxis, area } = computeEllipseMeasurementsFromPolygon(\n * coords as [number, number][],\n * 'kilometers'\n * );\n * ```\n */\nexport function computeEllipseMeasurementsFromPolygon(\n coordinates: [number, number][],\n units: DistanceUnit,\n): EllipseMeasurements {\n // Determine effective point count without allocating a new array\n const len = coordinates.length;\n const isClosed =\n len > 0 &&\n coordinates[0]?.[0] === coordinates[len - 1]?.[0] &&\n coordinates[0]?.[1] === coordinates[len - 1]?.[1];\n const pointCount = isClosed ? len - 1 : len;\n\n if (pointCount < 4) {\n return { xSemiAxis: 0, ySemiAxis: 0, majorAxis: 0, minorAxis: 0, area: 0 };\n }\n\n // For an ellipse polygon, opposite points are at index i and i + n/2\n const halfLen = Math.floor(pointCount / 2);\n const options = { units };\n let maxDist = 0;\n let minDist = Number.POSITIVE_INFINITY;\n\n // Sample several diameter measurements\n for (let i = 0; i < halfLen; i++) {\n const p1 = coordinates[i];\n const p2 = coordinates[i + halfLen];\n if (!(p1 && p2)) {\n continue;\n }\n\n const dist = distance(p1, p2, options);\n\n if (dist > maxDist) {\n maxDist = dist;\n }\n if (dist < minDist) {\n minDist = dist;\n }\n }\n\n const majorAxis = maxDist;\n const minorAxis = minDist === Number.POSITIVE_INFINITY ? maxDist : minDist;\n\n // Ellipse area = π × a × b (where a and b are semi-axes)\n const semiMajor = majorAxis / 2;\n const semiMinor = minorAxis / 2;\n const area = Math.PI * semiMajor * semiMinor;\n\n return {\n xSemiAxis: semiMajor,\n ySemiAxis: semiMinor,\n majorAxis,\n minorAxis,\n area,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAAgB,0BACd,QACA,WACA,OACoB;CACpB,MAAM,SAAS,SAAS,QAAQ,WAAW,EAAE,OAAO,CAAC;AAIrD,QAAO;EAAE;EAAQ,UAHA,SAAS;EAGC,MAFd,KAAK,KAAK,UAAU;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDnC,SAAgB,wCACd,SACA,SACA,SACA,OACuB;CACvB,MAAM,UAAU,EAAE,OAAO;CACzB,MAAM,QAAQ,SAAS,SAAS,SAAS,QAAQ;CACjD,MAAM,SAAS,SAAS,SAAS,SAAS,QAAQ;AAGlD,QAAO;EAAE;EAAO;EAAQ,MAFX,QAAQ;EAES;;;;;;;;;;;;;;;;;;;;;AAsBhC,SAAgB,sCACd,aACA,OACqB;CAErB,MAAM,MAAM,YAAY;CAKxB,MAAM,aAHJ,MAAM,KACN,YAAY,KAAK,OAAO,YAAY,MAAM,KAAK,MAC/C,YAAY,KAAK,OAAO,YAAY,MAAM,KAAK,KACnB,MAAM,IAAI;AAExC,KAAI,aAAa,EACf,QAAO;EAAE,WAAW;EAAG,WAAW;EAAG,WAAW;EAAG,WAAW;EAAG,MAAM;EAAG;CAI5E,MAAM,UAAU,KAAK,MAAM,aAAa,EAAE;CAC1C,MAAM,UAAU,EAAE,OAAO;CACzB,IAAI,UAAU;CACd,IAAI,UAAU,OAAO;AAGrB,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,KAAK;EAChC,MAAM,KAAK,YAAY;EACvB,MAAM,KAAK,YAAY,IAAI;AAC3B,MAAI,EAAE,MAAM,IACV;EAGF,MAAM,OAAO,SAAS,IAAI,IAAI,QAAQ;AAEtC,MAAI,OAAO,QACT,WAAU;AAEZ,MAAI,OAAO,QACT,WAAU;;CAId,MAAM,YAAY;CAClB,MAAM,YAAY,YAAY,OAAO,oBAAoB,UAAU;CAGnE,MAAM,YAAY,YAAY;CAC9B,MAAM,YAAY,YAAY;AAG9B,QAAO;EACL,WAAW;EACX,WAAW;EACX;EACA;EACA,MAPW,KAAK,KAAK,YAAY;EAQlC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
'use client';
|
|
15
|
-
|
|
16
14
|
import { DEFAULT_DISTANCE_UNITS, getDistanceUnitFromAbbreviation } from "../../../../shared/units.js";
|
|
17
15
|
import { DEFAULT_EDIT_HANDLE_COLOR, EDITABLE_LAYER_SUBLAYER_PROPS } from "../constants.js";
|
|
18
16
|
|
|
19
17
|
//#region src/deckgl/shapes/shared/utils/layer-config.ts
|
|
18
|
+
let cachedAbbrev = null;
|
|
19
|
+
let cachedProps;
|
|
20
20
|
/**
|
|
21
21
|
* Returns default props for EditableGeoJsonLayer configuration.
|
|
22
22
|
*
|
|
@@ -26,7 +26,7 @@ import { DEFAULT_EDIT_HANDLE_COLOR, EDITABLE_LAYER_SUBLAYER_PROPS } from "../con
|
|
|
26
26
|
* - Sublayer props for tooltips and handles
|
|
27
27
|
*
|
|
28
28
|
* @param unitAbbrev - Optional unit abbreviation (e.g., 'km', 'mi'). Defaults to DEFAULT_DISTANCE_UNITS.
|
|
29
|
-
* @returns Default props to spread onto EditableGeoJsonLayer
|
|
29
|
+
* @returns Default props to spread onto EditableGeoJsonLayer.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
32
|
* ```tsx
|
|
@@ -37,12 +37,15 @@ import { DEFAULT_EDIT_HANDLE_COLOR, EDITABLE_LAYER_SUBLAYER_PROPS } from "../con
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
function getDefaultEditableLayerProps(unitAbbrev) {
|
|
40
|
-
return
|
|
40
|
+
if (cachedAbbrev !== null && cachedAbbrev === unitAbbrev && cachedProps) return cachedProps;
|
|
41
|
+
cachedAbbrev = unitAbbrev;
|
|
42
|
+
cachedProps = {
|
|
41
43
|
getEditHandlePointColor: DEFAULT_EDIT_HANDLE_COLOR,
|
|
42
44
|
getEditHandlePointOutlineColor: DEFAULT_EDIT_HANDLE_COLOR,
|
|
43
45
|
modeConfig: { distanceUnits: unitAbbrev ? getDistanceUnitFromAbbreviation(unitAbbrev) ?? DEFAULT_DISTANCE_UNITS : DEFAULT_DISTANCE_UNITS },
|
|
44
46
|
_subLayerProps: EDITABLE_LAYER_SUBLAYER_PROPS
|
|
45
47
|
};
|
|
48
|
+
return cachedProps;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-config.js","names":[],"sources":["../../../../../src/deckgl/shapes/shared/utils/layer-config.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\
|
|
1
|
+
{"version":3,"file":"layer-config.js","names":["cachedAbbrev: DistanceUnitAbbreviation | undefined | null","cachedProps: EditableLayerDefaultProps | undefined"],"sources":["../../../../../src/deckgl/shapes/shared/utils/layer-config.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n DEFAULT_DISTANCE_UNITS,\n type DistanceUnit,\n type DistanceUnitAbbreviation,\n getDistanceUnitFromAbbreviation,\n} from '@/shared/units';\nimport {\n DEFAULT_EDIT_HANDLE_COLOR,\n EDITABLE_LAYER_SUBLAYER_PROPS,\n} from '../constants';\nimport type { Color } from '@deck.gl/core';\n\n/**\n * Props returned by getDefaultEditableLayerProps.\n * These are common configuration props shared between DrawShapeLayer and EditShapeLayer.\n */\nexport type EditableLayerDefaultProps = {\n /** Edit handle point color. */\n getEditHandlePointColor: Color;\n /** Edit handle point outline color. */\n getEditHandlePointOutlineColor: Color;\n /** Mode configuration with distance units. */\n modeConfig: {\n distanceUnits: DistanceUnit;\n };\n /** Sublayer props for tooltips and edit handles. */\n _subLayerProps: typeof EDITABLE_LAYER_SUBLAYER_PROPS;\n};\n\nlet cachedAbbrev: DistanceUnitAbbreviation | undefined | null = null;\nlet cachedProps: EditableLayerDefaultProps | undefined;\n\n/**\n * Returns default props for EditableGeoJsonLayer configuration.\n *\n * This consolidates the common configuration shared between DrawShapeLayer and EditShapeLayer:\n * - Edit handle colors\n * - Mode configuration with distance units\n * - Sublayer props for tooltips and handles\n *\n * @param unitAbbrev - Optional unit abbreviation (e.g., 'km', 'mi'). Defaults to DEFAULT_DISTANCE_UNITS.\n * @returns Default props to spread onto EditableGeoJsonLayer.\n *\n * @example\n * ```tsx\n * <editableGeoJsonLayer\n * {...getDefaultEditableLayerProps(unit)}\n * // other props\n * />\n * ```\n */\nexport function getDefaultEditableLayerProps(\n unitAbbrev?: DistanceUnitAbbreviation,\n): EditableLayerDefaultProps {\n if (cachedAbbrev !== null && cachedAbbrev === unitAbbrev && cachedProps) {\n return cachedProps;\n }\n\n cachedAbbrev = unitAbbrev;\n cachedProps = {\n getEditHandlePointColor: DEFAULT_EDIT_HANDLE_COLOR,\n getEditHandlePointOutlineColor: DEFAULT_EDIT_HANDLE_COLOR,\n modeConfig: {\n distanceUnits: unitAbbrev\n ? (getDistanceUnitFromAbbreviation(unitAbbrev) ??\n DEFAULT_DISTANCE_UNITS)\n : DEFAULT_DISTANCE_UNITS,\n },\n // biome-ignore lint/style/useNamingConvention: deck.gl API convention\n _subLayerProps: EDITABLE_LAYER_SUBLAYER_PROPS,\n };\n\n return cachedProps;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,IAAIA,eAA4D;AAChE,IAAIC;;;;;;;;;;;;;;;;;;;;AAqBJ,SAAgB,6BACd,YAC2B;AAC3B,KAAI,iBAAiB,QAAQ,iBAAiB,cAAc,YAC1D,QAAO;AAGT,gBAAe;AACf,eAAc;EACZ,yBAAyB;EACzB,gCAAgC;EAChC,YAAY,EACV,eAAe,aACV,gCAAgC,WAAW,IAC5C,yBACA,wBACL;EAED,gBAAgB;EACjB;AAED,QAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
'use client';
|
|
15
|
-
|
|
16
14
|
import { MapModeEvents } from "../../../../map-mode/events.js";
|
|
17
15
|
import { MapCursorEvents } from "../../../../map-cursor/events.js";
|
|
18
16
|
import { cursorStore } from "../../../../map-cursor/store.js";
|
|
@@ -24,15 +22,22 @@ import { Broadcast } from "@accelint/bus";
|
|
|
24
22
|
*/
|
|
25
23
|
const mapModeBus = Broadcast.getInstance();
|
|
26
24
|
const mapCursorBus = Broadcast.getInstance();
|
|
25
|
+
/** The idle mode name used when releasing ownership. */
|
|
26
|
+
const DEFAULT_MODE = "default";
|
|
27
27
|
/**
|
|
28
28
|
* Request a map mode change.
|
|
29
29
|
*
|
|
30
30
|
* Emits a mode change request through the event bus. The mode store will
|
|
31
31
|
* handle authorization and apply the change if approved.
|
|
32
32
|
*
|
|
33
|
-
* @param mapId - The map instance ID
|
|
34
|
-
* @param desiredMode - The mode to switch to
|
|
35
|
-
* @param owner - The identifier of the component requesting the change
|
|
33
|
+
* @param mapId - The map instance ID.
|
|
34
|
+
* @param desiredMode - The mode to switch to.
|
|
35
|
+
* @param owner - The identifier of the component requesting the change.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* requestModeChange(mapId, 'draw', 'draw-shape-layer');
|
|
40
|
+
* ```
|
|
36
41
|
*/
|
|
37
42
|
function requestModeChange(mapId, desiredMode, owner) {
|
|
38
43
|
mapModeBus.emit(MapModeEvents.changeRequest, {
|
|
@@ -46,20 +51,30 @@ function requestModeChange(mapId, desiredMode, owner) {
|
|
|
46
51
|
*
|
|
47
52
|
* Convenience function to request a mode change back to 'default'.
|
|
48
53
|
*
|
|
49
|
-
* @param mapId - The map instance ID
|
|
50
|
-
* @param owner - The identifier of the component releasing the mode
|
|
54
|
+
* @param mapId - The map instance ID.
|
|
55
|
+
* @param owner - The identifier of the component releasing the mode.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* releaseMode(mapId, 'draw-shape-layer');
|
|
60
|
+
* ```
|
|
51
61
|
*/
|
|
52
62
|
function releaseMode(mapId, owner) {
|
|
53
|
-
requestModeChange(mapId,
|
|
63
|
+
requestModeChange(mapId, DEFAULT_MODE, owner);
|
|
54
64
|
}
|
|
55
65
|
/**
|
|
56
66
|
* Request a cursor change.
|
|
57
67
|
*
|
|
58
68
|
* Emits a cursor change request through the event bus.
|
|
59
69
|
*
|
|
60
|
-
* @param mapId - The map instance ID
|
|
61
|
-
* @param cursor - The CSS cursor type to set
|
|
62
|
-
* @param owner - The identifier of the component requesting the change
|
|
70
|
+
* @param mapId - The map instance ID.
|
|
71
|
+
* @param cursor - The CSS cursor type to set.
|
|
72
|
+
* @param owner - The identifier of the component requesting the change.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* requestCursorChange(mapId, 'crosshair', 'draw-shape-layer');
|
|
77
|
+
* ```
|
|
63
78
|
*/
|
|
64
79
|
function requestCursorChange(mapId, cursor, owner) {
|
|
65
80
|
mapCursorBus.emit(MapCursorEvents.changeRequest, {
|
|
@@ -73,8 +88,13 @@ function requestCursorChange(mapId, cursor, owner) {
|
|
|
73
88
|
*
|
|
74
89
|
* Uses the cursor store's clear function to release the cursor.
|
|
75
90
|
*
|
|
76
|
-
* @param mapId - The map instance ID
|
|
77
|
-
* @param owner - The identifier of the component releasing the cursor
|
|
91
|
+
* @param mapId - The map instance ID.
|
|
92
|
+
* @param owner - The identifier of the component releasing the cursor.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* releaseCursor(mapId, 'draw-shape-layer');
|
|
97
|
+
* ```
|
|
78
98
|
*/
|
|
79
99
|
function releaseCursor(mapId, owner) {
|
|
80
100
|
cursorStore.actions(mapId).clearCursor(owner);
|
|
@@ -86,10 +106,15 @@ function releaseCursor(mapId, owner) {
|
|
|
86
106
|
* requires authorization. When the mode change is approved, the cursor
|
|
87
107
|
* will be automatically applied via getEffectiveCursor.
|
|
88
108
|
*
|
|
89
|
-
* @param mapId - The map instance ID
|
|
90
|
-
* @param desiredMode - The mode to switch to
|
|
91
|
-
* @param cursor - The CSS cursor type to set
|
|
92
|
-
* @param owner - The identifier of the component requesting the changes
|
|
109
|
+
* @param mapId - The map instance ID.
|
|
110
|
+
* @param desiredMode - The mode to switch to.
|
|
111
|
+
* @param cursor - The CSS cursor type to set.
|
|
112
|
+
* @param owner - The identifier of the component requesting the changes.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* requestModeAndCursor(mapId, 'draw', 'crosshair', 'draw-shape-layer');
|
|
117
|
+
* ```
|
|
93
118
|
*/
|
|
94
119
|
function requestModeAndCursor(mapId, desiredMode, cursor, owner) {
|
|
95
120
|
requestModeChange(mapId, desiredMode, owner);
|
|
@@ -100,8 +125,13 @@ function requestModeAndCursor(mapId, desiredMode, cursor, owner) {
|
|
|
100
125
|
*
|
|
101
126
|
* Common pattern when ending an operation.
|
|
102
127
|
*
|
|
103
|
-
* @param mapId - The map instance ID
|
|
104
|
-
* @param owner - The identifier of the component releasing mode and cursor
|
|
128
|
+
* @param mapId - The map instance ID.
|
|
129
|
+
* @param owner - The identifier of the component releasing mode and cursor.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* releaseModeAndCursor(mapId, 'draw-shape-layer');
|
|
134
|
+
* ```
|
|
105
135
|
*/
|
|
106
136
|
function releaseModeAndCursor(mapId, owner) {
|
|
107
137
|
releaseMode(mapId, owner);
|