@accelint/map-toolkit 1.5.0 → 3.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 +83 -0
- package/README.md +8 -1
- package/catalog-info.yaml +9 -6
- 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 +3 -3
- package/dist/deckgl/base-map/index.js +1 -1
- package/dist/deckgl/base-map/provider.d.ts +1 -1
- 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/extensions/coffin-corner/coffin-corner-extension.d.ts +144 -0
- package/dist/deckgl/extensions/coffin-corner/coffin-corner-extension.js +535 -0
- package/dist/deckgl/extensions/coffin-corner/coffin-corner-extension.js.map +1 -0
- package/dist/deckgl/extensions/coffin-corner/index.d.ts +17 -0
- package/dist/deckgl/extensions/coffin-corner/index.js +19 -0
- package/dist/deckgl/extensions/coffin-corner/store.d.ts +96 -0
- package/dist/deckgl/extensions/coffin-corner/store.js +173 -0
- package/dist/deckgl/extensions/coffin-corner/store.js.map +1 -0
- package/dist/deckgl/extensions/coffin-corner/types.d.ts +76 -0
- package/dist/deckgl/extensions/coffin-corner/types.js +27 -0
- package/dist/deckgl/extensions/coffin-corner/types.js.map +1 -0
- package/dist/deckgl/extensions/coffin-corner/use-coffin-corner.d.ts +81 -0
- package/dist/deckgl/extensions/coffin-corner/use-coffin-corner.js +75 -0
- package/dist/deckgl/extensions/coffin-corner/use-coffin-corner.js.map +1 -0
- package/dist/deckgl/extensions/index.d.ts +15 -0
- package/dist/deckgl/extensions/index.js +16 -0
- package/dist/deckgl/index.d.ts +9 -4
- package/dist/deckgl/index.js +6 -2
- 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 +70 -26
- 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 +93 -38
- package/dist/deckgl/shapes/display-shape-layer/index.js +433 -187
- 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 +116 -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 +106 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/icon-config.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/display-shape-layer/utils/radius-label.js +53 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/radius-label.js.map +1 -0
- 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 +8 -4
- package/dist/deckgl/shapes/draw-shape-layer/index.js +11 -17
- 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 +6 -5
- 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 +4 -3
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js +6 -20
- 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 +6 -33
- 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 +16 -12
- 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 +3 -3
- 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 +12 -6
- package/dist/deckgl/shapes/edit-shape-layer/index.js +72 -27
- 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 +4 -3
- 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 +5 -3
- 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 +83 -14
- package/dist/deckgl/shapes/edit-shape-layer/store.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/types.d.ts +18 -4
- package/dist/deckgl/shapes/edit-shape-layer/types.js +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.d.ts +2 -2
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js +8 -4
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js.map +1 -1
- package/dist/deckgl/shapes/index.d.ts +5 -4
- package/dist/deckgl/shapes/index.js +3 -2
- package/dist/deckgl/shapes/shared/constants.d.ts +4 -3
- package/dist/deckgl/shapes/shared/constants.js +51 -11
- 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 +182 -54
- 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/duplicate-shape.d.ts +56 -0
- package/dist/deckgl/shapes/shared/utils/duplicate-shape.js +131 -0
- package/dist/deckgl/shapes/shared/utils/duplicate-shape.js.map +1 -0
- 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 +15 -9
- 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 +4 -2
- package/dist/deckgl/symbol-layer/fiber.js +1 -1
- package/dist/deckgl/symbol-layer/fiber.js.map +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.d.ts +15 -56
- package/dist/shared/units.js +2 -53
- package/dist/shared/units.js.map +1 -1
- package/dist/viewport/index.d.ts +3 -4
- package/dist/viewport/index.js +2 -3
- package/dist/viewport/store.d.ts +1 -1
- package/dist/viewport/store.js +1 -1
- package/dist/viewport/types.d.ts +9 -5
- package/dist/viewport/types.js +1 -1
- package/dist/viewport/utils.d.ts +4 -4
- package/dist/viewport/utils.js +17 -9
- package/dist/viewport/utils.js.map +1 -1
- package/dist/viewport/viewport-size.d.ts +7 -6
- package/dist/viewport/viewport-size.js +3 -3
- package/dist/viewport/viewport-size.js.map +1 -1
- package/package.json +29 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw-ellipse-mode-with-tooltip.js","names":["center: [number, number]"],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.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 DrawEllipseUsingThreePointsMode,\n type FeatureCollection,\n type ModeProps,\n type PointerMoveEvent,\n type Tooltip,\n} from '@deck.gl-community/editable-layers';\nimport { type Coord, distance } from '@turf/turf';\nimport {
|
|
1
|
+
{"version":3,"file":"draw-ellipse-mode-with-tooltip.js","names":["center: [number, number]"],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.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 DISTANCE_UNIT_SYMBOLS,\n type DistanceUnit,\n} from '@accelint/constants/units';\nimport {\n DrawEllipseUsingThreePointsMode,\n type FeatureCollection,\n type ModeProps,\n type PointerMoveEvent,\n type Tooltip,\n} from '@deck.gl-community/editable-layers';\nimport { type Coord, distance } from '@turf/turf';\nimport { DEFAULT_DISTANCE_UNITS } from '@/shared/units';\nimport {\n formatDistanceTooltip,\n formatEllipseTooltip,\n} from '../../shared/constants';\n\n/**\n * Extends DrawEllipseUsingThreePointsMode to display contextual tooltips.\n *\n * Provides different tooltip content based on the drawing stage:\n * - **Stage 1** (after first click): Distance from first point to cursor\n * - **Stage 2** (after second click): Major/minor axes dimensions and area\n *\n * ## Drawing Flow\n * 1. **First click**: Sets the first endpoint of the major axis\n * 2. **Second click**: Sets the second endpoint of the major axis\n * - While moving to second click, shows distance tooltip (like line/polygon)\n * 3. **Third click**: Sets the minor axis radius\n * - While moving to third click, shows dimensions and area tooltip\n *\n * ## Geometry Calculations\n * - **Center**: Midpoint between first and second clicks\n * - **Y semi-axis**: Half the distance between clicks 1 and 2\n * - **X semi-axis**: Distance from center to cursor (becomes distance to click 3)\n * - **Area**: π × X semi-axis × Y semi-axis\n *\n * @example\n * ```typescript\n * import { DrawEllipseModeWithTooltip } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n *\n * // Used internally by DrawShapeLayer\n * const mode = new DrawEllipseModeWithTooltip();\n * ```\n */\nexport class DrawEllipseModeWithTooltip extends DrawEllipseUsingThreePointsMode {\n /** Current tooltip state (null when not drawing) */\n private tooltip: Tooltip | null = null;\n\n /**\n * Handle pointer move events to update the tooltip based on drawing stage.\n *\n * Stage 1 (1 click): Shows distance from first point to cursor.\n * Stage 2 (2 clicks): Shows major/minor axes dimensions and ellipse area.\n *\n * @param event - Pointer move event with cursor position\n * @param props - Mode properties including distance units configuration\n */\n override handlePointerMove(\n event: PointerMoveEvent,\n props: ModeProps<FeatureCollection>,\n ) {\n super.handlePointerMove(event, props);\n\n const clickSequence = this.getClickSequence();\n if (!clickSequence.length) {\n this.tooltip = null;\n return;\n }\n\n const { mapCoords } = event;\n const distanceUnits =\n (props.modeConfig?.distanceUnits as DistanceUnit) ??\n DEFAULT_DISTANCE_UNITS;\n const unitAbbrev = DISTANCE_UNIT_SYMBOLS[distanceUnits];\n const tooltipPosition = mapCoords;\n\n if (clickSequence.length === 1) {\n // First segment: show distance from first click to cursor (like line/polygon)\n const firstPoint = clickSequence[0] as Coord;\n const currentPoint = mapCoords as Coord;\n\n const dist = distance(firstPoint, currentPoint, { units: distanceUnits });\n\n this.tooltip = {\n position: tooltipPosition,\n text: formatDistanceTooltip(dist, unitAbbrev),\n };\n } else if (clickSequence.length === 2) {\n // Second segment: show dimensions and area (like rectangle)\n // The ellipse will have:\n // - center at midpoint of click1 and click2\n // - ySemiAxis = distance(click1, click2) / 2\n // - xSemiAxis = distance(center, cursor)\n const click1 = clickSequence[0] as [number, number];\n const click2 = clickSequence[1] as [number, number];\n const cursorPos = mapCoords as [number, number];\n\n // Calculate center (midpoint)\n const center: [number, number] = [\n (click1[0] + click2[0]) / 2,\n (click1[1] + click2[1]) / 2,\n ];\n\n // Calculate semi-axes\n const ySemiAxis = distance(click1, click2, { units: distanceUnits }) / 2;\n const xSemiAxis = distance(center, cursorPos, { units: distanceUnits });\n\n // Full axes (diameter equivalent)\n const majorAxis = Math.max(xSemiAxis, ySemiAxis) * 2;\n const minorAxis = Math.min(xSemiAxis, ySemiAxis) * 2;\n\n // Ellipse area = π × a × b\n const ellipseArea = Math.PI * xSemiAxis * ySemiAxis;\n\n this.tooltip = {\n position: tooltipPosition,\n text: formatEllipseTooltip(\n majorAxis,\n minorAxis,\n ellipseArea,\n unitAbbrev,\n ),\n };\n }\n }\n\n /**\n * Get the current tooltip array for rendering.\n *\n * @returns Array containing the tooltip if one is active, empty array otherwise\n */\n override getTooltips(): Tooltip[] {\n return this.tooltip ? [this.tooltip] : [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,IAAa,6BAAb,cAAgD,gCAAgC;;CAE9E,AAAQ,UAA0B;;;;;;;;;;CAWlC,AAAS,kBACP,OACA,OACA;AACA,QAAM,kBAAkB,OAAO,MAAM;EAErC,MAAM,gBAAgB,KAAK,kBAAkB;AAC7C,MAAI,CAAC,cAAc,QAAQ;AACzB,QAAK,UAAU;AACf;;EAGF,MAAM,EAAE,cAAc;EACtB,MAAM,gBACH,MAAM,YAAY,iBACnB;EACF,MAAM,aAAa,sBAAsB;EACzC,MAAM,kBAAkB;AAExB,MAAI,cAAc,WAAW,GAAG;GAE9B,MAAM,aAAa,cAAc;AAKjC,QAAK,UAAU;IACb,UAAU;IACV,MAAM,sBAJK,SAAS,YAFD,WAE2B,EAAE,OAAO,eAAe,CAAC,EAIrC,WAAW;IAC9C;aACQ,cAAc,WAAW,GAAG;GAMrC,MAAM,SAAS,cAAc;GAC7B,MAAM,SAAS,cAAc;GAC7B,MAAM,YAAY;GAGlB,MAAMA,SAA2B,EAC9B,OAAO,KAAK,OAAO,MAAM,IACzB,OAAO,KAAK,OAAO,MAAM,EAC3B;GAGD,MAAM,YAAY,SAAS,QAAQ,QAAQ,EAAE,OAAO,eAAe,CAAC,GAAG;GACvE,MAAM,YAAY,SAAS,QAAQ,WAAW,EAAE,OAAO,eAAe,CAAC;AASvE,QAAK,UAAU;IACb,UAAU;IACV,MAAM,qBARU,KAAK,IAAI,WAAW,UAAU,GAAG,GACjC,KAAK,IAAI,WAAW,UAAU,GAAG,GAG/B,KAAK,KAAK,YAAY,WAQtC,WACD;IACF;;;;;;;;CASL,AAAS,cAAyB;AAChC,SAAO,KAAK,UAAU,CAAC,KAAK,QAAQ,GAAG,EAAE"}
|
|
@@ -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,9 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
import { DEFAULT_DISTANCE_UNITS
|
|
14
|
+
import { DEFAULT_DISTANCE_UNITS } from "../../../../shared/units.js";
|
|
15
15
|
import { formatDistanceTooltip } from "../../shared/constants.js";
|
|
16
16
|
import { distance } from "@turf/turf";
|
|
17
|
+
import { DISTANCE_UNIT_SYMBOLS } from "@accelint/constants/units";
|
|
17
18
|
import { DrawLineStringMode } from "@deck.gl-community/editable-layers";
|
|
18
19
|
|
|
19
20
|
//#region src/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.ts
|
|
@@ -29,9 +30,6 @@ import { DrawLineStringMode } from "@deck.gl-community/editable-layers";
|
|
|
29
30
|
* 3. Click to add more points
|
|
30
31
|
* 4. Double-click to finish the line string
|
|
31
32
|
*
|
|
32
|
-
* ## Double-Click Workaround
|
|
33
|
-
* Includes a workaround for the double-click to finish issue in @deck.gl-community/editable-layers ~9.1.
|
|
34
|
-
* This will be fixed in a future version (PR #225).
|
|
35
33
|
*
|
|
36
34
|
* @example
|
|
37
35
|
* ```typescript
|
|
@@ -44,8 +42,6 @@ import { DrawLineStringMode } from "@deck.gl-community/editable-layers";
|
|
|
44
42
|
var DrawLineStringModeWithTooltip = class extends DrawLineStringMode {
|
|
45
43
|
/** Current tooltip state (null when not drawing) */
|
|
46
44
|
tooltip = null;
|
|
47
|
-
/** Cached mode props for double-click workaround */
|
|
48
|
-
lastModeProps = null;
|
|
49
45
|
/**
|
|
50
46
|
* Finish drawing the line string.
|
|
51
47
|
*
|
|
@@ -64,20 +60,10 @@ var DrawLineStringModeWithTooltip = class extends DrawLineStringMode {
|
|
|
64
60
|
};
|
|
65
61
|
this.resetClickSequence();
|
|
66
62
|
this.tooltip = null;
|
|
67
|
-
this.lastModeProps = null;
|
|
68
63
|
const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);
|
|
69
64
|
if (editAction) props.onEdit(editAction);
|
|
70
65
|
}
|
|
71
66
|
/**
|
|
72
|
-
* Handle double-click to finish drawing.
|
|
73
|
-
* This is called externally via a DOM event listener as a workaround for
|
|
74
|
-
* @deck.gl-community/editable-layers ~9.1 which doesn't register 'dblclick' in EVENT_TYPES.
|
|
75
|
-
* @see https://github.com/visgl/deck.gl-community/pull/225
|
|
76
|
-
*/
|
|
77
|
-
handleDoubleClick() {
|
|
78
|
-
if (this.lastModeProps) this.finishDrawing(this.lastModeProps);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
67
|
* Override handleClick to store props for double-click workaround.
|
|
82
68
|
*
|
|
83
69
|
* Caches the mode props so that the external double-click handler can
|
|
@@ -87,7 +73,6 @@ var DrawLineStringModeWithTooltip = class extends DrawLineStringMode {
|
|
|
87
73
|
* @param props - Mode properties including onEdit callback
|
|
88
74
|
*/
|
|
89
75
|
handleClick(event, props) {
|
|
90
|
-
this.lastModeProps = props;
|
|
91
76
|
super.handleClick(event, props);
|
|
92
77
|
}
|
|
93
78
|
/**
|
|
@@ -108,10 +93,11 @@ var DrawLineStringModeWithTooltip = class extends DrawLineStringMode {
|
|
|
108
93
|
}
|
|
109
94
|
const { mapCoords } = event;
|
|
110
95
|
const distanceUnits = props.modeConfig?.distanceUnits ?? DEFAULT_DISTANCE_UNITS;
|
|
111
|
-
const
|
|
96
|
+
const dist = distance(clickSequence.at(-1), mapCoords, { units: distanceUnits });
|
|
97
|
+
const unitAbbrev = DISTANCE_UNIT_SYMBOLS[distanceUnits];
|
|
112
98
|
this.tooltip = {
|
|
113
99
|
position: mapCoords,
|
|
114
|
-
text: formatDistanceTooltip(
|
|
100
|
+
text: formatDistanceTooltip(dist, unitAbbrev)
|
|
115
101
|
};
|
|
116
102
|
}
|
|
117
103
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw-line-string-mode-with-tooltip.js","names":[],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.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 type ClickEvent,\n DrawLineStringMode,\n type FeatureCollection,\n type ModeProps,\n type PointerMoveEvent,\n type Tooltip,\n} from '@deck.gl-community/editable-layers';\nimport { type Coord, distance } from '@turf/turf';\nimport {
|
|
1
|
+
{"version":3,"file":"draw-line-string-mode-with-tooltip.js","names":[],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.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 DISTANCE_UNIT_SYMBOLS,\n type DistanceUnit,\n} from '@accelint/constants/units';\nimport {\n type ClickEvent,\n DrawLineStringMode,\n type FeatureCollection,\n type ModeProps,\n type PointerMoveEvent,\n type SimpleFeatureCollection,\n type Tooltip,\n} from '@deck.gl-community/editable-layers';\nimport { type Coord, distance } from '@turf/turf';\nimport { DEFAULT_DISTANCE_UNITS } from '@/shared/units';\nimport { formatDistanceTooltip } from '../../shared/constants';\n\n/**\n * Extends DrawLineStringMode to display distance tooltip between points.\n *\n * Shows the distance from the last clicked point to the current cursor position\n * while drawing a line string. The tooltip updates in real-time as the cursor moves.\n *\n * ## Drawing Flow\n * 1. Click to add first point\n * 2. Move cursor (tooltip shows distance from last point)\n * 3. Click to add more points\n * 4. Double-click to finish the line string\n *\n *\n * @example\n * ```typescript\n * import { DrawLineStringModeWithTooltip } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n *\n * // Used internally by DrawShapeLayer\n * const mode = new DrawLineStringModeWithTooltip();\n * ```\n */\nexport class DrawLineStringModeWithTooltip extends DrawLineStringMode {\n /** Current tooltip state (null when not drawing) */\n private tooltip: Tooltip | null = null;\n\n /**\n * Finish drawing the line string.\n *\n * Creates a LineString geometry from the click sequence and emits an edit action.\n * Requires at least 2 points to create a valid line string.\n * Extracted to share between double-click workaround and parent class logic.\n *\n * @param props - Mode properties with onEdit callback\n */\n override finishDrawing(props: ModeProps<SimpleFeatureCollection>): void {\n const clickSequence = this.getClickSequence();\n if (clickSequence.length <= 1) {\n return;\n }\n\n const lineStringToAdd = {\n type: 'LineString' as const,\n coordinates: [...clickSequence],\n };\n\n this.resetClickSequence();\n this.tooltip = null;\n\n const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n\n /**\n * Override handleClick to store props for double-click workaround.\n *\n * Caches the mode props so that the external double-click handler can\n * access them when finishing the drawing.\n *\n * @param event - Click event with map coordinates\n * @param props - Mode properties including onEdit callback\n */\n override handleClick(\n event: ClickEvent,\n props: ModeProps<SimpleFeatureCollection>,\n ): void {\n super.handleClick(event, props);\n }\n\n /**\n * Handle pointer move events to update the tooltip with distance.\n *\n * Calculates the distance from the last clicked point to the current\n * cursor position and displays it in the configured distance units.\n *\n * @param event - Pointer move event with cursor position\n * @param props - Mode properties including distance units configuration\n */\n override handlePointerMove(\n event: PointerMoveEvent,\n props: ModeProps<FeatureCollection>,\n ) {\n super.handlePointerMove(event, props);\n\n const clickSequence = this.getClickSequence();\n if (!clickSequence.length) {\n this.tooltip = null;\n return;\n }\n\n const { mapCoords } = event;\n const distanceUnits =\n (props.modeConfig?.distanceUnits as DistanceUnit) ??\n DEFAULT_DISTANCE_UNITS;\n\n const lastPoint = clickSequence.at(-1) as Coord;\n const currentPoint = mapCoords as Coord;\n\n const dist = distance(lastPoint, currentPoint, { units: distanceUnits });\n const unitAbbrev = DISTANCE_UNIT_SYMBOLS[distanceUnits];\n\n this.tooltip = {\n position: mapCoords,\n text: formatDistanceTooltip(dist, unitAbbrev),\n };\n }\n\n /**\n * Get the current tooltip array for rendering.\n *\n * @returns Array containing the tooltip if one is active, empty array otherwise\n */\n override getTooltips(): Tooltip[] {\n return this.tooltip ? [this.tooltip] : [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAa,gCAAb,cAAmD,mBAAmB;;CAEpE,AAAQ,UAA0B;;;;;;;;;;CAWlC,AAAS,cAAc,OAAiD;EACtE,MAAM,gBAAgB,KAAK,kBAAkB;AAC7C,MAAI,cAAc,UAAU,EAC1B;EAGF,MAAM,kBAAkB;GACtB,MAAM;GACN,aAAa,CAAC,GAAG,cAAc;GAChC;AAED,OAAK,oBAAoB;AACzB,OAAK,UAAU;EAEf,MAAM,aAAa,KAAK,oBAAoB,iBAAiB,MAAM,KAAK;AACxE,MAAI,WACF,OAAM,OAAO,WAAW;;;;;;;;;;;CAa5B,AAAS,YACP,OACA,OACM;AACN,QAAM,YAAY,OAAO,MAAM;;;;;;;;;;;CAYjC,AAAS,kBACP,OACA,OACA;AACA,QAAM,kBAAkB,OAAO,MAAM;EAErC,MAAM,gBAAgB,KAAK,kBAAkB;AAC7C,MAAI,CAAC,cAAc,QAAQ;AACzB,QAAK,UAAU;AACf;;EAGF,MAAM,EAAE,cAAc;EACtB,MAAM,gBACH,MAAM,YAAY,iBACnB;EAKF,MAAM,OAAO,SAHK,cAAc,GAAG,GAAG,EACjB,WAE0B,EAAE,OAAO,eAAe,CAAC;EACxE,MAAM,aAAa,sBAAsB;AAEzC,OAAK,UAAU;GACb,UAAU;GACV,MAAM,sBAAsB,MAAM,WAAW;GAC9C;;;;;;;CAQH,AAAS,cAAyB;AAChC,SAAO,KAAK,UAAU,CAAC,KAAK,QAAQ,GAAG,EAAE"}
|
|
@@ -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,9 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
import { DEFAULT_DISTANCE_UNITS
|
|
14
|
+
import { DEFAULT_DISTANCE_UNITS } from "../../../../shared/units.js";
|
|
15
15
|
import { formatDistanceTooltip } from "../../shared/constants.js";
|
|
16
16
|
import { distance } from "@turf/turf";
|
|
17
|
+
import { DISTANCE_UNIT_SYMBOLS } from "@accelint/constants/units";
|
|
17
18
|
import { DrawPolygonMode } from "@deck.gl-community/editable-layers";
|
|
18
19
|
|
|
19
20
|
//#region src/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.ts
|
|
@@ -29,9 +30,6 @@ import { DrawPolygonMode } from "@deck.gl-community/editable-layers";
|
|
|
29
30
|
* 3. Click to add more vertices
|
|
30
31
|
* 4. Double-click or click the starting point to close the polygon
|
|
31
32
|
*
|
|
32
|
-
* ## Double-Click Workaround
|
|
33
|
-
* Includes a workaround for the double-click to finish issue in @deck.gl-community/editable-layers ~9.1.
|
|
34
|
-
* This will be fixed in a future version (PR #225).
|
|
35
33
|
*
|
|
36
34
|
* @example
|
|
37
35
|
* ```typescript
|
|
@@ -44,15 +42,12 @@ import { DrawPolygonMode } from "@deck.gl-community/editable-layers";
|
|
|
44
42
|
var DrawPolygonModeWithTooltip = class extends DrawPolygonMode {
|
|
45
43
|
/** Current tooltip state (null when not drawing) */
|
|
46
44
|
tooltip = null;
|
|
47
|
-
/** Cached mode props for double-click workaround */
|
|
48
|
-
lastModeProps = null;
|
|
49
45
|
/**
|
|
50
46
|
* Finish drawing the polygon.
|
|
51
47
|
*
|
|
52
48
|
* Creates a Polygon geometry from the click sequence and emits an edit action.
|
|
53
49
|
* Requires at least 3 points to create a valid polygon. Automatically closes
|
|
54
50
|
* the polygon by adding the first point to the end of the coordinate ring.
|
|
55
|
-
* Extracted to share between double-click workaround and parent class logic.
|
|
56
51
|
*
|
|
57
52
|
* @param props - Mode properties with onEdit callback
|
|
58
53
|
*/
|
|
@@ -66,33 +61,10 @@ var DrawPolygonModeWithTooltip = class extends DrawPolygonMode {
|
|
|
66
61
|
};
|
|
67
62
|
this.resetClickSequence();
|
|
68
63
|
this.tooltip = null;
|
|
69
|
-
this.lastModeProps = null;
|
|
70
64
|
const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);
|
|
71
65
|
if (editAction) props.onEdit(editAction);
|
|
72
66
|
}
|
|
73
67
|
/**
|
|
74
|
-
* Handle double-click to finish drawing.
|
|
75
|
-
* This is called externally via a DOM event listener as a workaround for
|
|
76
|
-
* @deck.gl-community/editable-layers ~9.1 which doesn't register 'dblclick' in EVENT_TYPES.
|
|
77
|
-
* @see https://github.com/visgl/deck.gl-community/pull/225
|
|
78
|
-
*/
|
|
79
|
-
handleDoubleClick() {
|
|
80
|
-
if (this.lastModeProps) this.finishDrawing(this.lastModeProps);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Override handleClick to store props for double-click workaround.
|
|
84
|
-
*
|
|
85
|
-
* Caches the mode props so that the external double-click handler can
|
|
86
|
-
* access them when finishing the drawing.
|
|
87
|
-
*
|
|
88
|
-
* @param event - Click event with map coordinates
|
|
89
|
-
* @param props - Mode properties including onEdit callback
|
|
90
|
-
*/
|
|
91
|
-
handleClick(event, props) {
|
|
92
|
-
this.lastModeProps = props;
|
|
93
|
-
super.handleClick(event, props);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
68
|
* Handle pointer move events to update the tooltip with distance.
|
|
97
69
|
*
|
|
98
70
|
* Calculates the distance from the last clicked vertex to the current
|
|
@@ -110,10 +82,11 @@ var DrawPolygonModeWithTooltip = class extends DrawPolygonMode {
|
|
|
110
82
|
}
|
|
111
83
|
const { mapCoords } = event;
|
|
112
84
|
const distanceUnits = props.modeConfig?.distanceUnits ?? DEFAULT_DISTANCE_UNITS;
|
|
113
|
-
const
|
|
85
|
+
const dist = distance(clickSequence.at(-1), mapCoords, { units: distanceUnits });
|
|
86
|
+
const unitAbbrev = DISTANCE_UNIT_SYMBOLS[distanceUnits];
|
|
114
87
|
this.tooltip = {
|
|
115
88
|
position: mapCoords,
|
|
116
|
-
text: formatDistanceTooltip(
|
|
89
|
+
text: formatDistanceTooltip(dist, unitAbbrev)
|
|
117
90
|
};
|
|
118
91
|
}
|
|
119
92
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw-polygon-mode-with-tooltip.js","names":[],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.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 type
|
|
1
|
+
{"version":3,"file":"draw-polygon-mode-with-tooltip.js","names":[],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.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 DISTANCE_UNIT_SYMBOLS,\n type DistanceUnit,\n} from '@accelint/constants/units';\nimport {\n DrawPolygonMode,\n type FeatureCollection,\n type ModeProps,\n type PointerMoveEvent,\n type SimpleFeatureCollection,\n type Tooltip,\n} from '@deck.gl-community/editable-layers';\nimport { type Coord, distance } from '@turf/turf';\nimport { DEFAULT_DISTANCE_UNITS } from '@/shared/units';\nimport { formatDistanceTooltip } from '../../shared/constants';\n\n/**\n * Extends DrawPolygonMode to display distance tooltip between points.\n *\n * Shows the distance from the last clicked point to the current cursor position\n * while drawing a polygon. The tooltip updates in real-time as the cursor moves.\n *\n * ## Drawing Flow\n * 1. Click to add first vertex\n * 2. Move cursor (tooltip shows distance from last vertex)\n * 3. Click to add more vertices\n * 4. Double-click or click the starting point to close the polygon\n *\n *\n * @example\n * ```typescript\n * import { DrawPolygonModeWithTooltip } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n *\n * // Used internally by DrawShapeLayer\n * const mode = new DrawPolygonModeWithTooltip();\n * ```\n */\nexport class DrawPolygonModeWithTooltip extends DrawPolygonMode {\n /** Current tooltip state (null when not drawing) */\n private tooltip: Tooltip | null = null;\n\n /**\n * Finish drawing the polygon.\n *\n * Creates a Polygon geometry from the click sequence and emits an edit action.\n * Requires at least 3 points to create a valid polygon. Automatically closes\n * the polygon by adding the first point to the end of the coordinate ring.\n *\n * @param props - Mode properties with onEdit callback\n */\n override finishDrawing(props: ModeProps<SimpleFeatureCollection>): void {\n const clickSequence = this.getClickSequence();\n const firstPoint = clickSequence[0];\n if (clickSequence.length <= 2 || !firstPoint) {\n return;\n }\n\n const polygonToAdd = {\n type: 'Polygon' as const,\n coordinates: [[...clickSequence, firstPoint]],\n };\n\n this.resetClickSequence();\n this.tooltip = null;\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(\n polygonToAdd,\n props,\n );\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n\n /**\n * Handle pointer move events to update the tooltip with distance.\n *\n * Calculates the distance from the last clicked vertex to the current\n * cursor position and displays it in the configured distance units.\n *\n * @param event - Pointer move event with cursor position\n * @param props - Mode properties including distance units configuration\n */\n override handlePointerMove(\n event: PointerMoveEvent,\n props: ModeProps<FeatureCollection>,\n ) {\n super.handlePointerMove(event, props);\n\n const clickSequence = this.getClickSequence();\n if (!clickSequence.length) {\n this.tooltip = null;\n return;\n }\n\n const { mapCoords } = event;\n const distanceUnits =\n (props.modeConfig?.distanceUnits as DistanceUnit) ??\n DEFAULT_DISTANCE_UNITS;\n\n const lastPoint = clickSequence.at(-1) as Coord;\n const currentPoint = mapCoords as Coord;\n\n const dist = distance(lastPoint, currentPoint, { units: distanceUnits });\n const unitAbbrev = DISTANCE_UNIT_SYMBOLS[distanceUnits];\n\n this.tooltip = {\n position: mapCoords,\n text: formatDistanceTooltip(dist, unitAbbrev),\n };\n }\n\n /**\n * Get the current tooltip array for rendering.\n *\n * @returns Array containing the tooltip if one is active, empty array otherwise\n */\n override getTooltips(): Tooltip[] {\n return this.tooltip ? [this.tooltip] : [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,6BAAb,cAAgD,gBAAgB;;CAE9D,AAAQ,UAA0B;;;;;;;;;;CAWlC,AAAS,cAAc,OAAiD;EACtE,MAAM,gBAAgB,KAAK,kBAAkB;EAC7C,MAAM,aAAa,cAAc;AACjC,MAAI,cAAc,UAAU,KAAK,CAAC,WAChC;EAGF,MAAM,eAAe;GACnB,MAAM;GACN,aAAa,CAAC,CAAC,GAAG,eAAe,WAAW,CAAC;GAC9C;AAED,OAAK,oBAAoB;AACzB,OAAK,UAAU;EAEf,MAAM,aAAa,KAAK,oCACtB,cACA,MACD;AACD,MAAI,WACF,OAAM,OAAO,WAAW;;;;;;;;;;;CAa5B,AAAS,kBACP,OACA,OACA;AACA,QAAM,kBAAkB,OAAO,MAAM;EAErC,MAAM,gBAAgB,KAAK,kBAAkB;AAC7C,MAAI,CAAC,cAAc,QAAQ;AACzB,QAAK,UAAU;AACf;;EAGF,MAAM,EAAE,cAAc;EACtB,MAAM,gBACH,MAAM,YAAY,iBACnB;EAKF,MAAM,OAAO,SAHK,cAAc,GAAG,GAAG,EACjB,WAE0B,EAAE,OAAO,eAAe,CAAC;EACxE,MAAM,aAAa,sBAAsB;AAEzC,OAAK,UAAU;GACb,UAAU;GACV,MAAM,sBAAsB,MAAM,WAAW;GAC9C;;;;;;;CAQH,AAAS,cAAyB;AAChC,SAAO,KAAK,UAAU,CAAC,KAAK,QAAQ,GAAG,EAAE"}
|
|
@@ -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,11 +11,12 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
import { DEFAULT_DISTANCE_UNITS
|
|
14
|
+
import { DEFAULT_DISTANCE_UNITS } from "../../../../shared/units.js";
|
|
15
15
|
import { formatRectangleTooltip } from "../../shared/constants.js";
|
|
16
16
|
import { area, bbox, bboxPolygon, convertArea, destination, distance } from "@turf/turf";
|
|
17
|
+
import { DISTANCE_UNIT_SYMBOLS } from "@accelint/constants/units";
|
|
17
18
|
import { DrawRectangleMode } from "@deck.gl-community/editable-layers";
|
|
18
|
-
import { featureCollection, point
|
|
19
|
+
import { featureCollection, point } from "@turf/helpers";
|
|
19
20
|
|
|
20
21
|
//#region src/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.ts
|
|
21
22
|
/**
|
|
@@ -67,12 +68,12 @@ var DrawRectangleModeWithTooltip = class extends DrawRectangleMode {
|
|
|
67
68
|
const lat1 = coord1[1] ?? 0;
|
|
68
69
|
const lon2 = coord2[0] ?? 0;
|
|
69
70
|
const lat2 = coord2[1] ?? 0;
|
|
70
|
-
const horizontalDist = distance(point
|
|
71
|
-
const verticalDist = distance(point
|
|
71
|
+
const horizontalDist = distance(point([lon1, lat1]), point([lon2, lat1]), { units: "kilometers" });
|
|
72
|
+
const verticalDist = distance(point([lon1, lat1]), point([lon1, lat2]), { units: "kilometers" });
|
|
72
73
|
const maxDist = Math.max(horizontalDist, verticalDist);
|
|
73
74
|
const lonSign = lon2 >= lon1 ? 1 : -1;
|
|
74
75
|
const latSign = lat2 >= lat1 ? 1 : -1;
|
|
75
|
-
finalCoord2 = destination(destination(point
|
|
76
|
+
finalCoord2 = destination(destination(point([lon1, lat1]), maxDist, lonSign > 0 ? 90 : 270, { units: "kilometers" }), maxDist, latSign > 0 ? 0 : 180, { units: "kilometers" }).geometry.coordinates;
|
|
76
77
|
}
|
|
77
78
|
return super.getTwoClickPolygon(coord1, finalCoord2, modeConfig);
|
|
78
79
|
}
|
|
@@ -89,20 +90,23 @@ var DrawRectangleModeWithTooltip = class extends DrawRectangleMode {
|
|
|
89
90
|
handlePointerMove(event, props) {
|
|
90
91
|
this.isShiftPressed = event.sourceEvent?.shiftKey ?? false;
|
|
91
92
|
super.handlePointerMove(event, props);
|
|
92
|
-
const
|
|
93
|
-
const firstClick = clickSequence[clickSequence.length - 1];
|
|
93
|
+
const firstClick = this.getClickSequence().at(-1);
|
|
94
94
|
if (!firstClick) {
|
|
95
95
|
this.tooltip = null;
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
const { mapCoords } = event;
|
|
99
99
|
const distanceUnits = props.modeConfig?.distanceUnits ?? DEFAULT_DISTANCE_UNITS;
|
|
100
|
-
const firstClickPoint = point
|
|
101
|
-
const currentPoint = point
|
|
102
|
-
const cornerPoint = point
|
|
100
|
+
const firstClickPoint = point(firstClick);
|
|
101
|
+
const currentPoint = point(mapCoords);
|
|
102
|
+
const cornerPoint = point([firstClick[0], mapCoords[1]]);
|
|
103
|
+
const dimension1 = distance(firstClickPoint, cornerPoint, { units: distanceUnits });
|
|
104
|
+
const dimension2 = distance(currentPoint, cornerPoint, { units: distanceUnits });
|
|
105
|
+
const convertedArea = convertArea(area(bboxPolygon(bbox(featureCollection([firstClickPoint, currentPoint])))), "meters", distanceUnits);
|
|
106
|
+
const unitAbbrev = DISTANCE_UNIT_SYMBOLS[distanceUnits];
|
|
103
107
|
this.tooltip = {
|
|
104
108
|
position: mapCoords,
|
|
105
|
-
text: formatRectangleTooltip(
|
|
109
|
+
text: formatRectangleTooltip(dimension1, dimension2, convertedArea, unitAbbrev)
|
|
106
110
|
};
|
|
107
111
|
}
|
|
108
112
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw-rectangle-mode-with-tooltip.js","names":[
|
|
1
|
+
{"version":3,"file":"draw-rectangle-mode-with-tooltip.js","names":[],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.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 DISTANCE_UNIT_SYMBOLS,\n type DistanceUnit,\n} from '@accelint/constants/units';\nimport {\n DrawRectangleMode,\n type FeatureCollection,\n type ModeProps,\n type PointerMoveEvent,\n type Tooltip,\n} from '@deck.gl-community/editable-layers';\nimport { featureCollection, point } from '@turf/helpers';\nimport {\n area,\n bbox,\n bboxPolygon,\n convertArea,\n destination,\n distance,\n} from '@turf/turf';\nimport { DEFAULT_DISTANCE_UNITS } from '@/shared/units';\nimport { formatRectangleTooltip } from '../../shared/constants';\nimport type { Position } from 'geojson';\n\n/**\n * Extends DrawRectangleMode to display dimensions and area tooltip.\n *\n * Shows the width, height, and total area of the rectangle being drawn.\n * The tooltip updates in real-time as the cursor moves, displaying measurements\n * in the configured distance units.\n *\n * ## Drawing Flow\n * 1. Click to set first corner\n * 2. Move cursor (tooltip shows dimensions and area)\n * 3. Click to set opposite corner and finish the rectangle\n *\n * ## Shift-to-Square Constraint\n * Hold Shift while drawing to constrain the rectangle to a square with equal sides.\n * Uses real-world distances (via Turf.js) to account for lat/lon distortion.\n *\n * @example\n * ```typescript\n * import { DrawRectangleModeWithTooltip } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n *\n * // Used internally by DrawShapeLayer\n * const mode = new DrawRectangleModeWithTooltip();\n * ```\n */\nexport class DrawRectangleModeWithTooltip extends DrawRectangleMode {\n /** Current tooltip state (null when not drawing) */\n private tooltip: Tooltip | null = null;\n /** Tracks whether Shift key is currently pressed for square constraint */\n private isShiftPressed = false;\n\n /**\n * Override getTwoClickPolygon to support Shift-constrained squares.\n *\n * When Shift is held, constrains the rectangle to a square by using the larger\n * of the horizontal or vertical distances as the side length. Uses real-world\n * geographic distances (via Turf.js) to account for lat/lon distortion at different\n * latitudes.\n *\n * @param coord1 - First corner coordinates [lon, lat]\n * @param coord2 - Second corner coordinates [lon, lat]\n * @param modeConfig - Mode configuration options\n * @returns Polygon geometry for the rectangle or square\n */\n override getTwoClickPolygon(\n coord1: Position,\n coord2: Position,\n modeConfig: ModeProps<FeatureCollection>['modeConfig'],\n ) {\n let finalCoord2 = coord2;\n\n // If Shift is pressed, constrain to a square using real distances\n if (this.isShiftPressed && coord1 && coord2) {\n const lon1 = coord1[0] ?? 0;\n const lat1 = coord1[1] ?? 0;\n const lon2 = coord2[0] ?? 0;\n const lat2 = coord2[1] ?? 0;\n\n // Calculate real-world distances using turf\n // Horizontal distance (along latitude)\n const horizontalDist = distance(\n point([lon1, lat1]),\n point([lon2, lat1]),\n {\n units: 'kilometers',\n },\n );\n // Vertical distance (along longitude)\n const verticalDist = distance(point([lon1, lat1]), point([lon1, lat2]), {\n units: 'kilometers',\n });\n\n // Use the larger distance for the square side\n const maxDist = Math.max(horizontalDist, verticalDist);\n\n // Determine direction signs\n const lonSign = lon2 >= lon1 ? 1 : -1;\n const latSign = lat2 >= lat1 ? 1 : -1;\n\n // Calculate new corner using destination() for accurate geographic positioning\n // Move horizontally from coord1\n const horizontalPoint = destination(\n point([lon1, lat1]),\n maxDist,\n lonSign > 0 ? 90 : 270,\n {\n units: 'kilometers',\n },\n );\n // Move vertically from that point\n const cornerPoint = destination(\n horizontalPoint,\n maxDist,\n latSign > 0 ? 0 : 180,\n {\n units: 'kilometers',\n },\n );\n\n finalCoord2 = cornerPoint.geometry.coordinates;\n }\n\n // Call parent implementation with potentially adjusted coordinates\n return super.getTwoClickPolygon(coord1, finalCoord2, modeConfig);\n }\n\n /**\n * Handle pointer move events to update the tooltip with rectangle measurements.\n *\n * Tracks the Shift key state for square constraint and calculates the width,\n * height, and area of the rectangle being drawn. Uses Turf.js for accurate\n * geographic distance and area calculations.\n *\n * @param event - Pointer move event with cursor position and source event\n * @param props - Mode properties including distance units configuration\n */\n override handlePointerMove(\n event: PointerMoveEvent,\n props: ModeProps<FeatureCollection>,\n ) {\n // Track shift key state from the source event\n const sourceEvent = event.sourceEvent as KeyboardEvent | undefined;\n this.isShiftPressed = sourceEvent?.shiftKey ?? false;\n\n super.handlePointerMove(event, props);\n\n const clickSequence = this.getClickSequence();\n const firstClick = clickSequence.at(-1);\n if (!firstClick) {\n this.tooltip = null;\n return;\n }\n\n const { mapCoords } = event;\n const distanceUnits =\n (props.modeConfig?.distanceUnits as DistanceUnit) ??\n DEFAULT_DISTANCE_UNITS;\n\n const firstClickPoint = point(firstClick);\n const currentPoint = point(mapCoords);\n\n // Calculate dimensions by finding the corner point\n const cornerPoint = point([\n firstClick[0] as number,\n mapCoords[1] as number,\n ]);\n const dimension1 = distance(firstClickPoint, cornerPoint, {\n units: distanceUnits,\n });\n const dimension2 = distance(currentPoint, cornerPoint, {\n units: distanceUnits,\n });\n\n // Calculate area properly accounting for Earth's curvature\n const points = featureCollection([firstClickPoint, currentPoint]);\n const bboxPoly = bboxPolygon(bbox(points));\n const rectArea = area(bboxPoly);\n const convertedArea = convertArea(rectArea, 'meters', distanceUnits);\n const unitAbbrev = DISTANCE_UNIT_SYMBOLS[distanceUnits];\n\n this.tooltip = {\n position: mapCoords,\n text: formatRectangleTooltip(\n dimension1,\n dimension2,\n convertedArea,\n unitAbbrev,\n ),\n };\n }\n\n /**\n * Get the current tooltip array for rendering.\n *\n * @returns Array containing the tooltip if one is active, empty array otherwise\n */\n override getTooltips(): Tooltip[] {\n return this.tooltip ? [this.tooltip] : [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,IAAa,+BAAb,cAAkD,kBAAkB;;CAElE,AAAQ,UAA0B;;CAElC,AAAQ,iBAAiB;;;;;;;;;;;;;;CAezB,AAAS,mBACP,QACA,QACA,YACA;EACA,IAAI,cAAc;AAGlB,MAAI,KAAK,kBAAkB,UAAU,QAAQ;GAC3C,MAAM,OAAO,OAAO,MAAM;GAC1B,MAAM,OAAO,OAAO,MAAM;GAC1B,MAAM,OAAO,OAAO,MAAM;GAC1B,MAAM,OAAO,OAAO,MAAM;GAI1B,MAAM,iBAAiB,SACrB,MAAM,CAAC,MAAM,KAAK,CAAC,EACnB,MAAM,CAAC,MAAM,KAAK,CAAC,EACnB,EACE,OAAO,cACR,CACF;GAED,MAAM,eAAe,SAAS,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,EACtE,OAAO,cACR,CAAC;GAGF,MAAM,UAAU,KAAK,IAAI,gBAAgB,aAAa;GAGtD,MAAM,UAAU,QAAQ,OAAO,IAAI;GACnC,MAAM,UAAU,QAAQ,OAAO,IAAI;AAsBnC,iBAToB,YATI,YACtB,MAAM,CAAC,MAAM,KAAK,CAAC,EACnB,SACA,UAAU,IAAI,KAAK,KACnB,EACE,OAAO,cACR,CACF,EAIC,SACA,UAAU,IAAI,IAAI,KAClB,EACE,OAAO,cACR,CACF,CAEyB,SAAS;;AAIrC,SAAO,MAAM,mBAAmB,QAAQ,aAAa,WAAW;;;;;;;;;;;;CAalE,AAAS,kBACP,OACA,OACA;AAGA,OAAK,iBADe,MAAM,aACS,YAAY;AAE/C,QAAM,kBAAkB,OAAO,MAAM;EAGrC,MAAM,aADgB,KAAK,kBAAkB,CACZ,GAAG,GAAG;AACvC,MAAI,CAAC,YAAY;AACf,QAAK,UAAU;AACf;;EAGF,MAAM,EAAE,cAAc;EACtB,MAAM,gBACH,MAAM,YAAY,iBACnB;EAEF,MAAM,kBAAkB,MAAM,WAAW;EACzC,MAAM,eAAe,MAAM,UAAU;EAGrC,MAAM,cAAc,MAAM,CACxB,WAAW,IACX,UAAU,GACX,CAAC;EACF,MAAM,aAAa,SAAS,iBAAiB,aAAa,EACxD,OAAO,eACR,CAAC;EACF,MAAM,aAAa,SAAS,cAAc,aAAa,EACrD,OAAO,eACR,CAAC;EAMF,MAAM,gBAAgB,YADL,KADA,YAAY,KADd,kBAAkB,CAAC,iBAAiB,aAAa,CAAC,CACxB,CAAC,CACX,EACa,UAAU,cAAc;EACpE,MAAM,aAAa,sBAAsB;AAEzC,OAAK,UAAU;GACb,UAAU;GACV,MAAM,uBACJ,YACA,YACA,eACA,WACD;GACF;;;;;;;CAQH,AAAS,cAAyB;AAChC,SAAO,KAAK,UAAU,CAAC,KAAK,QAAQ,GAAG,EAAE"}
|
|
@@ -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
|
|
@@ -64,37 +64,7 @@ const MODE_INSTANCES = {
|
|
|
64
64
|
function getModeInstance(shapeType) {
|
|
65
65
|
return MODE_INSTANCES[shapeType];
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Trigger double-click finish on the active drawing mode.
|
|
69
|
-
*
|
|
70
|
-
* This is a workaround for @deck.gl-community/editable-layers ~9.1 which doesn't
|
|
71
|
-
* register 'dblclick' in EVENT_TYPES. We listen for dblclick at the DOM level
|
|
72
|
-
* and call this function to finish drawing.
|
|
73
|
-
*
|
|
74
|
-
* Only LineString and Polygon modes support double-click to finish. Other shape
|
|
75
|
-
* types are completed with a single click and ignore this call.
|
|
76
|
-
*
|
|
77
|
-
* @param shapeType - The shape type currently being drawn
|
|
78
|
-
* @see https://github.com/visgl/deck.gl-community/pull/225
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* import { triggerDoubleClickFinish } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';
|
|
83
|
-
* import { ShapeFeatureType } from '@accelint/map-toolkit/deckgl/shapes/shared/types';
|
|
84
|
-
*
|
|
85
|
-
* // Listen for double-click at the DOM level
|
|
86
|
-
* mapContainer.addEventListener('dblclick', () => {
|
|
87
|
-
* if (currentShapeType === ShapeFeatureType.Polygon) {
|
|
88
|
-
* triggerDoubleClickFinish(currentShapeType);
|
|
89
|
-
* }
|
|
90
|
-
* });
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
function triggerDoubleClickFinish(shapeType) {
|
|
94
|
-
const mode = MODE_INSTANCES[shapeType];
|
|
95
|
-
if (mode instanceof DrawPolygonModeWithTooltip || mode instanceof DrawLineStringModeWithTooltip) mode.handleDoubleClick();
|
|
96
|
-
}
|
|
97
67
|
|
|
98
68
|
//#endregion
|
|
99
|
-
export { getModeInstance
|
|
69
|
+
export { getModeInstance };
|
|
100
70
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/index.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 { DrawPointMode, ViewMode } from '@deck.gl-community/editable-layers';\nimport { ShapeFeatureType } from '../../shared/types';\nimport { DrawCircleModeWithTooltip } from './draw-circle-mode-with-tooltip';\nimport { DrawEllipseModeWithTooltip } from './draw-ellipse-mode-with-tooltip';\nimport { DrawLineStringModeWithTooltip } from './draw-line-string-mode-with-tooltip';\nimport { DrawPolygonModeWithTooltip } from './draw-polygon-mode-with-tooltip';\nimport { DrawRectangleModeWithTooltip } from './draw-rectangle-mode-with-tooltip';\n\nexport { DrawCircleModeWithTooltip } from './draw-circle-mode-with-tooltip';\nexport { DrawEllipseModeWithTooltip } from './draw-ellipse-mode-with-tooltip';\nexport { DrawLineStringModeWithTooltip } from './draw-line-string-mode-with-tooltip';\nexport { DrawPolygonModeWithTooltip } from './draw-polygon-mode-with-tooltip';\nexport { DrawRectangleModeWithTooltip } from './draw-rectangle-mode-with-tooltip';\n\n/**\n * Cached mode instances.\n *\n * CRITICAL: Mode instances must be cached at module level to prevent\n * deck.gl assertion failures. Creating new mode instances on each render\n * causes the EditableGeoJsonLayer to fail with assertion errors.\n */\nconst MODE_INSTANCES = {\n [ShapeFeatureType.Point]: new DrawPointMode(),\n [ShapeFeatureType.LineString]: new DrawLineStringModeWithTooltip(),\n [ShapeFeatureType.Polygon]: new DrawPolygonModeWithTooltip(),\n [ShapeFeatureType.Rectangle]: new DrawRectangleModeWithTooltip(),\n [ShapeFeatureType.Circle]: new DrawCircleModeWithTooltip(),\n [ShapeFeatureType.Ellipse]: new DrawEllipseModeWithTooltip(),\n view: new ViewMode(),\n};\n\n/**\n * Get the cached mode instance for a shape type.\n *\n * Returns the pre-instantiated drawing mode for the specified shape type.\n * Modes are cached at module level to prevent deck.gl assertion failures\n * that occur when creating new mode instances on each render.\n *\n * @param shapeType - The shape type to get the mode for\n * @returns The cached mode instance for drawing that shape type\n *\n * @example\n * ```typescript\n * import { getModeInstance } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n * import { ShapeFeatureType } from '@accelint/map-toolkit/deckgl/shapes/shared/types';\n *\n * // Get the mode for drawing circles\n * const circleMode = getModeInstance(ShapeFeatureType.Circle);\n *\n * // Use with EditableGeoJsonLayer\n * const layer = new EditableGeoJsonLayer({\n * mode: circleMode,\n * // ... other props\n * });\n * ```\n */\nexport function getModeInstance(\n shapeType: ShapeFeatureType,\n): (typeof MODE_INSTANCES)[ShapeFeatureType] {\n return MODE_INSTANCES[shapeType];\n}\n\n/**\n * Get the view mode instance (for when not drawing).\n *\n * Returns the pre-instantiated ViewMode which is the default mode when\n * no drawing operation is active. This mode allows viewing and interacting\n * with the map without drawing new shapes.\n *\n * @returns The cached ViewMode instance\n *\n * @example\n * ```typescript\n * import { getViewModeInstance } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n *\n * // Get the view mode (default when not drawing)\n * const viewMode = getViewModeInstance();\n *\n * // Use with EditableGeoJsonLayer\n * const layer = new EditableGeoJsonLayer({\n * mode: viewMode,\n * // ... other props\n * });\n * ```\n */\nexport function getViewModeInstance(): ViewMode {\n return MODE_INSTANCES.view;\n}\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/deckgl/shapes/draw-shape-layer/modes/index.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 { DrawPointMode, ViewMode } from '@deck.gl-community/editable-layers';\nimport { ShapeFeatureType } from '../../shared/types';\nimport { DrawCircleModeWithTooltip } from './draw-circle-mode-with-tooltip';\nimport { DrawEllipseModeWithTooltip } from './draw-ellipse-mode-with-tooltip';\nimport { DrawLineStringModeWithTooltip } from './draw-line-string-mode-with-tooltip';\nimport { DrawPolygonModeWithTooltip } from './draw-polygon-mode-with-tooltip';\nimport { DrawRectangleModeWithTooltip } from './draw-rectangle-mode-with-tooltip';\n\nexport { DrawCircleModeWithTooltip } from './draw-circle-mode-with-tooltip';\nexport { DrawEllipseModeWithTooltip } from './draw-ellipse-mode-with-tooltip';\nexport { DrawLineStringModeWithTooltip } from './draw-line-string-mode-with-tooltip';\nexport { DrawPolygonModeWithTooltip } from './draw-polygon-mode-with-tooltip';\nexport { DrawRectangleModeWithTooltip } from './draw-rectangle-mode-with-tooltip';\n\n/**\n * Cached mode instances.\n *\n * CRITICAL: Mode instances must be cached at module level to prevent\n * deck.gl assertion failures. Creating new mode instances on each render\n * causes the EditableGeoJsonLayer to fail with assertion errors.\n */\nconst MODE_INSTANCES = {\n [ShapeFeatureType.Point]: new DrawPointMode(),\n [ShapeFeatureType.LineString]: new DrawLineStringModeWithTooltip(),\n [ShapeFeatureType.Polygon]: new DrawPolygonModeWithTooltip(),\n [ShapeFeatureType.Rectangle]: new DrawRectangleModeWithTooltip(),\n [ShapeFeatureType.Circle]: new DrawCircleModeWithTooltip(),\n [ShapeFeatureType.Ellipse]: new DrawEllipseModeWithTooltip(),\n view: new ViewMode(),\n};\n\n/**\n * Get the cached mode instance for a shape type.\n *\n * Returns the pre-instantiated drawing mode for the specified shape type.\n * Modes are cached at module level to prevent deck.gl assertion failures\n * that occur when creating new mode instances on each render.\n *\n * @param shapeType - The shape type to get the mode for\n * @returns The cached mode instance for drawing that shape type\n *\n * @example\n * ```typescript\n * import { getModeInstance } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n * import { ShapeFeatureType } from '@accelint/map-toolkit/deckgl/shapes/shared/types';\n *\n * // Get the mode for drawing circles\n * const circleMode = getModeInstance(ShapeFeatureType.Circle);\n *\n * // Use with EditableGeoJsonLayer\n * const layer = new EditableGeoJsonLayer({\n * mode: circleMode,\n * // ... other props\n * });\n * ```\n */\nexport function getModeInstance(\n shapeType: ShapeFeatureType,\n): (typeof MODE_INSTANCES)[ShapeFeatureType] {\n return MODE_INSTANCES[shapeType];\n}\n\n/**\n * Get the view mode instance (for when not drawing).\n *\n * Returns the pre-instantiated ViewMode which is the default mode when\n * no drawing operation is active. This mode allows viewing and interacting\n * with the map without drawing new shapes.\n *\n * @returns The cached ViewMode instance\n *\n * @example\n * ```typescript\n * import { getViewModeInstance } from '@accelint/map-toolkit/deckgl/shapes/draw-shape-layer/modes';\n *\n * // Get the view mode (default when not drawing)\n * const viewMode = getViewModeInstance();\n *\n * // Use with EditableGeoJsonLayer\n * const layer = new EditableGeoJsonLayer({\n * mode: viewMode,\n * // ... other props\n * });\n * ```\n */\nexport function getViewModeInstance(): ViewMode {\n return MODE_INSTANCES.view;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,iBAAiB;EACpB,iBAAiB,QAAQ,IAAI,eAAe;EAC5C,iBAAiB,aAAa,IAAI,+BAA+B;EACjE,iBAAiB,UAAU,IAAI,4BAA4B;EAC3D,iBAAiB,YAAY,IAAI,8BAA8B;EAC/D,iBAAiB,SAAS,IAAI,2BAA2B;EACzD,iBAAiB,UAAU,IAAI,4BAA4B;CAC5D,MAAM,IAAI,UAAU;CACrB;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BD,SAAgB,gBACd,WAC2C;AAC3C,QAAO,eAAe"}
|
|
@@ -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
|
|
@@ -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
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { DistanceUnitAbbreviation } from "../../../shared/units.js";
|
|
14
13
|
import { CircleProperties, Shape, ShapeFeatureType, StyleProperties } from "../shared/types.js";
|
|
15
14
|
import { UniqueId } from "@accelint/core";
|
|
15
|
+
import { DistanceUnitSymbol } from "@accelint/constants/units";
|
|
16
16
|
import { Feature } from "geojson";
|
|
17
17
|
|
|
18
18
|
//#region src/deckgl/shapes/draw-shape-layer/types.d.ts
|
|
@@ -75,7 +75,7 @@ type DrawShapeLayerProps = {
|
|
|
75
75
|
*/
|
|
76
76
|
mapId?: UniqueId;
|
|
77
77
|
/** Distance unit for tooltip measurements (defaults to 'km') */
|
|
78
|
-
unit?:
|
|
78
|
+
unit?: DistanceUnitSymbol;
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
81
|
* Function type for the draw action
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -13,20 +13,15 @@
|
|
|
13
13
|
|
|
14
14
|
'use client';
|
|
15
15
|
|
|
16
|
+
import { createLoggerDomain } from "../../../../shared/logger.js";
|
|
16
17
|
import { ShapeFeatureType } from "../../shared/types.js";
|
|
17
18
|
import { DEFAULT_DISTANCE_UNITS } from "../../../../shared/units.js";
|
|
18
19
|
import { DEFAULT_STYLE_PROPERTIES } from "../../shared/constants.js";
|
|
19
|
-
import { getLogger } from "@accelint/logger";
|
|
20
20
|
import { uuid } from "@accelint/core";
|
|
21
21
|
import { centroid, distance } from "@turf/turf";
|
|
22
22
|
|
|
23
23
|
//#region src/deckgl/shapes/draw-shape-layer/utils/feature-conversion.ts
|
|
24
|
-
const logger =
|
|
25
|
-
enabled: process.env.NODE_ENV !== "production",
|
|
26
|
-
level: "warn",
|
|
27
|
-
prefix: "[FeatureConversion]",
|
|
28
|
-
pretty: true
|
|
29
|
-
});
|
|
24
|
+
const logger = createLoggerDomain("[FeatureConversion]");
|
|
30
25
|
/**
|
|
31
26
|
* Generate a default name for a shape based on its type.
|
|
32
27
|
*
|