@deck.gl-community/editable-layers 9.1.1 → 9.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/edit-modes/draw-line-string-mode.d.ts +3 -1
  2. package/dist/edit-modes/draw-line-string-mode.d.ts.map +1 -1
  3. package/dist/edit-modes/draw-line-string-mode.js +19 -21
  4. package/dist/edit-modes/draw-line-string-mode.js.map +1 -1
  5. package/dist/edit-modes/draw-polygon-mode.d.ts +3 -1
  6. package/dist/edit-modes/draw-polygon-mode.d.ts.map +1 -1
  7. package/dist/edit-modes/draw-polygon-mode.js +19 -22
  8. package/dist/edit-modes/draw-polygon-mode.js.map +1 -1
  9. package/dist/edit-modes/edit-mode.d.ts +2 -1
  10. package/dist/edit-modes/edit-mode.d.ts.map +1 -1
  11. package/dist/edit-modes/geojson-edit-mode.d.ts +1 -0
  12. package/dist/edit-modes/geojson-edit-mode.d.ts.map +1 -1
  13. package/dist/edit-modes/geojson-edit-mode.js +1 -0
  14. package/dist/edit-modes/geojson-edit-mode.js.map +1 -1
  15. package/dist/edit-modes/measure-distance-mode.d.ts.map +1 -1
  16. package/dist/edit-modes/rotate-mode.d.ts.map +1 -1
  17. package/dist/edit-modes/scale-mode.d.ts.map +1 -1
  18. package/dist/edit-modes/types.d.ts +1 -0
  19. package/dist/edit-modes/types.d.ts.map +1 -1
  20. package/dist/editable-layers/editable-geojson-layer.d.ts +2 -1
  21. package/dist/editable-layers/editable-geojson-layer.d.ts.map +1 -1
  22. package/dist/editable-layers/editable-geojson-layer.js +5 -0
  23. package/dist/editable-layers/editable-geojson-layer.js.map +1 -1
  24. package/dist/editable-layers/editable-layer.d.ts +3 -1
  25. package/dist/editable-layers/editable-layer.d.ts.map +1 -1
  26. package/dist/editable-layers/editable-layer.js +7 -1
  27. package/dist/editable-layers/editable-layer.js.map +1 -1
  28. package/dist/index.cjs +604 -79
  29. package/dist/index.cjs.map +4 -4
  30. package/dist/lib/layers/segments-layer.d.ts +1 -1
  31. package/dist/lib/layers/segments-layer.d.ts.map +1 -1
  32. package/dist/lib/layers/segments-layer.js +1 -1
  33. package/dist/lib/layers/segments-layer.js.map +1 -1
  34. package/dist/lib/nebula-core.d.ts.map +1 -1
  35. package/dist/utils/memoize.d.ts.map +1 -1
  36. package/package.json +11 -11
  37. package/src/edit-modes/draw-line-string-mode.ts +23 -24
  38. package/src/edit-modes/draw-polygon-mode.ts +24 -27
  39. package/src/edit-modes/edit-mode.ts +4 -1
  40. package/src/edit-modes/geojson-edit-mode.ts +2 -0
  41. package/src/edit-modes/types.ts +3 -0
  42. package/src/editable-layers/editable-geojson-layer.ts +8 -1
  43. package/src/editable-layers/editable-layer.ts +10 -2
  44. package/src/lib/layers/segments-layer.ts +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/lib/style.ts", "../src/lib/deck-renderer/deck-drawer.ts", "../src/lib/feature.ts", "../src/lib/layer-mouse-event.ts", "../src/lib/nebula-layer.ts", "../src/utils/utils.ts", "../src/lib/deck-renderer/deck-cache.ts", "../src/editable-layers/junction-scatterplot-layer.ts", "../src/lib/layers/junctions-layer.ts", "../src/lib/layers/texts-layer.ts", "../src/lib/constants.ts", "../src/lib/layers/segments-layer.ts", "../src/lib/nebula-core.ts", "../src/editable-layers/editable-geojson-layer.ts", "../src/edit-modes/geojson-edit-mode.ts", "../src/edit-modes/utils.ts", "../src/edit-modes/immutable-feature-collection.ts", "../src/edit-modes/view-mode.ts", "../src/edit-modes/translate-mode.ts", "../src/utils/translate-from-center.ts", "../src/edit-modes/modify-mode.ts", "../src/edit-modes/scale-mode.ts", "../src/edit-modes/rotate-mode.ts", "../src/edit-modes/duplicate-mode.ts", "../src/edit-modes/split-polygon-mode.ts", "../src/edit-modes/extrude-mode.ts", "../src/edit-modes/elevation-mode.ts", "../src/edit-modes/draw-point-mode.ts", "../src/edit-modes/draw-line-string-mode.ts", "../src/utils/memoize.ts", "../src/edit-modes/draw-polygon-mode.ts", "../src/edit-modes/draw-rectangle-mode.ts", "../src/edit-modes/two-click-polygon-mode.ts", "../src/edit-modes/draw-square-mode.ts", "../src/edit-modes/draw-rectangle-from-center-mode.ts", "../src/edit-modes/draw-square-from-center-mode.ts", "../src/edit-modes/draw-circle-from-center-mode.ts", "../src/edit-modes/draw-circle-by-diameter-mode.ts", "../src/edit-modes/draw-ellipse-by-bounding-box-mode.ts", "../src/edit-modes/three-click-polygon-mode.ts", "../src/edit-modes/draw-rectangle-using-three-points-mode.ts", "../src/edit-modes/draw-ellipse-using-three-points-mode.ts", "../src/edit-modes/draw-90degree-polygon-mode.ts", "../src/edit-modes/draw-polygon-by-dragging-mode.ts", "../src/edit-modes/snappable-mode.ts", "../src/edit-modes/transform-mode.ts", "../src/edit-modes/composite-mode.ts", "../src/edit-modes/delete-mode.ts", "../src/constants.ts", "../src/editable-layers/editable-layer.ts", "../src/editable-layers/editable-path-layer.ts", "../src/editable-layers/editable-h3-cluster-layer.ts", "../src/editable-layers/selection-layer.ts", "../src/editable-layers/elevated-edit-handle-layer.ts", "../src/edit-modes/resize-circle-mode.ts", "../src/edit-modes/extend-line-string-mode.ts", "../src/edit-modes/measure-distance-mode.ts", "../src/edit-modes/measure-area-mode.ts", "../src/edit-modes/measure-angle-mode.ts"],
4
- "sourcesContent": ["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {ArrowStyles, DEFAULT_ARROWS, MAX_ARROWS} from './lib/style';\nexport {SELECTION_TYPE} from './lib/deck-renderer/deck-drawer';\n\nexport {Feature} from './lib/feature';\nexport {LayerMouseEvent} from './lib/layer-mouse-event';\n\nexport {NebulaLayer} from './lib/nebula-layer';\nexport {JunctionsLayer} from './lib/layers/junctions-layer';\nexport {TextsLayer} from './lib/layers/texts-layer';\nexport {SegmentsLayer} from './lib/layers/segments-layer';\n\nexport {NebulaCore} from './lib/nebula-core';\n\nexport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from './lib/constants';\n\n// Utils\nexport {toDeckColor} from './utils/utils';\n\n// Types\nexport type {Color, Style, Viewport} from './utils/types';\n\n// Layers\nexport {EditableGeoJsonLayer} from './editable-layers/editable-geojson-layer';\nexport {EditableH3ClusterLayer} from './editable-layers/editable-h3-cluster-layer';\nexport {SelectionLayer} from './editable-layers/selection-layer';\nexport {ElevatedEditHandleLayer} from './editable-layers/elevated-edit-handle-layer';\n\n// Layers move to deck.gl-community/layers?\nexport {JunctionScatterplotLayer} from './editable-layers/junction-scatterplot-layer';\n\n// Types\n\nimport * as utils from './utils/utils';\n\nexport {utils};\n\nexport {getPickedEditHandle, getEditHandlesForGeometry} from './edit-modes/utils';\n\nexport type {EditMode} from './edit-modes/edit-mode';\nexport type {GeoJsonEditModeType} from './edit-modes/geojson-edit-mode';\nexport type {GeoJsonEditModeConstructor} from './edit-modes/geojson-edit-mode';\n\nexport type {EditableGeoJsonLayerProps} from './editable-layers/editable-geojson-layer';\n\nexport {GeoJsonEditMode} from './edit-modes/geojson-edit-mode';\n\n// Alter modes\nexport {ModifyMode} from './edit-modes/modify-mode';\nexport {ResizeCircleMode} from './edit-modes/resize-circle-mode';\nexport {TranslateMode} from './edit-modes/translate-mode';\nexport {ScaleMode} from './edit-modes/scale-mode';\nexport {RotateMode} from './edit-modes/rotate-mode';\nexport {DuplicateMode} from './edit-modes/duplicate-mode';\nexport {ExtendLineStringMode} from './edit-modes/extend-line-string-mode';\nexport {SplitPolygonMode} from './edit-modes/split-polygon-mode';\nexport {ExtrudeMode} from './edit-modes/extrude-mode';\nexport {ElevationMode} from './edit-modes/elevation-mode';\nexport {TransformMode} from './edit-modes/transform-mode';\n\n// Draw modes\nexport {DrawPointMode} from './edit-modes/draw-point-mode';\nexport {DrawLineStringMode} from './edit-modes/draw-line-string-mode';\nexport {DrawPolygonMode} from './edit-modes/draw-polygon-mode';\nexport {DrawRectangleMode} from './edit-modes/draw-rectangle-mode';\nexport {DrawSquareMode} from './edit-modes/draw-square-mode';\nexport {DrawRectangleFromCenterMode} from './edit-modes/draw-rectangle-from-center-mode';\nexport {DrawSquareFromCenterMode} from './edit-modes/draw-square-from-center-mode';\nexport {DrawCircleByDiameterMode} from './edit-modes/draw-circle-by-diameter-mode';\nexport {DrawCircleFromCenterMode} from './edit-modes/draw-circle-from-center-mode';\nexport {DrawEllipseByBoundingBoxMode} from './edit-modes/draw-ellipse-by-bounding-box-mode';\nexport {DrawEllipseUsingThreePointsMode} from './edit-modes/draw-ellipse-using-three-points-mode';\nexport {DrawRectangleUsingThreePointsMode} from './edit-modes/draw-rectangle-using-three-points-mode';\nexport {Draw90DegreePolygonMode} from './edit-modes/draw-90degree-polygon-mode';\nexport {DrawPolygonByDraggingMode} from './edit-modes/draw-polygon-by-dragging-mode';\nexport {ImmutableFeatureCollection} from './edit-modes/immutable-feature-collection';\n\n// Other modes\nexport {ViewMode} from './edit-modes/view-mode';\nexport {MeasureDistanceMode} from './edit-modes/measure-distance-mode';\nexport {MeasureAreaMode} from './edit-modes/measure-area-mode';\nexport {MeasureAngleMode} from './edit-modes/measure-angle-mode';\nexport {CompositeMode} from './edit-modes/composite-mode';\nexport {SnappableMode} from './edit-modes/snappable-mode';\n\nexport type {\n ScreenCoordinates,\n EditAction,\n Pick,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps,\n GuideFeatureCollection,\n // Viewport,\n Tooltip\n} from './edit-modes/types';\n\nexport type {\n Position,\n PointCoordinates,\n LineStringCoordinates,\n PolygonCoordinates,\n MultiPointCoordinates,\n MultiLineStringCoordinates,\n MultiPolygonCoordinates,\n AnyCoordinates,\n Point,\n LineString,\n Polygon,\n MultiPoint,\n MultiLineString,\n MultiPolygon,\n Geometry,\n Polygonal,\n BoundingBoxArray,\n FeatureOf,\n FeatureWithProps,\n // Feature,\n FeatureCollection,\n AnyGeoJson\n} from './utils/geojson-types';\n\n// Experimental\nexport {memoize as _memoize} from './utils/memoize';\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Describes the arrow style of polylines\nexport const ArrowStyles = {\n NONE: 0,\n FORWARD: 1,\n BACKWARD: 2,\n BOTH: 3\n};\n\nexport const DEFAULT_ARROWS = 1;\nexport const MAX_ARROWS = 3;\n\nexport const DEFAULT_STYLE = {\n arrowColor: [0, 0, 0, 1],\n arrowCount: DEFAULT_ARROWS,\n arrowStyle: ArrowStyles.NONE,\n fillColor: [0, 0, 0, 1],\n lineColor: [0, 0, 0, 1],\n lineWidthMeters: 5,\n outlineRadiusMeters: 0,\n opacity: 1,\n zLevel: 0\n};\n", "import {PolygonLayer} from '@deck.gl/layers';\nimport {point, polygon} from '@turf/helpers';\nimport turfBbox from '@turf/bbox';\nimport turfBboxPolygon from '@turf/bbox-polygon';\nimport turfBuffer from '@turf/buffer';\nimport turfDifference from '@turf/difference';\nimport turfDistance from '@turf/distance';\n\nimport {Color} from '../../utils/types';\n\nconst POLYGON_LINE_COLOR = [0, 255, 0, 255];\nconst POLYGON_FILL_COLOR = [255, 255, 255, 90];\nconst POLYGON_LINE_WIDTH = 2;\n// const POLYGON_DASHES = [20, 20];\nconst POLYGON_THRESHOLD = 0.01;\nconst EXPANSION_KM = 10;\nconst LAYER_ID_VIEW = 'DeckDrawerView';\nconst LAYER_ID_PICK = 'DeckDrawerPick';\n\nexport const SELECTION_TYPE = {\n NONE: null,\n RECTANGLE: 'rectangle',\n POLYGON: 'polygon'\n};\n\nexport class DeckDrawer {\n nebula: Record<string, any>;\n usePolygon: boolean;\n validPolygon: boolean;\n landPoints: [number, number][];\n mousePoints: [number, number][];\n\n constructor(nebula: Record<string, any>) {\n this.nebula = nebula;\n this.usePolygon = false;\n this.validPolygon = true;\n this.landPoints = [];\n this.mousePoints = [];\n }\n\n _getLayerIds() {\n // TODO: sort by mouse priority\n return this.nebula.deckgl.props.layers\n .filter((l) => l && l.props && l.props.nebulaLayer && l.props.nebulaLayer.enableSelection)\n .map((l) => l.id);\n }\n\n _selectFromPickingInfos(pickingInfos: Record<string, any>[]) {\n const objects = pickingInfos.map(\n ({layer, index, object}) =>\n object.original || layer.props.nebulaLayer.deckCache.originals[index]\n );\n this.nebula.props.onSelection(objects);\n }\n\n _getBoundingBox(): Record<string, any> {\n const {mousePoints} = this;\n const allX = mousePoints.map((mousePoint) => mousePoint[0]);\n const allY = mousePoints.map((mousePoint) => mousePoint[1]);\n const x = Math.min(...allX);\n const y = Math.min(...allY);\n const maxX = Math.max(...allX);\n const maxY = Math.max(...allY);\n\n return {x, y, width: maxX - x, height: maxY - y};\n }\n\n _selectRectangleObjects() {\n if (this.landPoints.length !== 2) return;\n\n const [x1, y1] = this.mousePoints[0];\n const [x2, y2] = this.mousePoints[1];\n const pickingInfos = this.nebula.deckgl.pickObjects({\n x: Math.min(x1, x2),\n y: Math.min(y1, y2),\n width: Math.abs(x2 - x1),\n height: Math.abs(y2 - y1),\n layerIds: this._getLayerIds()\n });\n\n this._selectFromPickingInfos(pickingInfos);\n }\n\n _selectPolygonObjects() {\n const pickingInfos = this.nebula.deckgl.pickObjects({\n ...this._getBoundingBox(),\n layerIds: [LAYER_ID_PICK, ...this._getLayerIds()]\n });\n\n this._selectFromPickingInfos(pickingInfos.filter((item) => item.layer.id !== LAYER_ID_PICK));\n }\n\n _getMousePosFromEvent(event: Record<string, any>): [number, number] {\n const {offsetX, offsetY} = event;\n return [offsetX, offsetY];\n }\n\n // eslint-disable-next-line max-statements, complexity\n handleEvent(\n event: Record<string, any>,\n lngLat: [number, number],\n selectionType: number\n ): {redraw: boolean; deactivate: boolean} {\n // capture all events (mouse-up is needed to prevent us stuck in moving map)\n if (event.type !== 'mouseup') event.stopPropagation();\n\n // @ts-expect-error revisit selectionType type\n this.usePolygon = selectionType === SELECTION_TYPE.POLYGON;\n\n let redraw = false;\n let deactivate = false;\n\n const {usePolygon, landPoints, mousePoints} = this;\n\n if (event.type === 'mousedown') {\n if (usePolygon && landPoints.length) {\n // if landPoints.length is zero we want to insert two points (so we let it run the else)\n // also don't insert if polygon is invalid\n if (this.landPoints.length < 3 || this.validPolygon) {\n landPoints.push(lngLat);\n mousePoints.push(this._getMousePosFromEvent(event));\n }\n } else {\n this.landPoints = [lngLat, lngLat];\n const m = this._getMousePosFromEvent(event);\n this.mousePoints = [m, m];\n }\n redraw = true;\n } else if (event.type === 'mousemove' && landPoints.length) {\n // update last point\n landPoints[landPoints.length - 1] = lngLat;\n mousePoints[mousePoints.length - 1] = this._getMousePosFromEvent(event);\n redraw = true;\n } else if (event.type === 'mouseup') {\n if (usePolygon) {\n // check to see if completed\n // TODO: Maybe double-click to finish?\n if (\n landPoints.length > 4 &&\n turfDistance(landPoints[0], landPoints[landPoints.length - 1]) < POLYGON_THRESHOLD &&\n this.validPolygon\n ) {\n this._selectPolygonObjects();\n this.reset();\n redraw = true;\n deactivate = true;\n }\n } else {\n this._selectRectangleObjects();\n this.reset();\n redraw = true;\n deactivate = true;\n }\n }\n\n return {redraw, deactivate};\n }\n\n reset() {\n this.landPoints = [];\n this.mousePoints = [];\n }\n\n _makeStartPointHighlight(center: [number, number]): number[] {\n const buffer = turfBuffer(point(center), POLYGON_THRESHOLD / 4.0);\n // @ts-expect-error revisit return type\n return turfBboxPolygon(turfBbox(buffer)).geometry.coordinates;\n }\n\n render() {\n const data: any[] = [];\n const dataPick: any[] = [];\n\n if (!this.usePolygon && this.landPoints.length === 2) {\n // Use mouse points instead of land points so we get the right shape\n // no matter what bearing is.\n const [[x1, y1], [x2, y2]] = this.mousePoints;\n const selPolygon = [\n [x1, y1],\n [x1, y2],\n [x2, y2],\n [x2, y1],\n [x1, y1]\n ].map((mousePos) => this.nebula.unprojectMousePosition(mousePos));\n data.push({\n polygon: selPolygon,\n lineColor: POLYGON_LINE_COLOR,\n fillColor: POLYGON_FILL_COLOR\n });\n } else if (this.usePolygon && this.landPoints.length) {\n data.push({\n polygon: this.landPoints,\n lineColor: POLYGON_LINE_COLOR,\n fillColor: POLYGON_FILL_COLOR\n });\n\n // Hack: use a polygon to hide the outside, because pickObjects()\n // does not support polygons\n if (this.landPoints.length >= 3) {\n const landPointsPoly = polygon([[...this.landPoints, this.landPoints[0]]]);\n const bigBuffer = turfBuffer(point(this.landPoints[0]), EXPANSION_KM);\n let bigPolygon;\n try {\n // turfDifference throws an exception if the polygon\n // intersects with itself\n bigPolygon = turfDifference(bigBuffer, landPointsPoly);\n dataPick.push({\n polygon: bigPolygon.geometry.coordinates,\n fillColor: [0, 0, 0, 1]\n });\n this.validPolygon = true;\n } catch (e) {\n // invalid selection polygon\n this.validPolygon = false;\n }\n }\n }\n\n if (this.landPoints.length) {\n // highlight start point\n data.push({\n polygon: this._makeStartPointHighlight(this.landPoints[0]),\n lineColor: [0, 0, 0, 0],\n fillColor: POLYGON_LINE_COLOR\n });\n }\n\n // Hack to make the PolygonLayer() stay active,\n // otherwise it takes 3 seconds (!) to init!\n // TODO: fix this\n data.push({polygon: [[0, 0]]});\n dataPick.push({polygon: [[0, 0]]});\n\n return [\n new PolygonLayer({\n id: LAYER_ID_VIEW,\n data,\n fp64: false,\n opacity: 1.0,\n pickable: false,\n lineWidthMinPixels: POLYGON_LINE_WIDTH,\n lineWidthMaxPixels: POLYGON_LINE_WIDTH,\n lineDashJustified: true,\n // TODO(v9) Add extension\n // getLineDashArray: (x) => POLYGON_DASHES,\n getLineColor: (obj: {lineColor?: Color}) => obj.lineColor || [0, 0, 0, 255],\n getFillColor: (obj: {fillColor?: Color}) => obj.fillColor || [0, 0, 0, 255],\n getPolygon: (o: {polygon?: any}) => o.polygon\n }),\n new PolygonLayer({\n id: LAYER_ID_PICK,\n data: dataPick,\n getLineColor: (obj: {lineColor?: Color}) => obj.lineColor || [0, 0, 0, 255],\n getFillColor: (obj: {fillColor?: Color}) => obj.fillColor || [0, 0, 0, 255],\n fp64: false,\n opacity: 1.0,\n stroked: false,\n pickable: true,\n getPolygon: (o: {polygon?: any}) => o.polygon\n })\n ];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Feature as GeoJson} from '../utils/geojson-types';\n\nimport {Style} from '../utils/types';\n\nexport class Feature {\n // geo json coordinates\n geoJson: GeoJson;\n style: Style;\n original: any | null | undefined;\n metadata: Record<string, any>;\n\n constructor(\n geoJson: GeoJson,\n style: Style,\n original: any | null | undefined = null,\n metadata: Record<string, any> = {}\n ) {\n this.geoJson = geoJson;\n this.style = style;\n this.original = original;\n this.metadata = metadata;\n }\n\n getCoords() {\n return this.geoJson.geometry.coordinates;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Position} from '../utils/geojson-types';\n\nexport class LayerMouseEvent {\n canceled: boolean = false;\n // original item that this event is related to\n data: Record<string, any>;\n // internal nebula info about the object\n metadata: Record<string, any>;\n // the mouse [lng,lat] raycasted onto the ground\n groundPoint: Position;\n // browser event\n nativeEvent: MouseEvent;\n // reference to nebula\n nebula: Record<string, any>;\n\n constructor(nativeEvent: MouseEvent, {data, groundPoint, nebula, metadata}: Record<string, any>) {\n this.nativeEvent = nativeEvent;\n\n this.data = data;\n this.groundPoint = groundPoint;\n this.nebula = nebula;\n this.metadata = metadata;\n }\n\n stopPropagation() {\n this.nativeEvent.stopPropagation();\n this.canceled = true;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {EventEmitter} from 'eventemitter3';\nimport {v4} from 'uuid';\n\nimport {Feature} from './feature';\n\nexport class NebulaLayer extends EventEmitter {\n getData: () => Record<string, any>[];\n toNebulaFeature: (data: Record<string, any>) => Feature;\n id: string;\n helperLayers: Record<string, any>[];\n\n // flags\n usesMapEvents = false;\n enablePicking = false;\n enableSelection = false;\n //\n\n constructor({getData, on, toNebulaFeature}: Record<string, any>) {\n super();\n this.id = v4();\n this.getData = getData;\n this.toNebulaFeature = toNebulaFeature;\n this.helperLayers = [];\n\n if (on) {\n Object.keys(on).forEach((key) => this.on(key, on[key]));\n }\n }\n\n render(config: Record<string, any>): unknown {\n return null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport destination from '@turf/destination';\nimport bearing from '@turf/bearing';\nimport pointToLineDistance from '@turf/point-to-line-distance';\nimport {point} from '@turf/helpers';\nimport {WebMercatorViewport} from 'viewport-mercator-project';\nimport {FeatureOf, FeatureWithProps, LineString, Point, Position} from './geojson-types';\nimport {Viewport} from './types';\n\n// TODO edit-modes: delete and use edit-modes/utils instead\n\nexport type NearestPointType = FeatureWithProps<Point, {dist: number; index: number}>;\n\nexport function toDeckColor(\n color?: [number, number, number, number] | number,\n defaultColor: [number, number, number, number] = [255, 0, 0, 255]\n): [number, number, number, number] {\n if (!Array.isArray(color)) {\n return defaultColor;\n }\n return [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255];\n}\n\n//\n// a GeoJSON helper function that calls the provided function with\n// an argument that is the most deeply-nested array having elements\n// that are arrays of primitives as an argument, e.g.\n//\n// {\n// \"type\": \"MultiPolygon\",\n// \"coordinates\": [\n// [\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n// ],\n// [\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n// ]\n// ]\n// }\n//\n// the function would be called on:\n//\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n//\n// and\n//\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n//\nexport function recursivelyTraverseNestedArrays(\n array: Array<any>,\n prefix: Array<number>,\n fn: Function\n) {\n if (!Array.isArray(array[0])) {\n return true;\n }\n for (let i = 0; i < array.length; i++) {\n if (recursivelyTraverseNestedArrays(array[i], [...prefix, i], fn)) {\n fn(array, prefix);\n break;\n }\n }\n return false;\n}\n\nexport function generatePointsParallelToLinePoints(\n p1: Position,\n p2: Position,\n mapCoords: Position\n): Position[] {\n const lineString: LineString = {\n type: 'LineString',\n coordinates: [p1, p2]\n };\n const pt = point(mapCoords);\n const ddistance = pointToLineDistance(pt, lineString);\n const lineBearing = bearing(p1, p2);\n\n // Check if current point is to the left or right of line\n // Line from A=(x1,y1) to B=(x2,y2) a point P=(x,y)\n // then (x\u2212x1)(y2\u2212y1)\u2212(y\u2212y1)(x2\u2212x1)\n const isPointToLeftOfLine =\n (mapCoords[0] - p1[0]) * (p2[1] - p1[1]) - (mapCoords[1] - p1[1]) * (p2[0] - p1[0]);\n\n // Bearing to draw perpendicular to the line string\n const orthogonalBearing = isPointToLeftOfLine < 0 ? lineBearing - 90 : lineBearing - 270;\n\n // Get coordinates for the point p3 and p4 which are perpendicular to the lineString\n // Add the distance as the current position moves away from the lineString\n const p3 = destination(p2, ddistance, orthogonalBearing);\n const p4 = destination(p1, ddistance, orthogonalBearing);\n return [p3.geometry.coordinates, p4.geometry.coordinates] as [Position, Position];\n}\n\nexport function distance2d(x1: number, y1: number, x2: number, y2: number): number {\n const dx = x1 - x2;\n const dy = y1 - y2;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nexport function mix(a: number, b: number, ratio: number): number {\n return b * ratio + a * (1 - ratio);\n}\n\nexport function nearestPointOnProjectedLine(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport\n): NearestPointType {\n const wmViewport = new WebMercatorViewport(viewport);\n // Project the line to viewport, then find the nearest point\n const coordinates: Array<Array<number>> = line.geometry.coordinates as any;\n const projectedCoords = coordinates.map(([x, y, z = 0]) => wmViewport.project([x, y, z]));\n const [x, y] = wmViewport.project(inPoint.geometry.coordinates);\n // console.log('projectedCoords', JSON.stringify(projectedCoords));\n\n let minDistance = Infinity;\n let minPointInfo = {};\n\n projectedCoords.forEach(([x2, y2], index) => {\n if (index === 0) {\n return;\n }\n\n const [x1, y1] = projectedCoords[index - 1];\n\n // line from projectedCoords[index - 1] to projectedCoords[index]\n // convert to Ax + By + C = 0\n const A = y1 - y2;\n const B = x2 - x1;\n const C = x1 * y2 - x2 * y1;\n\n // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line\n const div = A * A + B * B;\n const distance = Math.abs(A * x + B * y + C) / Math.sqrt(div);\n\n // TODO: Check if inside bounds\n\n if (distance < minDistance) {\n minDistance = distance;\n minPointInfo = {\n index,\n x0: (B * (B * x - A * y) - A * C) / div,\n y0: (A * (-B * x + A * y) - B * C) / div\n };\n }\n });\n const {index, x0, y0} = minPointInfo as any;\n const [x1, y1, z1 = 0] = projectedCoords[index - 1];\n const [x2, y2, z2 = 0] = projectedCoords[index];\n\n // calculate what ratio of the line we are on to find the proper z\n const lineLength = distance2d(x1, y1, x2, y2);\n const startToPointLength = distance2d(x1, y1, x0, y0);\n const ratio = startToPointLength / lineLength;\n const z0 = mix(z1, z2, ratio);\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: wmViewport.unproject([x0, y0, z0])\n },\n properties: {\n // TODO: calculate the distance in proper units\n dist: minDistance,\n index: index - 1\n }\n };\n}\n\n/**\n * Inserts toInsert string into base string before insertBefore string.\n * @param base A string to insert into.\n * @param insertBeforeText A sub string in `base` string to insert before.\n * @param toInsert A string to insert.\n * @returns Combined string. `base` string if `insertBefore` string isn't found.\n */\nexport function insertBefore(base: string, insertBeforeText: string, toInsert: string): string {\n const at = base.indexOf(insertBeforeText);\n if (at < 0) {\n return base;\n }\n return base.slice(0, at) + toInsert + base.slice(at);\n}\n", "export class DeckCache<TORIG, TCONV> {\n objects: TCONV[];\n originals: TORIG[];\n updateTrigger: number;\n _idToPosition: Map<string, number>;\n _getData: () => TORIG[];\n _convert: (arg0: TORIG) => TCONV;\n\n constructor(getData: () => TORIG[], convert: (arg0: TORIG) => TCONV) {\n this.objects = [];\n this.originals = [];\n this.updateTrigger = 0;\n\n this._idToPosition = new Map();\n this._getData = getData;\n this._convert = convert;\n }\n\n updateAllDeckObjects() {\n if (!this._getData || !this._convert) return;\n\n this.originals.length = 0;\n this.objects.length = 0;\n this._idToPosition.clear();\n\n this._getData().forEach((d) => {\n this._idToPosition.set((d as any).id, this.objects.length);\n this.originals.push(d);\n this.objects.push(this._convert(d));\n });\n\n this.triggerUpdate();\n }\n\n updateDeckObjectsByIds(ids: string[]) {\n if (!this._getData || !this._convert) return;\n\n ids.forEach((id) => {\n const p = this._idToPosition.get(id);\n if (p !== undefined) {\n this.objects[p] = this._convert(this.originals[p]);\n }\n });\n\n this.triggerUpdate();\n }\n\n triggerUpdate() {\n this.updateTrigger++;\n }\n\n getDeckObjectById(id: string): TCONV | null | undefined {\n const p = this._idToPosition.get(id);\n return p !== undefined ? this.objects[p] : null;\n }\n\n getOriginalById(id: string): TORIG | null | undefined {\n const p = this._idToPosition.get(id);\n return p !== undefined ? this.originals[p] : null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CompositeLayerProps, DefaultProps} from '@deck.gl/core';\nimport {CompositeLayer} from '@deck.gl/core';\nimport type {ScatterplotLayerProps} from '@deck.gl/layers';\nimport {ScatterplotLayer} from '@deck.gl/layers';\n\nimport {Color} from '../utils/types';\n\ntype JunctionScatterplotLayerProps = CompositeLayerProps &\n Omit<ScatterplotLayerProps, 'getFillColor'> & {\n getFillColor?: Color | ((d) => Color);\n getStrokeColor?: Color | ((d) => Color);\n getInnerRadius?: number | ((d) => number);\n };\n\nexport class JunctionScatterplotLayer extends CompositeLayer<JunctionScatterplotLayerProps> {\n static layerName = 'JunctionScatterplotLayer';\n static defaultProps: DefaultProps<JunctionScatterplotLayerProps> = {\n ...ScatterplotLayer.defaultProps,\n getFillColor: (d) => [0, 0, 0, 255],\n getStrokeColor: (d) => [255, 255, 255, 255],\n getInnerRadius: (d) => 1\n };\n\n renderLayers() {\n const {id, getFillColor, getStrokeColor, getInnerRadius, updateTriggers} = this.props;\n\n // data needs to be passed explicitly after deck.gl 5.3\n return [\n // the full circles\n new ScatterplotLayer<any>({\n ...this.props,\n id: `${id}-full`,\n data: this.props.data as any,\n getLineColor: getStrokeColor,\n updateTriggers: {\n ...updateTriggers,\n getStrokeColor: updateTriggers.getStrokeColor\n }\n }), // the inner part\n new ScatterplotLayer<any>({\n ...this.props,\n id: `${id}-inner`,\n data: this.props.data as any,\n getFillColor,\n getRadius: getInnerRadius,\n pickable: false,\n updateTriggers: {\n ...updateTriggers,\n getFillColor: updateTriggers.getFillColor,\n getRadius: updateTriggers.getInnerRadius\n }\n })\n ];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {NebulaLayer} from '../nebula-layer';\nimport {toDeckColor} from '../../utils/utils';\nimport {DeckCache} from '../deck-renderer/deck-cache';\nimport {JunctionScatterplotLayer} from '../../editable-layers/junction-scatterplot-layer';\n\nexport class JunctionsLayer extends NebulaLayer {\n deckCache: DeckCache<any, any>;\n\n constructor(config: Record<string, any>) {\n super(config);\n this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));\n this.enablePicking = true;\n }\n\n render({nebula}: Record<string, any>) {\n const defaultColor: [number, number, number, number] = [0x0, 0x0, 0x0, 0xff];\n const {objects, updateTrigger} = this.deckCache;\n\n return new JunctionScatterplotLayer({\n id: `junctions-${this.id}`,\n data: objects,\n opacity: 1,\n pickable: true,\n getPosition: (nf: any) => nf.geoJson.geometry.coordinates,\n getFillColor: (nf: any) => toDeckColor(nf.style.fillColor) || defaultColor,\n getStrokeColor: (nf: any) =>\n toDeckColor(nf.style.outlineColor) || toDeckColor(nf.style.fillColor) || defaultColor,\n getRadius: (nf: any) => nf.style.pointRadiusMeters + nf.style.outlineRadiusMeters || 1,\n getInnerRadius: (nf: any) => nf.style.pointRadiusMeters || 0.5,\n parameters: {\n depthCompare: 'always'\n },\n\n updateTriggers: {all: updateTrigger},\n\n // @ts-expect-error TODO\n nebulaLayer: this\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TextLayer} from '@deck.gl/layers';\nimport {NebulaLayer} from '../nebula-layer';\nimport {toDeckColor} from '../../utils/utils';\nimport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from '../constants';\nimport {DeckCache} from '../deck-renderer/deck-cache';\nimport {Color} from '../../utils/types';\n\nexport class TextsLayer extends NebulaLayer {\n deckCache: DeckCache<any, any>;\n\n constructor(config: Record<string, any>) {\n super(config);\n this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));\n }\n\n render({nebula}: Record<string, any>): TextLayer {\n const defaultColor: Color = [0x0, 0x0, 0x0, 0xff];\n const {objects, updateTrigger} = this.deckCache;\n\n const {zoom} = nebula.props.viewport;\n\n return new TextLayer({\n id: `texts-${this.id}`,\n data: objects,\n opacity: 1,\n fp64: false,\n pickable: false,\n\n getText: (nf: any) => nf.style.text,\n getPosition: (nf: any) => nf.geoJson.geometry.coordinates,\n getColor: (nf: {style: {fillColor: Color}}) =>\n toDeckColor(nf.style.fillColor) || defaultColor,\n\n // TODO: layer should offer option to scale with zoom\n sizeScale: 1 / Math.pow(2, 20 - zoom),\n getSize: PROJECTED_PIXEL_SIZE_MULTIPLIER,\n\n updateTriggers: {all: updateTrigger},\n\n nebulaLayer: this\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.\n * Required in order to maintain the same appearance after upgrading to deck.gl v8.5.\n * https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md\n */\nexport const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ArrowStyles, DEFAULT_STYLE, MAX_ARROWS} from '../style';\nimport {NebulaLayer} from '../nebula-layer';\nimport {toDeckColor} from '../../utils/utils';\nimport {DeckCache} from '../deck-renderer/deck-cache';\nimport {PathMarkerLayer} from '@deck.gl-community/layers';\n\nconst NEBULA_TO_DECK_DIRECTIONS = {\n [ArrowStyles.NONE]: {forward: false, backward: false},\n [ArrowStyles.FORWARD]: {forward: true, backward: false},\n [ArrowStyles.BACKWARD]: {forward: false, backward: true},\n [ArrowStyles.BOTH]: {forward: true, backward: true}\n};\n\nexport class SegmentsLayer extends NebulaLayer {\n deckCache: DeckCache<any, any>;\n noBlend: boolean;\n highlightColor: [number, number, number, number];\n arrowSize: number;\n jointRounded: boolean;\n capRounded: boolean;\n dashed: boolean;\n markerLayerProps: Record<string, any> | null | undefined;\n\n constructor(config: Record<string, any>) {\n super(config);\n this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));\n this.enableSelection = true;\n this.enablePicking = config.enablePicking ?? true;\n this.noBlend = config.noBlend ?? false;\n this.jointRounded = config.jointRounded ?? true;\n this.capRounded = config.capRounded ?? true;\n this.dashed = config.dashed ?? false;\n this.markerLayerProps = config.markerLayerProps ?? null;\n this.highlightColor = [1, 1, 1, 1];\n this.arrowSize = 1;\n }\n\n getMouseOverSegment(): any {\n // TODO: remove references\n return null;\n }\n\n _calcMarkerPercentages(nf: Record<string, any>): number[] {\n const {arrowPercentages} = nf.style;\n if (arrowPercentages) {\n return arrowPercentages;\n }\n\n const arrowStyle = nf.style.arrowStyle || DEFAULT_STYLE.arrowStyle;\n if (arrowStyle === ArrowStyles.NONE) return [];\n\n const arrowCount = Math.min(nf.style.arrowCount || DEFAULT_STYLE.arrowCount, MAX_ARROWS);\n return [[0.5], [0.33, 0.66], [0.25, 0.5, 0.75]][arrowCount - 1];\n }\n\n _getHighlightedObjectIndex({nebula}: Record<string, any>): number {\n const {deckglMouseOverInfo} = nebula;\n if (deckglMouseOverInfo) {\n const {originalLayer, index} = deckglMouseOverInfo;\n if (originalLayer === this) {\n return index;\n }\n }\n\n // no object\n return -1;\n }\n\n render({nebula}: Record<string, any>) {\n const defaultColor: [number, number, number, number] = [0x0, 0x0, 0x0, 0xff];\n const {objects, updateTrigger} = this.deckCache;\n\n return new PathMarkerLayer<any>({\n id: `segments-${this.id}`,\n data: objects,\n opacity: 1,\n fp64: false,\n jointRounded: this.jointRounded,\n capRounded: this.capRounded,\n pickable: true,\n sizeScale: this.arrowSize || 6,\n parameters: {\n depthCompare: 'always',\n blendColorOperation: this.noBlend ? undefined : 'max'\n },\n getPath: (nf: any) => nf.geoJson.geometry.coordinates,\n getColor: (nf: any) => toDeckColor(nf.style.lineColor, defaultColor),\n getWidth: (nf: any) => nf.style.lineWidthMeters || 1,\n getZLevel: (nf: any) => nf.style.zLevel * 255,\n getDirection: (nf: any) => NEBULA_TO_DECK_DIRECTIONS[nf.style.arrowStyle],\n getMarkerColor: (nf: any) => toDeckColor(nf.style.arrowColor, defaultColor),\n // eslint-disable-next-line @typescript-eslint/unbound-method\n getMarkerPercentages: this._calcMarkerPercentages,\n updateTriggers: {all: updateTrigger},\n\n highlightedObjectIndex: this._getHighlightedObjectIndex({nebula}),\n highlightColor: toDeckColor(this.highlightColor),\n\n dashJustified: this.dashed,\n getDashArray: this.dashed ? (nf) => nf.style.dashArray : undefined,\n markerLayerProps:\n this.markerLayerProps ||\n (PathMarkerLayer as Record<string, any>).defaultProps.markerLayerProps,\n\n nebulaLayer: this\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {EventEmitter} from 'eventemitter3';\nimport {WebMercatorViewport} from '@deck.gl/core';\n\nimport {DeckDrawer} from './deck-renderer/deck-drawer';\nimport {LayerMouseEvent} from './layer-mouse-event';\nimport {NebulaLayer} from './nebula-layer';\n\nconst LOGGER_PREFIX = 'Nebula: ';\n\nexport class NebulaCore {\n init(props: Record<string, any>) {\n this.props = props;\n this.wmViewport = new WebMercatorViewport(this.props.viewport);\n\n // TODO: Properly use pointer events: ['click', 'pointermove', 'pointerup', 'pointerdown']\n ['click', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>\n document.addEventListener(name, this._onMouseEvent as any, true)\n );\n }\n\n detach() {\n // TODO: Properly use pointer events: ['click', 'pointermove', 'pointerup', 'pointerdown']\n ['click', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>\n document.removeEventListener(name, this._onMouseEvent as any, true)\n );\n }\n\n updateProps(newProps: Record<string, any>) {\n this.props = newProps;\n const {viewport} = this.props;\n\n this.wmViewport = new WebMercatorViewport(viewport);\n }\n\n props: Record<string, any> = null!;\n deckgl: Record<string, any> | null = null;\n mainContainer: Record<string, any> | null = null;\n deckglMouseOverInfo: Record<string, any> | null | undefined = null;\n _deckDrawer: DeckDrawer = null!;\n _mouseWasDown: boolean = null!;\n wmViewport: WebMercatorViewport = null!;\n queryObjectEvents = new EventEmitter();\n forceUpdate: () => any = null!;\n inited: boolean = null!;\n\n log(message: string) {\n const {logger} = this.props;\n if (logger && logger.info) {\n logger.info(LOGGER_PREFIX + message);\n }\n }\n\n updateAllDeckObjects() {\n this.getAllLayers().forEach((layer) => {\n if (layer && layer.deckCache) {\n layer.deckCache.updateAllDeckObjects();\n }\n });\n this.forceUpdate();\n }\n\n updateDeckObjectsByIds(ids: string[]) {\n this.getAllLayers().forEach((layer) => {\n if (layer && layer.deckCache) {\n layer.deckCache.updateDeckObjectsByIds(ids);\n }\n });\n this.forceUpdate();\n }\n\n rerenderLayers() {\n this.updateAllDeckObjects();\n }\n\n _isNebulaEvent({buttons, target, type}: Record<string, any>) {\n const {viewport} = this.props;\n\n // allow mouseup event aggressively to cancel drag properly\n // TODO: use pointer capture setPointerCapture() to capture mouseup properly after deckgl\n if (this._mouseWasDown && type === 'mouseup') {\n this._mouseWasDown = false;\n return true;\n }\n\n // allow mousemove event while dragging\n if (type === 'mousemove' && buttons > 0) {\n return true;\n }\n\n if (!target.getBoundingClientRect) {\n return false;\n }\n\n const rect = target.getBoundingClientRect();\n // Only listen to events coming from the basemap\n // identified by the canvas of the same size as viewport.\n // Need to round the rect dimension as some monitors\n // have some sub-pixel difference with viewport.\n return (\n Math.round(rect.width) === Math.round(viewport.width) &&\n Math.round(rect.height) === Math.round(viewport.height)\n );\n }\n\n _onMouseEvent = (event: MouseEvent) => {\n if (!this._isNebulaEvent(event)) {\n return;\n }\n\n if (event.type === 'mousedown') {\n this._mouseWasDown = true;\n }\n\n // offsetX/Y of the MouseEvent provides the offset in the X/Y coordinate\n // of the mouse pointer between that event and the padding edge of the target node.\n // We set our listener to document so we need to adjust offsetX/Y\n // in case the target is not be our WebGL canvas.\n const {top = 0, left = 0} = this.mainContainer\n ? this.mainContainer.getBoundingClientRect()\n : {};\n const proxyEvent = new Proxy(event, {\n get: (original: any, propertyName: string) => {\n if (propertyName === 'offsetX') {\n return original.pageX - left;\n }\n\n if (propertyName === 'offsetY') {\n return original.pageY - top;\n }\n\n // TODO: Properly use pointer events\n if (propertyName === 'type') {\n return original.type.replace('pointer', 'mouse');\n }\n\n const result = original[propertyName];\n if (typeof result === 'function') {\n return result.bind(original);\n }\n return result;\n }\n });\n\n this._handleDeckGLEvent(proxyEvent);\n };\n\n getMouseGroundPosition(event: Record<string, any>) {\n return this.wmViewport.unproject([event.offsetX, event.offsetY]) as [number, number];\n }\n\n unprojectMousePosition(mousePosition: [number, number]): [number, number] {\n return this.wmViewport.unproject(mousePosition) as [number, number];\n }\n\n // eslint-disable-next-line max-statements, complexity\n _handleDeckGLEvent(event: Record<string, any>) {\n const {\n deckgl,\n props: {onMapMouseEvent, selectionType, eventFilter}\n } = this;\n let sendMapEvent = true;\n let cursor = 'auto';\n\n if (event && deckgl && selectionType) {\n if (!this._deckDrawer) this._deckDrawer = new DeckDrawer(this);\n\n const lngLat = this.getMouseGroundPosition(event);\n if (eventFilter && !eventFilter(lngLat, event)) return;\n const drawerResult = this._deckDrawer.handleEvent(event, lngLat, selectionType);\n if (drawerResult.redraw) this.forceUpdate();\n return;\n }\n\n if (event && deckgl && (!event.buttons || event.type !== 'mousemove')) {\n // TODO: sort by mouse priority\n const layerIds = deckgl.props.layers\n .filter(\n (l: any) => l && l.props && l.props.nebulaLayer && l.props.nebulaLayer.enablePicking\n )\n .map((l: any) => l.id);\n\n const pickingInfo = deckgl.pickObject({\n x: event.offsetX,\n y: event.offsetY,\n radius: 5,\n layerIds\n });\n this.queryObjectEvents.emit('pick', {event, pickingInfo});\n if (pickingInfo) {\n sendMapEvent = false;\n\n const {index, lngLat} = pickingInfo;\n if (eventFilter && !eventFilter(lngLat, event)) return;\n\n const {layer: deckLayer, object} = pickingInfo;\n\n if (\n deckLayer &&\n deckLayer.props &&\n deckLayer.props.nebulaLayer &&\n deckLayer.props.nebulaLayer.eventHandler\n ) {\n deckLayer.props.nebulaLayer.eventHandler(event, pickingInfo);\n }\n\n const original =\n object.original ||\n (deckLayer.props.nebulaLayer &&\n deckLayer.props.nebulaLayer.deckCache &&\n deckLayer.props.nebulaLayer.deckCache.originals[index]);\n\n if (original) {\n this.deckglMouseOverInfo = {originalLayer: deckLayer.props.nebulaLayer, index};\n // @ts-expect-error narrow event type\n const nebulaMouseEvent = new LayerMouseEvent(event, {\n data: original,\n metadata: object.metadata,\n groundPoint: lngLat,\n nebula: this\n });\n deckLayer.props.nebulaLayer.emit(event.type, nebulaMouseEvent);\n this.forceUpdate();\n }\n\n cursor = 'pointer';\n }\n }\n\n if (document.documentElement) {\n document.documentElement.style.cursor = cursor;\n }\n\n if (sendMapEvent) {\n this.deckglMouseOverInfo = null;\n\n const lngLat = this.getMouseGroundPosition(event);\n if (eventFilter && !eventFilter(lngLat, event)) return;\n\n // send to layers first\n // @ts-expect-error narrow event type\n const nebulaMouseEvent = new LayerMouseEvent(event, {\n groundPoint: lngLat,\n nebula: this\n });\n this.getAllLayers()\n .filter((layer) => layer && layer.usesMapEvents)\n .forEach((layer) => layer.emit('mapMouseEvent', nebulaMouseEvent));\n\n this.getAllLayers()\n .filter(\n (layer) =>\n layer && layer.props && layer.props.nebulaLayer && layer.props.nebulaLayer.mapMouseEvent\n )\n .forEach((layer) => layer.props.nebulaLayer.mapMouseEvent(nebulaMouseEvent, layer));\n\n if (onMapMouseEvent) {\n onMapMouseEvent(event, lngLat);\n }\n }\n }\n\n getExtraDeckLayers(): Record<string, any>[] {\n const result: Record<string, any>[] = [];\n\n if (this._deckDrawer) result.push(...this._deckDrawer.render());\n\n return result;\n }\n\n renderDeckLayers() {\n return this.getAllLayers()\n .map((layer) => (layer instanceof NebulaLayer ? layer.render({nebula: this}) : layer))\n .filter(Boolean);\n }\n\n getAllLayers() {\n const result: Record<string, any>[] = [];\n\n this.props.layers.filter(Boolean).forEach((layer) => {\n result.push(layer);\n // Only NebulaLayers have helpers, Deck GL layers don't.\n if (layer instanceof NebulaLayer) {\n result.push(...layer.helperLayers);\n }\n });\n\n return result.filter(Boolean);\n }\n\n getRenderedLayers() {\n return [...this.renderDeckLayers(), ...this.getExtraDeckLayers()];\n }\n\n updateAndGetRenderedLayers(\n layers: Record<string, any>[],\n viewport: WebMercatorViewport,\n container: Record<string, any>\n ) {\n if (this.inited) {\n this.updateProps({layers, viewport});\n this.forceUpdate = () => container.forceUpdate();\n } else {\n this.inited = true;\n this.init({layers, viewport});\n this.forceUpdate = () => container.forceUpdate();\n this.updateAllDeckObjects();\n }\n\n return this.getRenderedLayers();\n }\n\n setDeck(deckgl: Record<string, any> | null) {\n if (deckgl) {\n this.deckgl = deckgl;\n }\n }\n\n setMainContainer(mainContainer: Record<string, any> | null) {\n if (mainContainer) {\n this.mainContainer = mainContainer;\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {UpdateParameters, DefaultProps} from '@deck.gl/core';\nimport {GeoJsonLayer, ScatterplotLayer, IconLayer, TextLayer} from '@deck.gl/layers';\nimport {\n EditAction,\n ClickEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n PointerMoveEvent\n} from '../edit-modes/types';\n\nimport {ViewMode} from '../edit-modes/view-mode';\nimport {TranslateMode} from '../edit-modes/translate-mode';\nimport {ModifyMode} from '../edit-modes/modify-mode';\nimport {ScaleMode} from '../edit-modes/scale-mode';\nimport {RotateMode} from '../edit-modes/rotate-mode';\nimport {DuplicateMode} from '../edit-modes/duplicate-mode';\nimport {SplitPolygonMode} from '../edit-modes/split-polygon-mode';\nimport {ExtrudeMode} from '../edit-modes/extrude-mode';\nimport {ElevationMode} from '../edit-modes/elevation-mode';\nimport {DrawPointMode} from '../edit-modes/draw-point-mode';\nimport {DrawLineStringMode} from '../edit-modes/draw-line-string-mode';\nimport {DrawPolygonMode} from '../edit-modes/draw-polygon-mode';\nimport {DrawRectangleMode} from '../edit-modes/draw-rectangle-mode';\nimport {DrawSquareMode} from '../edit-modes/draw-square-mode';\nimport {DrawRectangleFromCenterMode} from '../edit-modes/draw-rectangle-from-center-mode';\nimport {DrawSquareFromCenterMode} from '../edit-modes/draw-square-from-center-mode';\nimport {DrawCircleFromCenterMode} from '../edit-modes/draw-circle-from-center-mode';\nimport {DrawCircleByDiameterMode} from '../edit-modes/draw-circle-by-diameter-mode';\nimport {DrawEllipseByBoundingBoxMode} from '../edit-modes/draw-ellipse-by-bounding-box-mode';\nimport {DrawRectangleUsingThreePointsMode} from '../edit-modes/draw-rectangle-using-three-points-mode';\nimport {DrawEllipseUsingThreePointsMode} from '../edit-modes/draw-ellipse-using-three-points-mode';\nimport {Draw90DegreePolygonMode} from '../edit-modes/draw-90degree-polygon-mode';\nimport {DrawPolygonByDraggingMode} from '../edit-modes/draw-polygon-by-dragging-mode';\nimport {SnappableMode} from '../edit-modes/snappable-mode';\nimport {TransformMode} from '../edit-modes/transform-mode';\nimport {DeleteMode} from '../edit-modes/delete-mode';\nimport {GeoJsonEditModeType} from '../edit-modes/geojson-edit-mode';\n\nimport {Color} from '../utils/types';\nimport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from '../constants';\n\nimport {EditableLayer, EditableLayerProps} from './editable-layer';\nimport {EditablePathLayer} from './editable-path-layer';\nimport {Feature, FeatureCollection} from '../utils/geojson-types';\n\nconst DEFAULT_LINE_COLOR: Color = [0x0, 0x0, 0x0, 0x99];\nconst DEFAULT_FILL_COLOR: Color = [0x0, 0x0, 0x0, 0x90];\nconst DEFAULT_SELECTED_LINE_COLOR: Color = [0x0, 0x0, 0x0, 0xff];\nconst DEFAULT_SELECTED_FILL_COLOR: Color = [0x0, 0x0, 0x90, 0x90];\nconst DEFAULT_TENTATIVE_LINE_COLOR: Color = [0x90, 0x90, 0x90, 0xff];\nconst DEFAULT_TENTATIVE_FILL_COLOR: Color = [0x90, 0x90, 0x90, 0x90];\nconst DEFAULT_EDITING_EXISTING_POINT_COLOR: Color = [0xc0, 0x0, 0x0, 0xff];\nconst DEFAULT_EDITING_INTERMEDIATE_POINT_COLOR: Color = [0x0, 0x0, 0x0, 0x80];\nconst DEFAULT_EDITING_SNAP_POINT_COLOR: Color = [0x7c, 0x00, 0xc0, 0xff];\nconst DEFAULT_EDITING_POINT_OUTLINE_COLOR: Color = [0xff, 0xff, 0xff, 0xff];\nconst DEFAULT_EDITING_EXISTING_POINT_RADIUS = 5;\nconst DEFAULT_EDITING_INTERMEDIATE_POINT_RADIUS = 3;\nconst DEFAULT_EDITING_SNAP_POINT_RADIUS = 7;\nconst DEFAULT_TOOLTIP_FONT_SIZE = 32 * PROJECTED_PIXEL_SIZE_MULTIPLIER;\n\nconst DEFAULT_EDIT_MODE = DrawPolygonMode;\n\nfunction guideAccessor(accessor) {\n if (!accessor || typeof accessor !== 'function') {\n return accessor;\n }\n return (guideMaybeWrapped) => accessor(unwrapGuide(guideMaybeWrapped));\n}\n\n// The object handed to us from deck.gl is different depending on the version of deck.gl used, unwrap as necessary\nfunction unwrapGuide(guideMaybeWrapped) {\n if (guideMaybeWrapped.__source) {\n return guideMaybeWrapped.__source.object;\n } else if (guideMaybeWrapped.sourceFeature) {\n return guideMaybeWrapped.sourceFeature.feature;\n }\n // It is not wrapped, return as is\n return guideMaybeWrapped;\n}\n\nfunction getEditHandleColor(handle) {\n switch (handle.properties.editHandleType) {\n case 'existing':\n return DEFAULT_EDITING_EXISTING_POINT_COLOR;\n case 'snap-source':\n return DEFAULT_EDITING_SNAP_POINT_COLOR;\n case 'intermediate':\n default:\n return DEFAULT_EDITING_INTERMEDIATE_POINT_COLOR;\n }\n}\n\nfunction getEditHandleOutlineColor(handle) {\n return DEFAULT_EDITING_POINT_OUTLINE_COLOR;\n}\n\nfunction getEditHandleRadius(handle) {\n switch (handle.properties.editHandleType) {\n case 'existing':\n return DEFAULT_EDITING_EXISTING_POINT_RADIUS;\n case 'snap':\n return DEFAULT_EDITING_SNAP_POINT_RADIUS;\n case 'intermediate':\n default:\n return DEFAULT_EDITING_INTERMEDIATE_POINT_RADIUS;\n }\n}\n\nexport type EditableGeoJsonLayerProps<DataT = any> = EditableLayerProps & {\n data: DataT;\n mode?: any;\n modeConfig?: any;\n selectedFeatureIndexes?: number[];\n onEdit?: (updatedData?, editType?: string, featureIndexes?: number[], editContext?) => void;\n\n pickable?: boolean;\n pickingRadius?: number;\n pickingDepth?: number;\n fp64?: boolean;\n filled?: boolean;\n stroked?: boolean;\n lineWidthScale?: number;\n lineWidthMinPixels?: number;\n lineWidthMaxPixels?: number;\n pickingLineWidthExtraPixels?: number;\n lineWidthUnits?: string;\n lineJointRounded?: boolean;\n lineCapRounded?: boolean;\n lineMiterLimit?: number;\n pointRadiusScale?: number;\n pointRadiusMinPixels?: number;\n pointRadiusMaxPixels?: number;\n\n getLineColor?: Color | ((feature, isSelected, mode) => Color);\n getFillColor?: Color | ((feature, isSelected, mode) => Color);\n getRadius?: number | ((f) => number);\n getLineWidth?: number | ((f) => number);\n\n getTentativeLineColor?: Color | ((feature, isSelected, mode) => Color);\n getTentativeFillColor?: Color | ((feature, isSelected, mode) => Color);\n getTentativeLineWidth?: number | ((f) => number);\n\n editHandleType?: string;\n\n editHandlePointRadiusScale?: number;\n editHandlePointOutline?: boolean;\n editHandlePointStrokeWidth?: number;\n editHandlePointRadiusUnits?: string;\n editHandlePointRadiusMinPixels?: number;\n editHandlePointRadiusMaxPixels?: number;\n getEditHandlePointColor?: Color | ((handle) => Color);\n getEditHandlePointOutlineColor?: Color | ((handle) => Color);\n getEditHandlePointRadius?: number | ((handle) => number);\n\n // icon handles\n editHandleIconAtlas?: any;\n editHandleIconMapping?: any;\n editHandleIconSizeScale?: number;\n editHandleIconSizeUnits?: string;\n getEditHandleIcon?: (handle) => string;\n getEditHandleIconSize?: number;\n getEditHandleIconColor?: Color | ((handle) => Color);\n getEditHandleIconAngle?: number | ((handle) => number);\n\n // misc\n billboard?: boolean;\n};\n\nconst defaultProps: DefaultProps<EditableGeoJsonLayerProps<any>> = {\n mode: DEFAULT_EDIT_MODE,\n\n // Edit and interaction events\n onEdit: () => {},\n\n pickable: true,\n pickingRadius: 10,\n pickingDepth: 5,\n fp64: false,\n filled: true,\n stroked: true,\n lineWidthScale: PROJECTED_PIXEL_SIZE_MULTIPLIER,\n lineWidthMinPixels: 1,\n lineWidthMaxPixels: Number.MAX_SAFE_INTEGER,\n pickingLineWidthExtraPixels: 0,\n lineWidthUnits: 'pixels',\n lineJointRounded: false,\n lineCapRounded: false,\n lineMiterLimit: 4,\n pointRadiusScale: 1,\n pointRadiusMinPixels: 2,\n pointRadiusMaxPixels: Number.MAX_SAFE_INTEGER,\n getLineColor: (feature, isSelected, mode) =>\n isSelected ? DEFAULT_SELECTED_LINE_COLOR : DEFAULT_LINE_COLOR,\n getFillColor: (feature, isSelected, mode) =>\n isSelected ? DEFAULT_SELECTED_FILL_COLOR : DEFAULT_FILL_COLOR,\n getRadius: (f) =>\n (f && f.properties && f.properties.radius) || (f && f.properties && f.properties.size) || 1,\n getLineWidth: (f) => (f && f.properties && f.properties.lineWidth) || 3,\n\n // Tentative feature rendering\n getTentativeLineColor: (f) => DEFAULT_TENTATIVE_LINE_COLOR,\n getTentativeFillColor: (f) => DEFAULT_TENTATIVE_FILL_COLOR,\n getTentativeLineWidth: (f) => (f && f.properties && f.properties.lineWidth) || 3,\n\n editHandleType: 'point',\n\n // point handles\n editHandlePointRadiusScale: 1,\n editHandlePointOutline: true,\n editHandlePointStrokeWidth: 2,\n editHandlePointRadiusUnits: 'pixels',\n editHandlePointRadiusMinPixels: 4,\n editHandlePointRadiusMaxPixels: 8,\n getEditHandlePointColor: getEditHandleColor,\n getEditHandlePointOutlineColor: getEditHandleOutlineColor,\n getEditHandlePointRadius: getEditHandleRadius,\n\n // icon handles\n editHandleIconAtlas: null,\n editHandleIconMapping: null,\n editHandleIconSizeScale: 1,\n editHandleIconSizeUnits: 'pixels',\n getEditHandleIcon: (handle) => handle.properties.editHandleType,\n getEditHandleIconSize: 10,\n getEditHandleIconColor: getEditHandleColor,\n getEditHandleIconAngle: 0,\n\n // misc\n billboard: true\n};\n\n// Mapping of mode name to mode class (for legacy purposes)\nconst modeNameMapping = {\n view: ViewMode,\n\n // Alter modes\n modify: ModifyMode,\n translate: new SnappableMode(new TranslateMode()),\n\n transform: new SnappableMode(new TransformMode()),\n scale: ScaleMode,\n rotate: RotateMode,\n duplicate: DuplicateMode,\n split: SplitPolygonMode,\n extrude: ExtrudeMode,\n elevation: ElevationMode,\n delete: DeleteMode,\n\n // Draw modes\n drawPoint: DrawPointMode,\n drawLineString: DrawLineStringMode,\n drawPolygon: DrawPolygonMode,\n drawRectangle: DrawRectangleMode,\n drawSquare: DrawSquareMode,\n drawRectangleFromCenter: DrawRectangleFromCenterMode,\n drawSquareFromCenter: DrawSquareFromCenterMode,\n drawCircleFromCenter: DrawCircleFromCenterMode,\n drawCircleByBoundingBox: DrawCircleByDiameterMode,\n drawEllipseByBoundingBox: DrawEllipseByBoundingBoxMode,\n drawRectangleUsing3Points: DrawRectangleUsingThreePointsMode,\n drawEllipseUsing3Points: DrawEllipseUsingThreePointsMode,\n draw90DegreePolygon: Draw90DegreePolygonMode,\n drawPolygonByDragging: DrawPolygonByDraggingMode\n};\n\nexport class EditableGeoJsonLayer extends EditableLayer<\n FeatureCollection,\n EditableGeoJsonLayerProps<FeatureCollection>\n> {\n static layerName = 'EditableGeoJsonLayer';\n static defaultProps = defaultProps;\n\n state: EditableLayer['state'] & {\n cursor?: 'grabbing' | 'grab' | null;\n mode: GeoJsonEditModeType;\n lastPointerMoveEvent: PointerMoveEvent;\n tentativeFeature?: Feature;\n editHandles: any[];\n selectedFeatures: Feature[];\n } = undefined!;\n\n // setState: ($Shape<State>) => void;\n renderLayers() {\n const subLayerProps = this.getSubLayerProps({\n id: 'geojson',\n\n // Proxy most GeoJsonLayer props as-is\n data: this.props.data,\n fp64: this.props.fp64,\n filled: this.props.filled,\n stroked: this.props.stroked,\n lineWidthScale: this.props.lineWidthScale,\n lineWidthMinPixels: this.props.lineWidthMinPixels,\n lineWidthMaxPixels: this.props.lineWidthMaxPixels,\n lineWidthUnits: this.props.lineWidthUnits,\n lineJointRounded: this.props.lineJointRounded,\n lineCapRounded: this.props.lineCapRounded,\n lineMiterLimit: this.props.lineMiterLimit,\n pointRadiusScale: this.props.pointRadiusScale,\n pointRadiusMinPixels: this.props.pointRadiusMinPixels,\n pointRadiusMaxPixels: this.props.pointRadiusMaxPixels,\n getLineColor: this.selectionAwareAccessor(this.props.getLineColor),\n getFillColor: this.selectionAwareAccessor(this.props.getFillColor),\n getPointRadius: this.selectionAwareAccessor(this.props.getRadius),\n getLineWidth: this.selectionAwareAccessor(this.props.getLineWidth),\n\n _subLayerProps: {\n linestrings: {\n billboard: this.props.billboard,\n updateTriggers: {\n // required to update dashed array attribute\n all: [this.props.selectedFeatureIndexes, this.props.mode]\n }\n },\n 'polygons-stroke': {\n billboard: this.props.billboard,\n pickingLineWidthExtraPixels: this.props.pickingLineWidthExtraPixels,\n type: EditablePathLayer,\n updateTriggers: {\n // required to update dashed array attribute\n all: [this.props.selectedFeatureIndexes, this.props.mode]\n }\n }\n },\n\n updateTriggers: {\n getLineColor: [this.props.selectedFeatureIndexes, this.props.mode],\n getFillColor: [this.props.selectedFeatureIndexes, this.props.mode],\n getPointRadius: [this.props.selectedFeatureIndexes, this.props.mode],\n getLineWidth: [this.props.selectedFeatureIndexes, this.props.mode]\n }\n });\n\n let layers: any = [new GeoJsonLayer(subLayerProps)];\n\n layers = layers.concat(this.createGuidesLayers(), this.createTooltipsLayers());\n\n return layers;\n }\n\n initializeState() {\n super.initializeState();\n\n this.setState({\n selectedFeatures: [],\n editHandles: []\n });\n }\n\n // TODO: is this the best way to properly update state from an outside event handler?\n shouldUpdateState(opts: any) {\n // console.log(\n // 'shouldUpdateState',\n // opts.changeFlags.propsOrDataChanged,\n // opts.changeFlags.stateChanged\n // );\n return super.shouldUpdateState(opts) || opts.changeFlags.stateChanged;\n }\n\n updateState({props, oldProps, changeFlags, context}: UpdateParameters<this>) {\n super.updateState({oldProps, props, changeFlags, context});\n\n if (changeFlags.propsOrDataChanged) {\n const modePropChanged = Object.keys(oldProps).length === 0 || props.mode !== oldProps.mode;\n if (modePropChanged) {\n let mode: DrawPolygonMode;\n if (typeof props.mode === 'function') {\n // They passed a constructor/class, so new it up\n const ModeConstructor = props.mode;\n mode = new ModeConstructor();\n } else if (typeof props.mode === 'string') {\n // Lookup the mode based on its name (for backwards compatibility)\n mode = modeNameMapping[props.mode];\n // eslint-disable-next-line no-console\n console.warn(\n \"Deprecated use of passing `mode` as a string. Pass the mode's class constructor instead.\"\n );\n } else {\n // Should be an instance of EditMode in this case\n mode = props.mode;\n }\n\n if (!mode) {\n console.warn(`No mode configured for ${String(props.mode)}`); // eslint-disable-line no-console,no-undef\n // Use default mode\n mode = new DEFAULT_EDIT_MODE();\n }\n\n if (mode !== this.state.mode) {\n this.setState({mode, cursor: null});\n }\n }\n }\n\n let selectedFeatures = [];\n if (\n Array.isArray(props.selectedFeatureIndexes) &&\n typeof props.data === 'object' &&\n 'features' in props.data\n ) {\n // TODO: needs improved testing, i.e. checking for duplicates, NaNs, out of range numbers, ...\n const propsData = props.data;\n selectedFeatures = props.selectedFeatureIndexes.map((elem) => propsData.features[elem]);\n }\n\n this.setState({selectedFeatures});\n }\n\n getModeProps(props: EditableGeoJsonLayerProps<any>) {\n return {\n modeConfig: props.modeConfig,\n data: props.data,\n selectedIndexes: props.selectedFeatureIndexes,\n lastPointerMoveEvent: this.state.lastPointerMoveEvent,\n cursor: this.state.cursor,\n onEdit: (editAction: EditAction<FeatureCollection>) => {\n // Force a re-render\n // This supports double-click where we need to ensure that there's a re-render between the two clicks\n // even though the data wasn't changed, just the internal tentative feature.\n this.setNeedsUpdate();\n props.onEdit(editAction);\n },\n onUpdateCursor: (cursor: string | null | undefined) => {\n this.setState({cursor});\n }\n };\n }\n\n selectionAwareAccessor(accessor: any) {\n if (typeof accessor !== 'function') {\n return accessor;\n }\n return (feature: Feature) =>\n accessor(feature, this.isFeatureSelected(feature), this.props.mode);\n }\n\n isFeatureSelected(feature: Feature) {\n if (!this.props.data || !this.props.selectedFeatureIndexes) {\n return false;\n }\n if (!this.props.selectedFeatureIndexes.length) {\n return false;\n }\n\n return this.state.selectedFeatures.includes(feature);\n }\n\n getPickingInfo({info, sourceLayer}: Record<string, any>) {\n if (sourceLayer.id.endsWith('guides')) {\n // If user is picking an editing handle, add additional data to the info\n info.isGuide = true;\n }\n\n return info;\n }\n\n _updateAutoHighlight(info) {\n // Extra handling for guides\n if (info?.sourceLayer) {\n if (info.isGuide) {\n for (const layer of info.sourceLayer.getSubLayers()) {\n layer.updateAutoHighlight(info);\n }\n } else {\n info.sourceLayer.updateAutoHighlight(info);\n }\n }\n }\n\n createGuidesLayers() {\n const mode = this.getActiveMode();\n const guides: FeatureCollection = mode.getGuides(this.getModeProps(this.props));\n\n if (!guides || !guides.features.length) {\n return [];\n }\n\n const subLayerProps = {\n linestrings: {\n billboard: this.props.billboard,\n autoHighlight: false\n },\n 'polygons-fill': {\n autoHighlight: false\n },\n 'polygons-stroke': {\n billboard: this.props.billboard\n }\n };\n\n if (this.props.editHandleType === 'icon') {\n subLayerProps['points-icon'] = {\n type: IconLayer,\n iconAtlas: this.props.editHandleIconAtlas,\n iconMapping: this.props.editHandleIconMapping,\n sizeUnits: this.props.editHandleIconSizeUnits,\n sizeScale: this.props.editHandleIconSizeScale,\n getIcon: guideAccessor(this.props.getEditHandleIcon),\n getSize: guideAccessor(this.props.getEditHandleIconSize),\n getColor: guideAccessor(this.props.getEditHandleIconColor),\n getAngle: guideAccessor(this.props.getEditHandleIconAngle),\n billboard: this.props.billboard\n };\n } else {\n subLayerProps['points-circle'] = {\n type: ScatterplotLayer,\n radiusScale: this.props.editHandlePointRadiusScale,\n stroked: this.props.editHandlePointOutline,\n getLineWidth: this.props.editHandlePointStrokeWidth,\n radiusUnits: this.props.editHandlePointRadiusUnits,\n radiusMinPixels: this.props.editHandlePointRadiusMinPixels,\n radiusMaxPixels: this.props.editHandlePointRadiusMaxPixels,\n getRadius: guideAccessor(this.props.getEditHandlePointRadius),\n getFillColor: guideAccessor(this.props.getEditHandlePointColor),\n getLineColor: guideAccessor(this.props.getEditHandlePointOutlineColor),\n billboard: this.props.billboard\n };\n }\n\n const layer = new GeoJsonLayer(\n this.getSubLayerProps({\n id: 'guides',\n data: guides,\n fp64: this.props.fp64,\n _subLayerProps: subLayerProps,\n lineWidthScale: this.props.lineWidthScale,\n lineWidthMinPixels: this.props.lineWidthMinPixels,\n lineWidthMaxPixels: this.props.lineWidthMaxPixels,\n lineWidthUnits: this.props.lineWidthUnits,\n lineJointRounded: this.props.lineJointRounded,\n lineCapRounded: this.props.lineCapRounded,\n lineMiterLimit: this.props.lineMiterLimit,\n getLineColor: guideAccessor(this.props.getTentativeLineColor),\n getLineWidth: guideAccessor(this.props.getTentativeLineWidth),\n getFillColor: guideAccessor(this.props.getTentativeFillColor),\n pointType: this.props.editHandleType === 'icon' ? 'icon' : 'circle',\n iconAtlas: this.props.editHandleIconAtlas\n })\n );\n\n return [layer];\n }\n\n createTooltipsLayers() {\n const mode = this.getActiveMode();\n const tooltips = mode.getTooltips(this.getModeProps(this.props) as any);\n\n const layer = new TextLayer({\n getSize: DEFAULT_TOOLTIP_FONT_SIZE,\n ...this.getSubLayerProps({\n id: 'tooltips',\n data: tooltips\n })\n });\n\n return [layer];\n }\n\n onLayerClick(event: ClickEvent): void {\n this.getActiveMode().handleClick(event, this.getModeProps(this.props) as any);\n }\n\n onLayerKeyUp(event: KeyboardEvent): void {\n this.getActiveMode().handleKeyUp(event, this.getModeProps(this.props) as any);\n }\n\n onStartDragging(event: StartDraggingEvent): void {\n this.getActiveMode().handleStartDragging(event, this.getModeProps(this.props) as any);\n }\n\n onDragging(event: DraggingEvent): void {\n this.getActiveMode().handleDragging(event, this.getModeProps(this.props) as any);\n }\n\n onStopDragging(event: StopDraggingEvent): void {\n this.getActiveMode().handleStopDragging(event, this.getModeProps(this.props) as any);\n }\n\n onPointerMove(event: PointerMoveEvent): void {\n this.setState({lastPointerMoveEvent: event});\n this.getActiveMode().handlePointerMove(event, this.getModeProps(this.props) as any);\n }\n\n getCursor({isDragging}: {isDragging: boolean}): null | 'grabbing' | 'grab' {\n if (this.state === null || this.state === undefined) {\n // Layer in 'Awaiting state'\n return null;\n }\n\n let {cursor} = this.state;\n if (!cursor) {\n // default cursor\n cursor = isDragging ? 'grabbing' : 'grab';\n }\n return cursor;\n }\n\n getActiveMode(): GeoJsonEditModeType {\n return this.state.mode;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfUnion from '@turf/union';\nimport turfDifference from '@turf/difference';\nimport turfIntersect from '@turf/intersect';\nimport rewind from '@turf/rewind';\n\nimport {\n EditAction,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n Pick,\n Tooltip,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {FeatureCollection, Feature, Polygon, Geometry, Position} from '../utils/geojson-types';\nimport {getPickedEditHandles, getNonGuidePicks} from './utils';\nimport {EditMode} from './edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport type GeoJsonEditAction = EditAction<FeatureCollection>;\n\nconst DEFAULT_GUIDES: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n};\nconst DEFAULT_TOOLTIPS: Tooltip[] = [];\n\n// Main interface for `EditMode`s that edit GeoJSON\nexport type GeoJsonEditModeType = EditMode<FeatureCollection, FeatureCollection>;\n\nexport interface GeoJsonEditModeConstructor {\n new (): GeoJsonEditModeType;\n}\n\nexport class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeatureCollection> {\n _clickSequence: Position[] = [];\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n return DEFAULT_GUIDES;\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return DEFAULT_TOOLTIPS;\n }\n\n getSelectedFeature(props: ModeProps<FeatureCollection>): Feature | null | undefined {\n if (props.selectedIndexes.length === 1) {\n return props.data.features[props.selectedIndexes[0]];\n }\n return null;\n }\n\n getSelectedGeometry(props: ModeProps<FeatureCollection>): Geometry | null | undefined {\n const feature = this.getSelectedFeature(props);\n if (feature) {\n return feature.geometry;\n }\n return null;\n }\n\n getSelectedFeaturesAsFeatureCollection(props: ModeProps<FeatureCollection>): FeatureCollection {\n const {features} = props.data;\n const selectedFeatures = props.selectedIndexes.map((selectedIndex) => features[selectedIndex]);\n return {\n type: 'FeatureCollection',\n features: selectedFeatures\n };\n }\n\n getClickSequence(): Position[] {\n return this._clickSequence;\n }\n\n addClickSequence({mapCoords}: ClickEvent): void {\n this._clickSequence.push(mapCoords);\n }\n\n resetClickSequence(): void {\n this._clickSequence = [];\n }\n\n getTentativeGuide(props: ModeProps<FeatureCollection>): TentativeFeature | null | undefined {\n const guides = this.getGuides(props);\n return guides.features.find(\n (f) => f.properties && f.properties.guideType === 'tentative'\n ) as TentativeFeature;\n }\n\n isSelectionPicked(picks: Pick[], props: ModeProps<FeatureCollection>): boolean {\n if (!picks.length) return false;\n const pickedFeatures = getNonGuidePicks(picks).map(({index}) => index);\n const pickedHandles = getPickedEditHandles(picks).map(\n ({properties}) => properties.featureIndex\n );\n const pickedIndexes = new Set([...pickedFeatures, ...pickedHandles]);\n return props.selectedIndexes.some((index) => pickedIndexes.has(index));\n }\n\n rewindPolygon(feature: Feature): Feature {\n const {geometry} = feature;\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n if (isPolygonal) {\n // @ts-expect-error turf type too wide\n return rewind(feature);\n }\n\n return feature;\n }\n\n getAddFeatureAction(\n featureOrGeometry: Geometry | Feature,\n features: FeatureCollection,\n featureProperties?: {}\n ): GeoJsonEditAction {\n // Unsure why flow can't deal with Geometry type, but there I fixed it\n const featureOrGeometryAsAny: any = featureOrGeometry;\n featureProperties = featureProperties || {};\n\n const feature: any =\n featureOrGeometryAsAny.type === 'Feature'\n ? featureOrGeometryAsAny\n : {\n type: 'Feature',\n properties: featureProperties,\n geometry: featureOrGeometryAsAny\n };\n\n const rewindFeature = this.rewindPolygon(feature);\n const updatedData = new ImmutableFeatureCollection(features)\n .addFeature(rewindFeature)\n .getObject();\n\n return {\n updatedData,\n editType: 'addFeature',\n editContext: {\n featureIndexes: [updatedData.features.length - 1]\n }\n };\n }\n\n getAddManyFeaturesAction(\n {features: featuresToAdd}: FeatureCollection,\n features: FeatureCollection\n ): GeoJsonEditAction {\n let updatedData = new ImmutableFeatureCollection(features);\n const initialIndex = updatedData.getObject().features.length;\n const updatedIndexes: number[] = [];\n for (const feature of featuresToAdd) {\n const {properties, geometry} = feature;\n const geometryAsAny: any = geometry;\n updatedData = updatedData.addFeature({\n type: 'Feature',\n properties,\n geometry: geometryAsAny\n });\n updatedIndexes.push(initialIndex + updatedIndexes.length);\n }\n\n return {\n updatedData: updatedData.getObject(),\n editType: 'addFeature',\n editContext: {\n featureIndexes: updatedIndexes\n }\n };\n }\n\n // eslint-disable-next-line complexity\n getAddFeatureOrBooleanPolygonAction(\n featureOrGeometry: Polygon | Feature,\n props: ModeProps<FeatureCollection>,\n featureProperties?: {}\n ): GeoJsonEditAction | null | undefined {\n const featureOrGeometryAsAny: any = featureOrGeometry;\n featureProperties = featureProperties || {};\n\n const selectedFeature = this.getSelectedFeature(props);\n const {modeConfig} = props;\n if (modeConfig && modeConfig.booleanOperation) {\n if (\n !selectedFeature ||\n (selectedFeature.geometry.type !== 'Polygon' &&\n selectedFeature.geometry.type !== 'MultiPolygon')\n ) {\n // eslint-disable-next-line no-console,no-undef\n console.warn(\n 'booleanOperation only supported for single Polygon or MultiPolygon selection'\n );\n return null;\n }\n\n const feature =\n featureOrGeometryAsAny.type === 'Feature'\n ? featureOrGeometryAsAny\n : {\n type: 'Feature',\n geometry: featureOrGeometryAsAny\n };\n\n let updatedGeometry;\n if (modeConfig.booleanOperation === 'union') {\n // @ts-expect-error selectedFeature type too wide\n updatedGeometry = turfUnion(selectedFeature, feature);\n } else if (modeConfig.booleanOperation === 'difference') {\n // @ts-expect-error selectedFeature type too wide\n updatedGeometry = turfDifference(selectedFeature, feature);\n } else if (modeConfig.booleanOperation === 'intersection') {\n // @ts-expect-error selectedFeature type too wide\n updatedGeometry = turfIntersect(selectedFeature, feature);\n } else {\n // eslint-disable-next-line no-console,no-undef\n console.warn(`Invalid booleanOperation ${modeConfig.booleanOperation}`);\n return null;\n }\n\n if (!updatedGeometry) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('Canceling edit. Boolean operation erased entire polygon.');\n return null;\n }\n\n const featureIndex = props.selectedIndexes[0];\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replaceGeometry(featureIndex, updatedGeometry.geometry)\n .getObject();\n\n const editAction: GeoJsonEditAction = {\n updatedData,\n editType: 'unionGeometry',\n editContext: {\n featureIndexes: [featureIndex]\n }\n };\n\n return editAction;\n }\n return this.getAddFeatureAction(featureOrGeometry, props.data, featureProperties);\n }\n\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature | null {\n return null;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {}\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n const tentativeFeature = this.createTentativeFeature(props);\n if (tentativeFeature) {\n props.onEdit({\n updatedData: props.data,\n editType: 'updateTentativeFeature',\n editContext: {\n feature: tentativeFeature\n }\n });\n }\n }\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>): void {}\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>): void {}\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {}\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>): void {\n if (event.key === 'Escape') {\n this.resetClickSequence();\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n}\n\nexport function getIntermediatePosition(position1: Position, position2: Position): Position {\n const intermediatePosition: Position = [\n (position1[0] + position2[0]) / 2.0,\n (position1[1] + position2[1]) / 2.0\n ];\n\n return intermediatePosition;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable no-shadow */\n\nimport destination from '@turf/destination';\nimport bearing from '@turf/bearing';\nimport pointToLineDistance from '@turf/point-to-line-distance';\nimport {flattenEach} from '@turf/meta';\n// import type {MultiLineString} from '@turf/helpers';\nimport {point} from '@turf/helpers';\nimport {getCoords} from '@turf/invariant';\nimport {WebMercatorViewport} from 'viewport-mercator-project';\nimport {Viewport, Pick, EditHandleFeature, EditHandleType, StartDraggingEvent} from './types';\nimport {\n Geometry,\n Position,\n Point,\n LineString,\n Polygon,\n FeatureOf,\n FeatureWithProps,\n AnyCoordinates\n} from '../utils/geojson-types';\n\nexport type NearestPointType = FeatureWithProps<Point, {dist: number; index: number}>;\n\nexport function toDeckColor(\n color?: [number, number, number, number] | number,\n defaultColor: [number, number, number, number] = [255, 0, 0, 255]\n): [number, number, number, number] {\n if (!Array.isArray(color)) {\n return defaultColor;\n }\n return [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255];\n}\n\n//\n// a GeoJSON helper function that calls the provided function with\n// an argument that is the most deeply-nested array having elements\n// that are arrays of primitives as an argument, e.g.\n//\n// {\n// \"type\": \"MultiPolygon\",\n// \"coordinates\": [\n// [\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n// ],\n// [\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n// ]\n// ]\n// }\n//\n// the function would be called on:\n//\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n//\n// and\n//\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n//\nexport function recursivelyTraverseNestedArrays(\n array: Array<any>,\n prefix: Array<number>,\n fn: (array: Array<any>, prefix: number[]) => void\n) {\n if (!Array.isArray(array[0])) {\n return true;\n }\n for (let i = 0; i < array.length; i++) {\n if (recursivelyTraverseNestedArrays(array[i], [...prefix, i], fn)) {\n fn(array, prefix);\n break;\n }\n }\n return false;\n}\n\nexport function generatePointsParallelToLinePoints(\n p1: Position,\n p2: Position,\n coords: Position\n): Position[] {\n const lineString: LineString = {\n type: 'LineString',\n coordinates: [p1, p2]\n };\n const pt = point(coords);\n const ddistance = pointToLineDistance(pt, lineString);\n const lineBearing = bearing(p1, p2);\n\n // Check if current point is to the left or right of line\n // Line from A=(x1,y1) to B=(x2,y2) a point P=(x,y)\n // then (x\u2212x1)(y2\u2212y1)\u2212(y\u2212y1)(x2\u2212x1)\n const isPointToLeftOfLine =\n (coords[0] - p1[0]) * (p2[1] - p1[1]) - (coords[1] - p1[1]) * (p2[0] - p1[0]);\n\n // Bearing to draw perpendicular to the line string\n const orthogonalBearing = isPointToLeftOfLine < 0 ? lineBearing - 90 : lineBearing - 270;\n\n // Get coordinates for the point p3 and p4 which are perpendicular to the lineString\n // Add the distance as the current position moves away from the lineString\n const p3 = destination(p2, ddistance, orthogonalBearing);\n const p4 = destination(p1, ddistance, orthogonalBearing);\n\n return [p3.geometry.coordinates, p4.geometry.coordinates] as Position[];\n}\n\nexport function distance2d(x1: number, y1: number, x2: number, y2: number): number {\n const dx = x1 - x2;\n const dy = y1 - y2;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nexport function mix(a: number, b: number, ratio: number): number {\n return b * ratio + a * (1 - ratio);\n}\n\nexport function nearestPointOnProjectedLine(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport\n): NearestPointType {\n const wmViewport = new WebMercatorViewport(viewport);\n // Project the line to viewport, then find the nearest point\n const coordinates: Array<Array<number>> = line.geometry.coordinates as any;\n const projectedCoords = coordinates.map(([x, y, z = 0]) => wmViewport.project([x, y, z]));\n const [x, y] = wmViewport.project(inPoint.geometry.coordinates);\n // console.log('projectedCoords', JSON.stringify(projectedCoords));\n\n let minDistance = Infinity;\n let minPointInfo = {};\n\n projectedCoords.forEach(([x2, y2], index) => {\n if (index === 0) {\n return;\n }\n\n const [x1, y1] = projectedCoords[index - 1];\n\n // line from projectedCoords[index - 1] to projectedCoords[index]\n // convert to Ax + By + C = 0\n const A = y1 - y2;\n const B = x2 - x1;\n const C = x1 * y2 - x2 * y1;\n\n // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line\n const div = A * A + B * B;\n const distance = Math.abs(A * x + B * y + C) / Math.sqrt(div);\n\n // TODO: Check if inside bounds\n\n if (distance < minDistance) {\n minDistance = distance;\n minPointInfo = {\n index,\n x0: (B * (B * x - A * y) - A * C) / div,\n y0: (A * (-B * x + A * y) - B * C) / div\n };\n }\n });\n // @ts-expect-error TODO\n const {index, x0, y0} = minPointInfo;\n const [x1, y1, z1 = 0] = projectedCoords[index - 1];\n const [x2, y2, z2 = 0] = projectedCoords[index];\n\n // calculate what ratio of the line we are on to find the proper z\n const lineLength = distance2d(x1, y1, x2, y2);\n const startToPointLength = distance2d(x1, y1, x0, y0);\n const ratio = startToPointLength / lineLength;\n const z0 = mix(z1, z2, ratio);\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: wmViewport.unproject([x0, y0, z0])\n },\n properties: {\n // TODO: calculate the distance in proper units\n dist: minDistance,\n index: index - 1\n }\n };\n}\n\nexport function nearestPointOnLine( // <G extends LineString | MultiLineString>(\n lines: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport?: Viewport\n): NearestPointType {\n let mercator;\n\n if (viewport) {\n mercator = new WebMercatorViewport(viewport);\n }\n let closestPoint: any = point([Infinity, Infinity], {\n dist: Infinity\n });\n\n if (!lines.geometry?.coordinates.length || lines.geometry?.coordinates.length < 2) {\n return closestPoint;\n }\n\n // @ts-expect-error TODO\n // eslint-disable-next-line max-statements, complexity\n flattenEach(lines, (line: any) => {\n const coords: any = getCoords(line);\n // @ts-expect-error TODO\n const pointCoords: any = getCoords(inPoint);\n\n let minDist;\n let to;\n let from;\n let x;\n let y;\n let segmentIdx;\n let dist;\n\n if (coords.length > 1 && pointCoords.length) {\n let lineCoordinates;\n let pointCoordinate;\n\n // If viewport is given, then translate these coordinates to pixels to increase precision\n if (mercator) {\n lineCoordinates = coords.map((lineCoordinate) => mercator.project(lineCoordinate));\n pointCoordinate = mercator.project(pointCoords);\n } else {\n lineCoordinates = coords;\n pointCoordinate = pointCoords;\n }\n\n for (let n = 1; n < lineCoordinates.length; n++) {\n if (lineCoordinates[n][0] !== lineCoordinates[n - 1][0]) {\n const slope =\n (lineCoordinates[n][1] - lineCoordinates[n - 1][1]) /\n (lineCoordinates[n][0] - lineCoordinates[n - 1][0]);\n const inverseSlope = lineCoordinates[n][1] - slope * lineCoordinates[n][0];\n\n dist =\n Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) /\n Math.sqrt(slope * slope + 1);\n } else dist = Math.abs(pointCoordinate[0] - lineCoordinates[n][0]);\n\n // length^2 of line segment\n const rl2 =\n Math.pow(lineCoordinates[n][1] - lineCoordinates[n - 1][1], 2) +\n Math.pow(lineCoordinates[n][0] - lineCoordinates[n - 1][0], 2);\n\n // distance^2 of pt to end line segment\n const ln2 =\n Math.pow(lineCoordinates[n][1] - pointCoordinate[1], 2) +\n Math.pow(lineCoordinates[n][0] - pointCoordinate[0], 2);\n\n // distance^2 of pt to begin line segment\n const lnm12 =\n Math.pow(lineCoordinates[n - 1][1] - pointCoordinate[1], 2) +\n Math.pow(lineCoordinates[n - 1][0] - pointCoordinate[0], 2);\n\n // minimum distance^2 of pt to infinite line\n const dist2 = Math.pow(dist, 2);\n\n // calculated length^2 of line segment\n const calcrl2 = ln2 - dist2 + lnm12 - dist2;\n\n // redefine minimum distance to line segment (not infinite line) if necessary\n if (calcrl2 > rl2) {\n dist = Math.sqrt(Math.min(ln2, lnm12));\n }\n\n if (minDist === null || minDist === undefined || minDist > dist) {\n // eslint-disable-next-line max-depth\n if (calcrl2 > rl2) {\n // eslint-disable-next-line max-depth\n if (lnm12 < ln2) {\n to = 0; // nearer to previous point\n from = 1;\n } else {\n from = 0; // nearer to current point\n to = 1;\n }\n } else {\n // perpendicular from point intersects line segment\n to = Math.sqrt(lnm12 - dist2) / Math.sqrt(rl2);\n from = Math.sqrt(ln2 - dist2) / Math.sqrt(rl2);\n }\n minDist = dist;\n segmentIdx = n;\n }\n }\n\n const dx = lineCoordinates[segmentIdx - 1][0] - lineCoordinates[segmentIdx][0];\n const dy = lineCoordinates[segmentIdx - 1][1] - lineCoordinates[segmentIdx][1];\n\n x = lineCoordinates[segmentIdx - 1][0] - dx * to;\n y = lineCoordinates[segmentIdx - 1][1] - dy * to;\n }\n\n // index needs to be -1 because we have to account for the shift from initial backscan\n let snapPoint = {x, y, idx: segmentIdx - 1, to, from};\n\n if (mercator) {\n const pixelToLatLong = mercator.unproject([snapPoint.x, snapPoint.y]);\n snapPoint = {\n x: pixelToLatLong[0],\n y: pixelToLatLong[1],\n idx: segmentIdx - 1,\n to,\n from\n };\n }\n\n closestPoint = point([snapPoint.x, snapPoint.y], {\n dist: Math.abs(snapPoint.from - snapPoint.to),\n index: snapPoint.idx\n });\n });\n\n return closestPoint;\n}\n\nexport function getPickedEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.length ? handles[0] : null;\n}\n\nexport function getPickedSnapSourceEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.find((handle) => handle.properties.editHandleType === 'snap-source');\n}\n\nexport function getNonGuidePicks(picks: Pick[]): Pick[] {\n return picks && picks.filter((pick) => !pick.isGuide);\n}\n\nexport function getPickedExistingEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.find(\n ({properties}) => properties.featureIndex >= 0 && properties.editHandleType === 'existing'\n );\n}\n\nexport function getPickedIntermediateEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.find(\n ({properties}) => properties.featureIndex >= 0 && properties.editHandleType === 'intermediate'\n );\n}\n\nexport function getPickedEditHandles(picks: Pick[] | null | undefined): EditHandleFeature[] {\n const handles =\n (picks &&\n picks\n .filter((pick) => pick.isGuide && pick.object.properties.guideType === 'editHandle')\n .map((pick) => pick.object)) ||\n [];\n\n return handles;\n}\n\nexport function getEditHandlesForGeometry(\n geometry: Geometry,\n featureIndex: number,\n editHandleType: EditHandleType = 'existing'\n): EditHandleFeature[] {\n let handles: EditHandleFeature[] = [];\n\n switch (geometry.type) {\n case 'Point':\n // positions are not nested\n handles = [\n {\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType,\n positionIndexes: [],\n featureIndex\n },\n geometry: {\n type: 'Point',\n coordinates: geometry.coordinates\n }\n }\n ];\n break;\n case 'MultiPoint':\n case 'LineString':\n // positions are nested 1 level\n handles = handles.concat(\n getEditHandlesForCoordinates(geometry.coordinates, [], featureIndex, editHandleType)\n );\n break;\n case 'Polygon':\n case 'MultiLineString':\n // positions are nested 2 levels\n for (let a = 0; a < geometry.coordinates.length; a++) {\n handles = handles.concat(\n getEditHandlesForCoordinates(geometry.coordinates[a], [a], featureIndex, editHandleType)\n );\n if (geometry.type === 'Polygon') {\n // Don't repeat the first/last handle for Polygons\n handles = handles.slice(0, -1);\n }\n }\n\n break;\n case 'MultiPolygon':\n // positions are nested 3 levels\n for (let a = 0; a < geometry.coordinates.length; a++) {\n for (let b = 0; b < geometry.coordinates[a].length; b++) {\n handles = handles.concat(\n getEditHandlesForCoordinates(\n geometry.coordinates[a][b],\n [a, b],\n featureIndex,\n editHandleType\n )\n );\n // Don't repeat the first/last handle for Polygons\n handles = handles.slice(0, -1);\n }\n }\n\n break;\n default:\n throw Error(`Unhandled geometry type: ${(geometry as {type: string}).type}`);\n }\n\n return handles;\n}\n\nfunction getEditHandlesForCoordinates(\n coordinates: any[],\n positionIndexPrefix: number[],\n featureIndex: number,\n editHandleType: EditHandleType = 'existing'\n): EditHandleFeature[] {\n const editHandles: EditHandleFeature[] = [];\n for (let i = 0; i < coordinates.length; i++) {\n const position = coordinates[i] as Position;\n editHandles.push({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n positionIndexes: [...positionIndexPrefix, i],\n featureIndex,\n editHandleType\n },\n geometry: {\n type: 'Point',\n coordinates: position\n }\n });\n }\n return editHandles;\n}\n\n/**\n * Calculates coordinates for a feature preserving rectangular shape.\n * @param feature Feature before modification.\n * @param editHandleIndex Index of the point to modify.\n * @param coords New position for the point.\n * @returns Updated coordinates.\n */\nexport function updateRectanglePosition(\n feature: FeatureOf<Polygon>,\n editHandleIndex: number,\n coords: Position\n): Position[][] | null {\n const coordinates = feature.geometry.coordinates;\n if (!coordinates) {\n return null;\n }\n\n const points = coordinates[0].slice(0, 4);\n points[editHandleIndex % 4] = coords;\n\n const p0 = points[(editHandleIndex + 2) % 4];\n const p2 = points[editHandleIndex % 4];\n points[(editHandleIndex + 1) % 4] = [p2[0], p0[1]];\n points[(editHandleIndex + 3) % 4] = [p0[0], p2[1]];\n\n return [[...points, points[0]]];\n}\n\n/** Creates a copy of feature's coordinates.\n * Each position in coordinates is transformed by calling the provided function.\n * @param coords Coordinates of a feature.\n * @param callback A function to transform each coordinate.\n * @retuns Transformed coordinates.\n */\nexport function mapCoords(\n coords: AnyCoordinates,\n callback: (coords: Position) => Position\n): AnyCoordinates {\n if (typeof coords[0] === 'number') {\n if (!isNaN(coords[0]) && isFinite(coords[0])) {\n return callback(coords as Position);\n }\n return coords;\n }\n\n return (coords as Position[])\n .map((coord) => {\n return mapCoords(coord, callback) as Position;\n })\n .filter(Boolean);\n}\n\nexport function shouldCancelPan(event: StartDraggingEvent) {\n return event.picks.length && event.picks.find((p) => p.featureType === 'points');\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n Feature,\n FeatureCollection,\n Geometry,\n Polygon,\n MultiLineString,\n MultiPolygon,\n Position,\n PolygonCoordinates\n} from '../utils/geojson-types';\n\nexport class ImmutableFeatureCollection {\n featureCollection: FeatureCollection;\n\n constructor(featureCollection: FeatureCollection) {\n this.featureCollection = featureCollection;\n }\n\n getObject() {\n return this.featureCollection;\n }\n\n /**\n * Replaces the position deeply nested withing the given feature's geometry.\n * Works with Point, MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon.\n *\n * @param featureIndex The index of the feature to update\n * @param positionIndexes An array containing the indexes of the position to replace\n * @param updatedPosition The updated position to place in the result (i.e. [lng, lat])\n *\n * @returns A new `ImmutableFeatureCollection` with the given position replaced. Does not modify this `ImmutableFeatureCollection`.\n */\n replacePosition(\n featureIndex: number,\n positionIndexes: number[] | null | undefined,\n updatedPosition: Position\n ): ImmutableFeatureCollection {\n const geometry = this.featureCollection.features[featureIndex].geometry;\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n const updatedGeometry: any = {\n ...geometry,\n coordinates: immutablyReplacePosition(\n geometry.coordinates,\n positionIndexes,\n updatedPosition,\n isPolygonal\n )\n };\n\n return this.replaceGeometry(featureIndex, updatedGeometry);\n }\n\n /**\n * Removes a position deeply nested in a GeoJSON geometry coordinates array.\n * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon.\n *\n * @param featureIndex The index of the feature to update\n * @param positionIndexes An array containing the indexes of the postion to remove\n *\n * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`.\n *\n */\n // eslint-disable-next-line complexity\n removePosition(\n featureIndex: number,\n positionIndexes: number[] | null | undefined\n ): ImmutableFeatureCollection {\n const geometry = this.featureCollection.features[featureIndex].geometry;\n\n if (geometry.type === 'Point') {\n throw Error(\"Can't remove a position from a Point or there'd be nothing left\");\n }\n if (\n geometry.type === 'MultiPoint' && // only 1 point left\n geometry.coordinates.length < 2\n ) {\n throw Error(\"Can't remove the last point of a MultiPoint or there'd be nothing left\");\n }\n if (\n geometry.type === 'LineString' && // only 2 positions\n geometry.coordinates.length < 3\n ) {\n throw Error(\"Can't remove position. LineString must have at least two positions\");\n }\n if (\n geometry.type === 'Polygon' && // outer ring is a triangle\n geometry.coordinates[0].length < 5 &&\n Array.isArray(positionIndexes) && // trying to remove from outer ring\n positionIndexes[0] === 0\n ) {\n throw Error(\"Can't remove position. Polygon's outer ring must have at least four positions\");\n }\n if (\n geometry.type === 'MultiLineString' && // only 1 LineString left\n geometry.coordinates.length === 1 && // only 2 positions\n geometry.coordinates[0].length < 3\n ) {\n throw Error(\"Can't remove position. MultiLineString must have at least two positions\");\n }\n if (\n geometry.type === 'MultiPolygon' && // only 1 polygon left\n geometry.coordinates.length === 1 && // outer ring is a triangle\n geometry.coordinates[0][0].length < 5 &&\n Array.isArray(positionIndexes) && // trying to remove from first polygon\n positionIndexes[0] === 0 && // trying to remove from outer ring\n positionIndexes[1] === 0\n ) {\n throw Error(\n \"Can't remove position. MultiPolygon's outer ring must have at least four positions\"\n );\n }\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n const updatedGeometry: any = {\n ...geometry,\n coordinates: immutablyRemovePosition(geometry.coordinates, positionIndexes, isPolygonal)\n };\n\n // Handle cases where incomplete geometries need pruned (e.g. holes that were triangles)\n pruneGeometryIfNecessary(updatedGeometry);\n\n return this.replaceGeometry(featureIndex, updatedGeometry);\n }\n\n /**\n * Adds a position deeply nested in a GeoJSON geometry coordinates array.\n * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon.\n *\n * @param featureIndex The index of the feature to update\n * @param positionIndexes An array containing the indexes of the position that will proceed the new position\n * @param positionToAdd The new position to place in the result (i.e. [lng, lat])\n *\n * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`.\n */\n addPosition(\n featureIndex: number,\n positionIndexes: number[] | null | undefined,\n positionToAdd: Position\n ): ImmutableFeatureCollection {\n const geometry = this.featureCollection.features[featureIndex].geometry;\n\n if (geometry.type === 'Point') {\n throw new Error('Unable to add a position to a Point feature');\n }\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n const updatedGeometry: any = {\n ...geometry,\n coordinates: immutablyAddPosition(\n geometry.coordinates,\n positionIndexes,\n positionToAdd,\n isPolygonal\n )\n };\n\n return this.replaceGeometry(featureIndex, updatedGeometry);\n }\n\n replaceGeometry(featureIndex: number, geometry: Geometry): ImmutableFeatureCollection {\n const updatedFeature: any = {\n ...this.featureCollection.features[featureIndex],\n geometry\n };\n\n const updatedFeatureCollection = {\n ...this.featureCollection,\n features: [\n ...this.featureCollection.features.slice(0, featureIndex),\n updatedFeature,\n ...this.featureCollection.features.slice(featureIndex + 1)\n ]\n };\n\n return new ImmutableFeatureCollection(updatedFeatureCollection);\n }\n\n addFeature(feature: Feature): ImmutableFeatureCollection {\n return this.addFeatures([feature]);\n }\n\n addFeatures(features: Feature[]): ImmutableFeatureCollection {\n const updatedFeatureCollection = {\n ...this.featureCollection,\n features: [...this.featureCollection.features, ...features]\n };\n\n return new ImmutableFeatureCollection(updatedFeatureCollection);\n }\n\n deleteFeature(featureIndex: number) {\n return this.deleteFeatures([featureIndex]);\n }\n\n deleteFeatures(featureIndexes: number[]) {\n const features = [...this.featureCollection.features];\n featureIndexes.sort();\n for (let i = featureIndexes.length - 1; i >= 0; i--) {\n const featureIndex = featureIndexes[i];\n if (featureIndex >= 0 && featureIndex < features.length) {\n features.splice(featureIndex, 1);\n }\n }\n\n const updatedFeatureCollection = {\n ...this.featureCollection,\n features\n };\n\n return new ImmutableFeatureCollection(updatedFeatureCollection);\n }\n}\n\nfunction getUpdatedPosition(updatedPosition: Position, previousPosition: Position): Position {\n // This function checks if the updatedPosition is missing elevation\n // and copies it from previousPosition\n if (updatedPosition.length === 2 && previousPosition.length === 3) {\n const elevation = (previousPosition as any)[2];\n return [updatedPosition[0], updatedPosition[1], elevation];\n }\n\n return updatedPosition;\n}\n\nfunction immutablyReplacePosition(\n coordinates: any,\n positionIndexes: number[] | null | undefined,\n updatedPosition: Position,\n isPolygonal: boolean\n): any {\n if (!positionIndexes) {\n return coordinates;\n }\n if (positionIndexes.length === 0) {\n return getUpdatedPosition(updatedPosition, coordinates);\n }\n if (positionIndexes.length === 1) {\n const updated = [\n ...coordinates.slice(0, positionIndexes[0]),\n getUpdatedPosition(updatedPosition, coordinates[positionIndexes[0]]),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n\n if (\n isPolygonal &&\n (positionIndexes[0] === 0 || positionIndexes[0] === coordinates.length - 1)\n ) {\n // for polygons, the first point is repeated at the end of the array\n // so, update it on both ends of the array\n updated[0] = getUpdatedPosition(updatedPosition, coordinates[0]);\n updated[coordinates.length - 1] = getUpdatedPosition(updatedPosition, coordinates[0]);\n }\n return updated;\n }\n\n // recursively update inner array\n return [\n ...coordinates.slice(0, positionIndexes[0]),\n immutablyReplacePosition(\n coordinates[positionIndexes[0]],\n positionIndexes.slice(1, positionIndexes.length),\n updatedPosition,\n isPolygonal\n ),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n}\n\nfunction immutablyRemovePosition(\n coordinates: any,\n positionIndexes: number[] | null | undefined,\n isPolygonal: boolean\n): any {\n if (!positionIndexes) {\n return coordinates;\n }\n if (positionIndexes.length === 0) {\n throw Error('Must specify the index of the position to remove');\n }\n if (positionIndexes.length === 1) {\n const updated = [\n ...coordinates.slice(0, positionIndexes[0]),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n\n if (\n isPolygonal &&\n (positionIndexes[0] === 0 || positionIndexes[0] === coordinates.length - 1)\n ) {\n // for polygons, the first point is repeated at the end of the array\n // so, if the first/last coordinate is to be removed, coordinates[1] will be the new first/last coordinate\n if (positionIndexes[0] === 0) {\n // change the last to be the same as the first\n updated[updated.length - 1] = updated[0];\n } else if (positionIndexes[0] === coordinates.length - 1) {\n // change the first to be the same as the last\n updated[0] = updated[updated.length - 1];\n }\n }\n return updated;\n }\n\n // recursively update inner array\n return [\n ...coordinates.slice(0, positionIndexes[0]),\n immutablyRemovePosition(\n coordinates[positionIndexes[0]],\n positionIndexes.slice(1, positionIndexes.length),\n isPolygonal\n ),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n}\n\nfunction immutablyAddPosition(\n coordinates: any,\n positionIndexes: number[] | null | undefined,\n positionToAdd: Position,\n isPolygonal: boolean\n): any {\n if (!positionIndexes) {\n return coordinates;\n }\n if (positionIndexes.length === 0) {\n throw Error('Must specify the index of the position to remove');\n }\n if (positionIndexes.length === 1) {\n const updated = [\n ...coordinates.slice(0, positionIndexes[0]),\n positionToAdd,\n ...coordinates.slice(positionIndexes[0])\n ];\n return updated;\n }\n\n // recursively update inner array\n return [\n ...coordinates.slice(0, positionIndexes[0]),\n immutablyAddPosition(\n coordinates[positionIndexes[0]],\n positionIndexes.slice(1, positionIndexes.length),\n positionToAdd,\n isPolygonal\n ),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n}\n\nfunction pruneGeometryIfNecessary(geometry: Geometry) {\n switch (geometry.type) {\n case 'Polygon':\n prunePolygonIfNecessary(geometry);\n break;\n case 'MultiLineString':\n pruneMultiLineStringIfNecessary(geometry);\n break;\n case 'MultiPolygon':\n pruneMultiPolygonIfNecessary(geometry);\n break;\n default:\n // Not downgradable\n break;\n }\n}\n\nfunction prunePolygonIfNecessary(geometry: Polygon) {\n const polygon = geometry.coordinates;\n\n // If any hole is no longer a polygon, remove the hole entirely\n for (let holeIndex = 1; holeIndex < polygon.length; holeIndex++) {\n if (removeHoleIfNecessary(polygon, holeIndex)) {\n // It was removed, so keep the index the same\n holeIndex--;\n }\n }\n}\n\nfunction pruneMultiLineStringIfNecessary(geometry: MultiLineString) {\n for (let lineStringIndex = 0; lineStringIndex < geometry.coordinates.length; lineStringIndex++) {\n const lineString = geometry.coordinates[lineStringIndex];\n if (lineString.length === 1) {\n // Only a single position left on this LineString, so remove it (can't have Point in MultiLineString)\n geometry.coordinates.splice(lineStringIndex, 1);\n // Keep the index the same\n lineStringIndex--;\n }\n }\n}\n\nfunction pruneMultiPolygonIfNecessary(geometry: MultiPolygon) {\n for (let polygonIndex = 0; polygonIndex < geometry.coordinates.length; polygonIndex++) {\n const polygon = geometry.coordinates[polygonIndex];\n const outerRing = polygon[0];\n\n // If the outer ring is no longer a polygon, remove the whole polygon\n if (outerRing.length <= 3) {\n geometry.coordinates.splice(polygonIndex, 1);\n // It was removed, so keep the index the same\n polygonIndex--;\n }\n\n for (let holeIndex = 1; holeIndex < polygon.length; holeIndex++) {\n if (removeHoleIfNecessary(polygon, holeIndex)) {\n // It was removed, so keep the index the same\n holeIndex--;\n }\n }\n }\n}\n\nfunction removeHoleIfNecessary(polygon: PolygonCoordinates, holeIndex: number) {\n const hole = polygon[holeIndex];\n if (hole.length <= 3) {\n polygon.splice(holeIndex, 1);\n return true;\n }\n return false;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class ViewMode extends GeoJsonEditMode {}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfBearing from '@turf/bearing';\nimport turfDistance from '@turf/distance';\nimport clone from '@turf/clone';\nimport type {Feature as TurfFeature, Geometry as TurfGeometry} from '@turf/helpers';\nimport {point} from '@turf/helpers';\nimport {WebMercatorViewport} from 'viewport-mercator-project';\nimport {FeatureCollection, Position, Geometry} from '../utils/geojson-types';\nimport {\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps\n} from './types';\nimport {mapCoords} from './utils';\nimport {translateFromCenter} from '../utils/translate-from-center';\nimport {GeoJsonEditMode, GeoJsonEditAction} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class TranslateMode extends GeoJsonEditMode {\n _geometryBeforeTranslate: FeatureCollection | null | undefined;\n _isTranslatable: boolean = undefined!;\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isTranslatable) {\n // Nothing to do\n return;\n }\n\n if (this._geometryBeforeTranslate) {\n // Translate the geometry\n const editAction = this.getTranslateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'translating',\n props\n );\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n\n // cancel map panning\n event.cancelPan();\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n this._isTranslatable = this.isSelectionPicked(event.pointerDownPicks || event.picks, props);\n\n this.updateCursor(props);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isTranslatable) {\n return;\n }\n\n event.cancelPan();\n this._geometryBeforeTranslate = this.getSelectedFeaturesAsFeatureCollection(props);\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._geometryBeforeTranslate) {\n // Translate the geometry\n const editAction = this.getTranslateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'translated',\n props\n );\n\n if (editAction) {\n props.onEdit(editAction);\n }\n\n this._geometryBeforeTranslate = null;\n }\n }\n\n updateCursor(props: ModeProps<FeatureCollection>) {\n if (this._isTranslatable) {\n props.onUpdateCursor('move');\n } else {\n props.onUpdateCursor(null);\n }\n }\n\n // eslint-disable-next-line max-statements\n getTranslateAction(\n startDragPoint: Position,\n currentPoint: Position,\n editType: string,\n props: ModeProps<FeatureCollection>\n ): GeoJsonEditAction | null | undefined {\n if (!this._geometryBeforeTranslate) {\n return null;\n }\n\n let updatedData = new ImmutableFeatureCollection(props.data);\n const selectedIndexes = props.selectedIndexes;\n\n const {viewport: viewportDesc, screenSpace} = props.modeConfig || {};\n\n // move features without adapting to mercator projection\n if (viewportDesc && screenSpace) {\n const viewport = viewportDesc.project ? viewportDesc : new WebMercatorViewport(viewportDesc);\n\n const from = viewport.project(startDragPoint);\n const to = viewport.project(currentPoint);\n const dx = to[0] - from[0];\n const dy = to[1] - from[1];\n\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const feature = this._geometryBeforeTranslate.features[i];\n\n let coordinates = feature.geometry.coordinates;\n if (coordinates) {\n coordinates = mapCoords(coordinates, (coord) => {\n const pixels = viewport.project(coord);\n if (pixels) {\n pixels[0] += dx;\n pixels[1] += dy;\n return viewport.unproject(pixels);\n }\n return null;\n });\n\n // @ts-expect-error turf types\n updatedData = updatedData.replaceGeometry(selectedIndex, {\n type: feature.geometry.type,\n coordinates\n });\n }\n }\n } else {\n const p1 = point(startDragPoint);\n const p2 = point(currentPoint);\n\n const distanceMoved = turfDistance(p1, p2);\n const direction = turfBearing(p1, p2);\n\n const movedFeatures = this._geometryBeforeTranslate.features.map((feature) =>\n translateFromCenter(clone(feature as TurfFeature<TurfGeometry>), distanceMoved, direction)\n );\n\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const movedFeature = movedFeatures[i];\n updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry as Geometry);\n }\n }\n\n return {\n updatedData: updatedData.getObject(),\n editType,\n editContext: {\n featureIndexes: selectedIndexes\n }\n };\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfCenter from '@turf/center';\nimport turfRhumbBearing from '@turf/rhumb-bearing';\nimport turfRhumbDistance from '@turf/rhumb-distance';\nimport turfRhumbDestination from '@turf/rhumb-destination';\nimport type {\n Position as TurfPosition,\n Feature as TurfFeature,\n Geometry as TurfGeometry\n} from '@turf/helpers';\nimport {mapCoords} from '../edit-modes/utils';\nimport type {AnyCoordinates /* , Position */} from './geojson-types';\n\n// This function takes feature's center, moves it,\n// and builds new feature around it keeping the proportions\nexport function translateFromCenter(\n feature: TurfFeature<TurfGeometry>,\n distance: number,\n direction: number\n) {\n const initialCenterPoint = turfCenter(feature as TurfFeature);\n\n const movedCenterPoint = turfRhumbDestination(initialCenterPoint, distance, direction);\n\n const movedCoordinates = mapCoords(\n feature.geometry.coordinates as AnyCoordinates,\n (coordinate) => {\n const rhumbDistance = turfRhumbDistance(\n initialCenterPoint.geometry.coordinates,\n coordinate as TurfPosition\n );\n const rhumbDirection = turfRhumbBearing(\n initialCenterPoint.geometry.coordinates,\n coordinate as TurfPosition\n );\n\n const movedPosition = turfRhumbDestination(\n movedCenterPoint.geometry.coordinates,\n rhumbDistance,\n rhumbDirection\n ).geometry.coordinates;\n return movedPosition;\n }\n );\n\n feature.geometry.coordinates = movedCoordinates;\n\n return feature;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {point, lineString as toLineString} from '@turf/helpers';\nimport {\n recursivelyTraverseNestedArrays,\n nearestPointOnProjectedLine,\n nearestPointOnLine,\n getEditHandlesForGeometry,\n getPickedEditHandles,\n getPickedEditHandle,\n getPickedExistingEditHandle,\n getPickedIntermediateEditHandle,\n updateRectanglePosition,\n NearestPointType,\n shouldCancelPan\n} from './utils';\nimport {LineString, Point, Polygon, FeatureCollection, FeatureOf} from '../utils/geojson-types';\nimport {\n ModeProps,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n Viewport,\n GuideFeatureCollection,\n EditHandleFeature,\n GuideFeature\n} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ModifyMode extends GeoJsonEditMode {\n // eslint-disable-next-line complexity\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const handles: GuideFeature[] = [];\n\n const {data, lastPointerMoveEvent} = props;\n const {features} = data;\n const picks = lastPointerMoveEvent && lastPointerMoveEvent.picks;\n const mapCoords = lastPointerMoveEvent && lastPointerMoveEvent.mapCoords;\n\n for (const index of props.selectedIndexes) {\n if (index < features.length) {\n const {geometry} = features[index];\n handles.push(...getEditHandlesForGeometry(geometry, index));\n } else {\n console.warn(`selectedFeatureIndexes out of range ${index}`); // eslint-disable-line no-console,no-undef\n }\n }\n\n // intermediate edit handle\n if (picks && picks.length && mapCoords) {\n const existingEditHandle = getPickedExistingEditHandle(picks);\n // don't show intermediate point when too close to an existing edit handle\n const featureAsPick = !existingEditHandle && picks.find((pick) => !pick.isGuide);\n\n // is the feature in the pick selected\n if (\n featureAsPick &&\n !featureAsPick.object.geometry.type.includes('Point') &&\n !(\n props.modeConfig?.lockRectangles && featureAsPick.object.properties.shape === 'Rectangle'\n ) &&\n props.selectedIndexes.includes(featureAsPick.index)\n ) {\n let intermediatePoint: NearestPointType | null | undefined = null;\n let positionIndexPrefix: number[] = [];\n const referencePoint = point(mapCoords);\n // process all lines of the (single) feature\n recursivelyTraverseNestedArrays(\n featureAsPick.object.geometry.coordinates,\n [],\n (lineString, prefix) => {\n const lineStringFeature = toLineString(lineString);\n const candidateIntermediatePoint = this.getNearestPoint(\n // @ts-expect-error turf types too wide\n lineStringFeature,\n referencePoint,\n props.modeConfig && props.modeConfig.viewport\n );\n if (\n !intermediatePoint ||\n candidateIntermediatePoint.properties.dist < intermediatePoint.properties.dist\n ) {\n intermediatePoint = candidateIntermediatePoint;\n positionIndexPrefix = prefix;\n }\n }\n );\n // tack on the lone intermediate point to the set of handles\n if (intermediatePoint) {\n const {\n geometry: {coordinates: position},\n properties: {index}\n } = intermediatePoint;\n handles.push({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'intermediate',\n featureIndex: featureAsPick.index,\n positionIndexes: [...positionIndexPrefix, index + 1]\n },\n geometry: {\n type: 'Point',\n coordinates: position\n }\n });\n }\n }\n }\n\n return {\n type: 'FeatureCollection',\n features: handles\n };\n }\n\n // turf.js does not support elevation for nearestPointOnLine\n getNearestPoint(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport | null | undefined\n ): NearestPointType {\n const {coordinates} = line.geometry;\n if (coordinates.some((coord) => coord.length > 2)) {\n if (viewport) {\n // This line has elevation, we need to use alternative algorithm\n return nearestPointOnProjectedLine(line, inPoint, viewport);\n }\n // eslint-disable-next-line no-console,no-undef\n console.log(\n 'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'\n );\n }\n return nearestPointOnLine(line, inPoint, viewport);\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const pickedExistingHandle = getPickedExistingEditHandle(event.picks);\n const pickedIntermediateHandle = getPickedIntermediateEditHandle(event.picks);\n\n if (pickedExistingHandle) {\n const {featureIndex, positionIndexes} = pickedExistingHandle.properties;\n\n let updatedData;\n try {\n updatedData = new ImmutableFeatureCollection(props.data)\n .removePosition(featureIndex, positionIndexes)\n .getObject();\n } catch (ignored) {\n // This happens if user attempts to remove the last point\n }\n\n if (updatedData) {\n props.onEdit({\n updatedData,\n editType: 'removePosition',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: pickedExistingHandle.geometry.coordinates\n }\n });\n }\n } else if (pickedIntermediateHandle) {\n const {featureIndex, positionIndexes} = pickedIntermediateHandle.properties;\n\n const feature = props.data.features[featureIndex];\n const canAddPosition = !(\n props.modeConfig?.lockRectangles && feature?.properties.shape === 'Rectangle'\n );\n\n if (canAddPosition) {\n const updatedData = new ImmutableFeatureCollection(props.data)\n .addPosition(featureIndex, positionIndexes, pickedIntermediateHandle.geometry.coordinates)\n .getObject();\n\n if (updatedData) {\n props.onEdit({\n updatedData,\n editType: 'addPosition',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: pickedIntermediateHandle.geometry.coordinates\n }\n });\n }\n }\n }\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n\n if (editHandle) {\n // Cancel map panning if pointer went down on an edit handle\n event.cancelPan();\n\n this._dragEditHandle('movePosition', props, editHandle, event);\n }\n }\n\n _dragEditHandle(\n editType: string,\n props: ModeProps<FeatureCollection>,\n editHandle: EditHandleFeature,\n event: StopDraggingEvent | DraggingEvent\n ) {\n const editHandleProperties = editHandle.properties;\n const editedFeature = props.data.features[editHandleProperties.featureIndex];\n\n let updatedData;\n if (props.modeConfig?.lockRectangles && editedFeature.properties.shape === 'Rectangle') {\n const coordinates = updateRectanglePosition(\n editedFeature as FeatureOf<Polygon>,\n editHandleProperties.positionIndexes[1],\n event.mapCoords\n ) as any; // TODO\n\n updatedData = new ImmutableFeatureCollection(props.data)\n .replaceGeometry(editHandleProperties.featureIndex, {coordinates, type: 'Polygon'})\n .getObject();\n } else {\n updatedData = new ImmutableFeatureCollection(props.data)\n .replacePosition(\n editHandleProperties.featureIndex,\n editHandleProperties.positionIndexes,\n event.mapCoords\n )\n .getObject();\n }\n\n props.onEdit({\n updatedData,\n editType,\n editContext: {\n featureIndexes: [editHandleProperties.featureIndex],\n positionIndexes: editHandleProperties.positionIndexes,\n position: event.mapCoords\n }\n });\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n const cursor = this.getCursor(event);\n props.onUpdateCursor(cursor);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (shouldCancelPan(event)) {\n event.cancelPan();\n }\n\n const selectedFeatureIndexes = props.selectedIndexes;\n\n const editHandle = getPickedIntermediateEditHandle(event.picks);\n if (selectedFeatureIndexes.length && editHandle) {\n const editHandleProperties = editHandle.properties;\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .addPosition(\n editHandleProperties.featureIndex,\n editHandleProperties.positionIndexes,\n event.mapCoords\n )\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'addPosition',\n editContext: {\n featureIndexes: [editHandleProperties.featureIndex],\n positionIndexes: editHandleProperties.positionIndexes,\n position: event.mapCoords\n }\n });\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n const selectedFeatureIndexes = props.selectedIndexes;\n const editHandle = getPickedEditHandle(event.picks);\n if (selectedFeatureIndexes.length && editHandle) {\n this._dragEditHandle('finishMovePosition', props, editHandle, event);\n }\n }\n\n getCursor(event: PointerMoveEvent): string | null | undefined {\n const picks = (event && event.picks) || [];\n\n const handlesPicked = getPickedEditHandles(picks);\n if (handlesPicked.length) {\n return 'cell';\n }\n return null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bbox from '@turf/bbox';\nimport turfCentroid from '@turf/centroid';\nimport turfBearing from '@turf/bearing';\nimport bboxPolygon from '@turf/bbox-polygon';\nimport {point, featureCollection} from '@turf/helpers';\nimport {polygonToLine} from '@turf/polygon-to-line';\nimport {coordEach} from '@turf/meta';\nimport turfDistance from '@turf/distance';\nimport turfTransformScale from '@turf/transform-scale';\nimport {getCoord, getGeom} from '@turf/invariant';\nimport {FeatureCollection, Position} from '../utils/geojson-types';\nimport {\n ModeProps,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n EditHandleFeature,\n GuideFeatureCollection\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ScaleMode extends GeoJsonEditMode {\n _geometryBeingScaled: FeatureCollection | null | undefined;\n _selectedEditHandle: EditHandleFeature | null | undefined;\n _cornerGuidePoints: Array<EditHandleFeature> = [];\n _cursor: string | null | undefined;\n _isScaling = false;\n\n _isSinglePointGeometrySelected = (geometry: FeatureCollection | null | undefined): boolean => {\n const {features} = geometry || {};\n if (Array.isArray(features) && features.length === 1) {\n // @ts-expect-error turf types diff\n const {type}: {type: string} = getGeom(features[0]);\n return type === 'Point';\n }\n return false;\n };\n\n _getOppositeScaleHandle = (selectedHandle: EditHandleFeature): EditHandleFeature | null => {\n const selectedHandleIndex =\n selectedHandle &&\n selectedHandle.properties &&\n Array.isArray(selectedHandle.properties.positionIndexes) &&\n selectedHandle.properties.positionIndexes[0];\n\n if (typeof selectedHandleIndex !== 'number') {\n return null;\n }\n const guidePointCount = this._cornerGuidePoints.length;\n const oppositeIndex = (selectedHandleIndex + guidePointCount / 2) % guidePointCount;\n return (\n this._cornerGuidePoints.find((p) => {\n if (!Array.isArray(p.properties.positionIndexes)) {\n return false;\n }\n return p.properties.positionIndexes[0] === oppositeIndex;\n }) || null\n );\n };\n\n _getUpdatedData = (props: ModeProps<FeatureCollection>, editedData: FeatureCollection) => {\n let updatedData = new ImmutableFeatureCollection(props.data);\n const selectedIndexes = props.selectedIndexes;\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const movedFeature = editedData.features[i];\n updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry);\n }\n return updatedData.getObject();\n };\n\n isEditHandleSelected = (): boolean => Boolean(this._selectedEditHandle);\n\n getScaleAction = (\n startDragPoint: Position,\n currentPoint: Position,\n editType: string,\n props: ModeProps<FeatureCollection>\n ) => {\n if (!this._selectedEditHandle) {\n return null;\n }\n\n const oppositeHandle = this._getOppositeScaleHandle(this._selectedEditHandle);\n const origin = getCoord(oppositeHandle) as Position;\n\n const scaleFactor = getScaleFactor(origin, startDragPoint, currentPoint);\n\n // @ts-expect-error turf types diff\n const scaledFeatures: FeatureCollection = turfTransformScale(\n // @ts-expect-error turf types diff\n this._geometryBeingScaled,\n scaleFactor,\n {origin}\n );\n\n return {\n updatedData: this._getUpdatedData(props, scaledFeatures),\n editType,\n editContext: {\n featureIndexes: props.selectedIndexes\n }\n };\n };\n\n updateCursor = (props: ModeProps<FeatureCollection>) => {\n if (this._selectedEditHandle) {\n if (this._cursor) {\n props.onUpdateCursor(this._cursor);\n }\n const cursorGeometry = this.getSelectedFeaturesAsFeatureCollection(props);\n\n // Get resize cursor direction from the hovered scale editHandle (e.g. nesw or nwse)\n // @ts-expect-error turf types diff\n const centroid = turfCentroid(cursorGeometry);\n const bearing = turfBearing(centroid, this._selectedEditHandle);\n const positiveBearing = bearing < 0 ? bearing + 180 : bearing;\n if (\n (positiveBearing >= 0 && positiveBearing <= 90) ||\n (positiveBearing >= 180 && positiveBearing <= 270)\n ) {\n this._cursor = 'nesw-resize';\n props.onUpdateCursor('nesw-resize');\n } else {\n this._cursor = 'nwse-resize';\n props.onUpdateCursor('nwse-resize');\n }\n } else {\n props.onUpdateCursor(null);\n this._cursor = null;\n }\n };\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isScaling) {\n const selectedEditHandle = getPickedEditHandle(event.picks);\n this._selectedEditHandle =\n selectedEditHandle && selectedEditHandle.properties.editHandleType === 'scale'\n ? selectedEditHandle\n : null;\n\n this.updateCursor(props);\n }\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n event.cancelPan();\n this._isScaling = true;\n this._geometryBeingScaled = this.getSelectedFeaturesAsFeatureCollection(props);\n }\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isScaling) {\n return;\n }\n\n props.onUpdateCursor(this._cursor);\n\n const scaleAction = this.getScaleAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'scaling',\n props\n );\n if (scaleAction) {\n props.onEdit(scaleAction);\n }\n\n event.cancelPan();\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._isScaling) {\n // Scale the geometry\n const scaleAction = this.getScaleAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'scaled',\n props\n );\n if (scaleAction) {\n props.onEdit(scaleAction);\n }\n\n props.onUpdateCursor(null);\n\n this._geometryBeingScaled = null;\n this._selectedEditHandle = null;\n this._cursor = null;\n this._isScaling = false;\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n this._cornerGuidePoints = [];\n const selectedGeometry = this.getSelectedFeaturesAsFeatureCollection(props);\n\n // Add buffer to the enveloping box if a single Point feature is selected\n if (this._isSinglePointGeometrySelected(selectedGeometry)) {\n return {type: 'FeatureCollection', features: []};\n }\n\n const boundingBox = bboxPolygon(bbox(selectedGeometry));\n boundingBox.properties.mode = 'scale';\n const cornerGuidePoints: EditHandleFeature[] = [];\n\n coordEach(boundingBox, (coord, coordIndex) => {\n if (coordIndex < 4) {\n // Get corner midpoint guides from the enveloping box\n const cornerPoint = point(coord, {\n guideType: 'editHandle',\n editHandleType: 'scale',\n positionIndexes: [coordIndex]\n });\n cornerGuidePoints.push(cornerPoint as EditHandleFeature);\n }\n });\n\n this._cornerGuidePoints = cornerGuidePoints;\n // @ts-expect-error turf types diff\n return featureCollection([polygonToLine(boundingBox), ...this._cornerGuidePoints]);\n }\n}\n\nfunction getScaleFactor(centroid: Position, startDragPoint: Position, currentPoint: Position) {\n const startDistance = turfDistance(centroid, startDragPoint);\n const endDistance = turfDistance(centroid, currentPoint);\n return endDistance / startDistance;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bbox from '@turf/bbox';\nimport turfCentroid from '@turf/centroid';\nimport turfBearing from '@turf/bearing';\nimport bboxPolygon from '@turf/bbox-polygon';\nimport turfDistance from '@turf/distance';\nimport {coordEach} from '@turf/meta';\nimport {getGeom} from '@turf/invariant';\nimport {point, featureCollection, lineString} from '@turf/helpers';\nimport turfTransformRotate from '@turf/transform-rotate';\nimport {polygonToLine} from '@turf/polygon-to-line';\nimport {\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps,\n EditHandleFeature,\n GuideFeatureCollection\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {FeatureCollection, Position} from '../utils/geojson-types';\nimport {GeoJsonEditMode, GeoJsonEditAction, getIntermediatePosition} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class RotateMode extends GeoJsonEditMode {\n _selectedEditHandle: EditHandleFeature | null | undefined;\n _geometryBeingRotated: FeatureCollection | null | undefined;\n _isRotating = false;\n\n _isSinglePointGeometrySelected = (geometry: FeatureCollection | null | undefined): boolean => {\n const {features} = geometry || {};\n if (Array.isArray(features) && features.length === 1) {\n // @ts-expect-error turf type diff\n const {type}: {type: string} = getGeom(features[0]);\n return type === 'Point';\n }\n return false;\n };\n\n getIsRotating = () => this._isRotating;\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const selectedGeometry =\n this._geometryBeingRotated || this.getSelectedFeaturesAsFeatureCollection(props);\n\n if (this._isSinglePointGeometrySelected(selectedGeometry)) {\n return {type: 'FeatureCollection', features: []};\n }\n\n if (this._isRotating) {\n // Display rotate pivot\n // @ts-expect-error turf types diff\n return featureCollection([turfCentroid(selectedGeometry)]) as GuideFeatureCollection;\n }\n\n const boundingBox = bboxPolygon(bbox(selectedGeometry));\n\n let previousCoord: Position | null = null;\n let topEdgeMidpointCoords: Position | null = null;\n let longestEdgeLength = 0;\n\n coordEach(boundingBox, (coord: any) => {\n if (previousCoord) {\n const edgeMidpoint = getIntermediatePosition(coord, previousCoord);\n if (!topEdgeMidpointCoords || edgeMidpoint[1] > topEdgeMidpointCoords[1]) {\n // Get the top edge midpoint of the enveloping box\n topEdgeMidpointCoords = edgeMidpoint;\n }\n // Get the length of the longest edge of the enveloping box\n const edgeDistance = turfDistance(coord, previousCoord);\n longestEdgeLength = Math.max(longestEdgeLength, edgeDistance);\n }\n previousCoord = coord;\n });\n\n // Scale the length of the line between the rotate handler and the enveloping box\n // relative to the length of the longest edge of the enveloping box\n const rotateHandleCoords = topEdgeMidpointCoords && [\n topEdgeMidpointCoords[0],\n topEdgeMidpointCoords[1] + longestEdgeLength / 1000\n ];\n\n const lineFromEnvelopeToRotateHandle = lineString([topEdgeMidpointCoords, rotateHandleCoords]);\n const rotateHandle = point(rotateHandleCoords, {\n guideType: 'editHandle',\n editHandleType: 'rotate'\n });\n\n const outFeatures = [polygonToLine(boundingBox), rotateHandle, lineFromEnvelopeToRotateHandle];\n\n // @ts-expect-error turf type diff\n return featureCollection(outFeatures);\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isRotating) {\n return;\n }\n\n const rotateAction = this.getRotateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'rotating',\n props\n );\n if (rotateAction) {\n props.onEdit(rotateAction);\n }\n\n event.cancelPan();\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isRotating) {\n const selectedEditHandle = getPickedEditHandle(event.picks);\n this._selectedEditHandle =\n selectedEditHandle && selectedEditHandle.properties.editHandleType === 'rotate'\n ? selectedEditHandle\n : null;\n }\n\n this.updateCursor(props);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n event.cancelPan();\n this._isRotating = true;\n this._geometryBeingRotated = this.getSelectedFeaturesAsFeatureCollection(props);\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._isRotating) {\n // Rotate the geometry\n const rotateAction = this.getRotateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'rotated',\n props\n );\n\n if (rotateAction) {\n props.onEdit(rotateAction);\n }\n\n this._geometryBeingRotated = null;\n this._selectedEditHandle = null;\n this._isRotating = false;\n }\n }\n\n updateCursor(props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n // TODO: look at doing SVG cursors to get a better \"rotate\" cursor\n props.onUpdateCursor('crosshair');\n } else {\n props.onUpdateCursor(null);\n }\n }\n\n getRotateAction(\n startDragPoint: Position,\n currentPoint: Position,\n editType: string,\n props: ModeProps<FeatureCollection>\n ): GeoJsonEditAction | null | undefined {\n if (!this._geometryBeingRotated) {\n return null;\n }\n // @ts-expect-error turf types diff\n const centroid = turfCentroid(this._geometryBeingRotated);\n // @ts-expect-error turf types diff\n const angle = getRotationAngle(centroid, startDragPoint, currentPoint);\n\n // @ts-expect-error turf types too wide\n const rotatedFeatures: FeatureCollection = turfTransformRotate(\n // @ts-expect-error turf types too wide\n this._geometryBeingRotated,\n angle,\n {\n pivot: centroid\n }\n );\n\n let updatedData = new ImmutableFeatureCollection(props.data);\n\n const selectedIndexes = props.selectedIndexes;\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const movedFeature = rotatedFeatures.features[i];\n updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry);\n }\n\n return {\n updatedData: updatedData.getObject(),\n editType,\n editContext: {\n featureIndexes: selectedIndexes\n }\n };\n }\n}\n\nfunction getRotationAngle(centroid: Position, startDragPoint: Position, currentPoint: Position) {\n const bearing1 = turfBearing(centroid, startDragPoint);\n const bearing2 = turfBearing(centroid, currentPoint);\n return bearing2 - bearing1;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {StartDraggingEvent, ModeProps} from './types';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {TranslateMode} from './translate-mode';\n\nexport class DuplicateMode extends TranslateMode {\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n super.handleStartDragging(event, props);\n\n if (this._geometryBeforeTranslate) {\n props.onEdit(this.getAddManyFeaturesAction(this._geometryBeforeTranslate, props.data));\n }\n }\n\n updateCursor(props: ModeProps<FeatureCollection>) {\n if (this._isTranslatable) {\n props.onUpdateCursor('copy');\n } else {\n props.onUpdateCursor(null);\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport booleanPointInPolygon from '@turf/boolean-point-in-polygon';\nimport turfDifference from '@turf/difference';\nimport turfBuffer from '@turf/buffer';\nimport lineIntersect from '@turf/line-intersect';\nimport type {Point} from '@turf/helpers';\nimport {lineString} from '@turf/helpers';\nimport turfBearing from '@turf/bearing';\nimport turfDistance from '@turf/distance';\nimport turfDestination from '@turf/destination';\nimport turfPolygonToLine from '@turf/polygon-to-line';\nimport type {NearestPointOnLine} from '@turf/nearest-point-on-line';\nimport nearestPointOnLine from '@turf/nearest-point-on-line';\nimport {generatePointsParallelToLinePoints} from './utils';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {GeoJsonEditMode, GeoJsonEditAction} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class SplitPolygonMode extends GeoJsonEditMode {\n calculateMapCoords(clickSequence: any, mapCoords: any, props: ModeProps<FeatureCollection>) {\n const modeConfig = props.modeConfig;\n if (!modeConfig || !modeConfig.lock90Degree || !clickSequence.length) {\n return mapCoords;\n }\n if (clickSequence.length === 1) {\n // if first point is clicked, then find closest polygon point and build ~90deg vector\n const firstPoint = clickSequence[0];\n const selectedGeometry = this.getSelectedGeometry(props);\n // @ts-expect-error turf types diff\n const feature = turfPolygonToLine(selectedGeometry);\n\n const lines = feature.type === 'FeatureCollection' ? feature.features : [feature];\n let minDistance = Number.MAX_SAFE_INTEGER;\n let closestPoint: NearestPointOnLine | null = null;\n // If Multipolygon, then we should find nearest polygon line and stick split to it.\n lines.forEach((line) => {\n const snapPoint = nearestPointOnLine(line, firstPoint);\n const distanceFromOrigin = turfDistance(snapPoint, firstPoint);\n if (minDistance > distanceFromOrigin) {\n minDistance = distanceFromOrigin;\n closestPoint = snapPoint;\n }\n });\n\n if (closestPoint) {\n // closest point is used as 90degree entry to the polygon\n const lastBearing = turfBearing(firstPoint, closestPoint);\n const currentDistance = turfDistance(firstPoint, mapCoords, {units: 'meters'});\n return turfDestination(firstPoint, currentDistance, lastBearing, {\n units: 'meters'\n }).geometry.coordinates;\n }\n return mapCoords;\n }\n // Allow only 90 degree turns\n const lastPoint = clickSequence[clickSequence.length - 1];\n const [approximatePoint] = generatePointsParallelToLinePoints(\n clickSequence[clickSequence.length - 2],\n lastPoint,\n mapCoords\n );\n // align point with current ground\n const nearestPt = nearestPointOnLine(lineString([lastPoint, approximatePoint]), mapCoords)\n .geometry.coordinates;\n return nearestPt;\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length === 0 || !props.lastPointerMoveEvent) {\n // nothing to do yet\n return guides;\n }\n\n const {mapCoords} = props.lastPointerMoveEvent;\n\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords, props)]\n }\n });\n\n return guides;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const tentativeFeature = this.getTentativeGuide(props);\n\n const selectedGeometry = this.getSelectedGeometry(props);\n\n if (!selectedGeometry) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('A polygon must be selected for splitting');\n return;\n }\n\n const clickSequence = this.getClickSequence();\n if (tentativeFeature && tentativeFeature.geometry.type === 'LineString') {\n clickSequence.push(\n tentativeFeature.geometry.coordinates[tentativeFeature.geometry.coordinates.length - 1]\n );\n } else {\n this.addClickSequence(event);\n }\n\n const pt: Point = {\n type: 'Point',\n coordinates: clickSequence[clickSequence.length - 1]\n };\n\n // @ts-expect-error turf types diff\n const isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry);\n if (clickSequence.length > 1 && tentativeFeature && !isPointInPolygon) {\n this.resetClickSequence();\n // @ts-expect-error narrow type\n const isLineInterectingWithPolygon = lineIntersect(tentativeFeature, selectedGeometry);\n if (isLineInterectingWithPolygon.features.length === 0) {\n return;\n }\n\n const editAction = this.splitPolygon(tentativeFeature, props);\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n\n splitPolygon(tentativeFeature: TentativeFeature, props: ModeProps<FeatureCollection>) {\n const selectedGeometry = this.getSelectedGeometry(props);\n const featureIndex = props.selectedIndexes[0];\n const modeConfig = props.modeConfig || {};\n\n // Default gap in between the polygon\n let {gap = 0.1, units = 'centimeters'} = modeConfig;\n if (gap === 0) {\n gap = 0.1;\n units = 'centimeters';\n }\n\n const buffer = turfBuffer(tentativeFeature, gap, {units});\n // @ts-expect-error turf types diff\n const updatedGeometry = turfDifference(selectedGeometry, buffer);\n if (!updatedGeometry) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('Canceling edit. Split Polygon erased');\n return null;\n }\n\n const {type, coordinates} = updatedGeometry.geometry;\n let updatedCoordinates: any[] = []; // TODO\n if (type === 'Polygon') {\n // Update the coordinates as per Multipolygon\n updatedCoordinates = coordinates.map((c) => [c]);\n } else {\n // Handle Case when Multipolygon has holes\n updatedCoordinates = coordinates.reduce((agg, prev) => {\n prev.forEach((p) => {\n // @ts-expect-error revisit coordinates type here\n agg.push([p]);\n });\n return agg;\n }, []);\n }\n\n // Update the type to Mulitpolygon\n const updatedData = new ImmutableFeatureCollection(props.data).replaceGeometry(featureIndex, {\n type: 'MultiPolygon',\n coordinates: updatedCoordinates\n });\n\n const editAction: GeoJsonEditAction = {\n updatedData: updatedData.getObject(),\n editType: 'split',\n editContext: {\n featureIndexes: [featureIndex]\n }\n };\n\n return editAction;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bearing from '@turf/bearing';\nimport {\n generatePointsParallelToLinePoints,\n getPickedEditHandle,\n getPickedIntermediateEditHandle,\n shouldCancelPan\n} from './utils';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {ModeProps, StartDraggingEvent, StopDraggingEvent, DraggingEvent} from './types';\nimport {ModifyMode} from './modify-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ExtrudeMode extends ModifyMode {\n // this mode is busted =(\n\n isPointAdded = false;\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n\n if (editHandle) {\n const {featureIndex} = editHandle.properties;\n let {positionIndexes} = editHandle.properties;\n\n const size = this.coordinatesSize(positionIndexes, featureIndex, props.data);\n positionIndexes = this.isPointAdded\n ? this.nextPositionIndexes(positionIndexes, size)\n : positionIndexes;\n // p1 and p1 are end points for edge\n const p1 = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n props.data\n );\n const p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data);\n if (p1 && p2) {\n // p3 and p4 are end points for moving (extruding) edge\n const [p3, p4] = generatePointsParallelToLinePoints(p1, p2, event.mapCoords);\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replacePosition(featureIndex, this.prevPositionIndexes(positionIndexes, size), p4)\n .replacePosition(featureIndex, positionIndexes, p3)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'extruding',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes: this.nextPositionIndexes(positionIndexes, size),\n position: p3\n }\n });\n\n event.cancelPan();\n }\n }\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (shouldCancelPan(event)) {\n event.cancelPan();\n }\n\n const selectedFeatureIndexes = props.selectedIndexes;\n\n const editHandle = getPickedIntermediateEditHandle(event.picks);\n if (selectedFeatureIndexes.length && editHandle) {\n const {positionIndexes, featureIndex} = editHandle.properties;\n\n const size = this.coordinatesSize(positionIndexes, featureIndex, props.data);\n // p1 and p1 are end points for edge\n const p1 = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n props.data\n );\n const p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data);\n\n if (p1 && p2) {\n let updatedData = new ImmutableFeatureCollection(props.data);\n if (!this.isOrthogonal(positionIndexes, featureIndex, size, props.data)) {\n updatedData = updatedData.addPosition(featureIndex, positionIndexes, p2);\n }\n if (\n !this.isOrthogonal(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n size,\n props.data\n )\n ) {\n updatedData = updatedData.addPosition(featureIndex, positionIndexes, p1);\n this.isPointAdded = true;\n }\n\n props.onEdit({\n updatedData: updatedData.getObject(),\n editType: 'startExtruding',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: p1\n }\n });\n }\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n const selectedFeatureIndexes = props.selectedIndexes;\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n if (selectedFeatureIndexes.length && editHandle) {\n const {featureIndex} = editHandle.properties;\n let {positionIndexes} = editHandle.properties;\n\n const size = this.coordinatesSize(positionIndexes, featureIndex, props.data);\n positionIndexes = this.isPointAdded\n ? this.nextPositionIndexes(positionIndexes, size)\n : positionIndexes;\n // p1 and p1 are end points for edge\n const p1 = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n props.data\n );\n const p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data);\n\n if (p1 && p2) {\n // p3 and p4 are end points for new moved (extruded) edge\n const [p3, p4] = generatePointsParallelToLinePoints(p1, p2, event.mapCoords);\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replacePosition(featureIndex, this.prevPositionIndexes(positionIndexes, size), p4)\n .replacePosition(featureIndex, positionIndexes, p3)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'extruded',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: p3\n }\n });\n }\n }\n this.isPointAdded = false;\n }\n\n coordinatesSize(\n positionIndexes: number[] | null | undefined,\n featureIndex: number,\n {features}: FeatureCollection\n ) {\n let size = 0;\n if (Array.isArray(positionIndexes)) {\n const feature = features[featureIndex];\n const coordinates: any = feature.geometry.coordinates;\n // for Multi polygons, length will be 3\n if (positionIndexes.length === 3) {\n const [a, b] = positionIndexes;\n if (coordinates.length && coordinates[a].length) {\n size = coordinates[a][b].length;\n }\n } else {\n const [b] = positionIndexes;\n if (coordinates.length && coordinates[b].length) {\n size = coordinates[b].length;\n }\n }\n }\n return size;\n }\n\n getBearing(p1: any, p2: any) {\n const angle = bearing(p1, p2);\n if (angle < 0) {\n return Math.floor(360 + angle);\n }\n return Math.floor(angle);\n }\n\n isOrthogonal(\n positionIndexes: number[] | null | undefined,\n featureIndex: number,\n size: number,\n features: FeatureCollection\n ) {\n if (!Array.isArray(positionIndexes)) {\n return false;\n }\n if (positionIndexes[positionIndexes.length - 1] === size - 1) {\n positionIndexes[positionIndexes.length - 1] = 0;\n }\n const prevPoint = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n features\n );\n const nextPoint = this.getPointForPositionIndexes(\n this.nextPositionIndexes(positionIndexes, size),\n featureIndex,\n features\n );\n const currentPoint = this.getPointForPositionIndexes(positionIndexes, featureIndex, features);\n const prevAngle = this.getBearing(currentPoint, prevPoint);\n const nextAngle = this.getBearing(currentPoint, nextPoint);\n return [89, 90, 91, 269, 270, 271].includes(Math.abs(prevAngle - nextAngle));\n }\n\n nextPositionIndexes(positionIndexes: number[] | null | undefined, size: number): number[] {\n if (!Array.isArray(positionIndexes)) {\n return [];\n }\n const next = [...positionIndexes];\n if (next.length) {\n next[next.length - 1] = next[next.length - 1] === size - 1 ? 0 : next[next.length - 1] + 1;\n }\n return next;\n }\n\n prevPositionIndexes(positionIndexes: number[] | null | undefined, size: number): number[] {\n if (!Array.isArray(positionIndexes)) {\n return [];\n }\n const prev = [...positionIndexes];\n if (prev.length) {\n prev[prev.length - 1] = prev[prev.length - 1] === 0 ? size - 2 : prev[prev.length - 1] - 1;\n }\n return prev;\n }\n\n getPointForPositionIndexes(\n positionIndexes: number[] | null | undefined,\n featureIndex: number,\n {features}: FeatureCollection\n ) {\n let p1;\n if (Array.isArray(positionIndexes)) {\n const feature = features[featureIndex];\n const coordinates: any = feature.geometry.coordinates;\n // for Multi polygons, length will be 3\n if (positionIndexes.length === 3) {\n const [a, b, c] = positionIndexes;\n if (coordinates.length && coordinates[a].length) {\n p1 = coordinates[a][b][c];\n }\n } else {\n const [b, c] = positionIndexes;\n if (coordinates.length && coordinates[b].length) {\n p1 = coordinates[b][c];\n }\n }\n }\n return p1;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ModeProps, PointerMoveEvent, StopDraggingEvent} from './types';\nimport {Position, FeatureCollection} from '../utils/geojson-types';\nimport {getPickedEditHandle} from './utils';\nimport {ModifyMode} from './modify-mode';\n\nfunction defaultCalculateElevationChange({\n pointerDownScreenCoords,\n screenCoords\n}: {\n pointerDownScreenCoords: Position;\n screenCoords: Position;\n}) {\n return 10 * (pointerDownScreenCoords[1] - screenCoords[1]);\n}\n\nexport class ElevationMode extends ModifyMode {\n makeElevatedEvent(\n event: PointerMoveEvent | StopDraggingEvent,\n position: Position,\n props: ModeProps<FeatureCollection>\n ): Record<string, any> {\n const {\n minElevation = 0,\n maxElevation = 20000,\n calculateElevationChange = defaultCalculateElevationChange\n } = props.modeConfig || {};\n\n if (!event.pointerDownScreenCoords) {\n return event;\n }\n\n // $FlowFixMe - really, I know it has something at index 2\n let elevation = position.length === 3 ? position[2] : 0;\n\n // calculateElevationChange is configurable because (at this time) modes are not aware of the viewport\n elevation += calculateElevationChange({\n pointerDownScreenCoords: event.pointerDownScreenCoords,\n screenCoords: event.screenCoords\n });\n elevation = Math.min(elevation, maxElevation);\n elevation = Math.max(elevation, minElevation);\n\n return Object.assign({}, event, {\n mapCoords: [position[0], position[1], elevation]\n });\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n const position = editHandle ? editHandle.geometry.coordinates : event.mapCoords;\n // @ts-expect-error return type too wide\n super.handlePointerMove(this.makeElevatedEvent(event, position, props), props);\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n const editHandle = getPickedEditHandle(event.picks);\n const position = editHandle ? editHandle.geometry.coordinates : event.mapCoords;\n // @ts-expect-error return type too wide\n super.handleStopDragging(this.makeElevatedEvent(event, position, props), props);\n }\n\n getCursor(event: PointerMoveEvent): string | null | undefined {\n let cursor = super.getCursor(event);\n if (cursor === 'cell') {\n cursor = 'ns-resize';\n }\n return cursor;\n }\n\n static calculateElevationChangeWithViewport(\n viewport: any,\n {\n pointerDownScreenCoords,\n screenCoords\n }: {\n pointerDownScreenCoords: Position;\n screenCoords: Position;\n }\n ): number {\n // Source: https://gis.stackexchange.com/a/127949/111804\n const metersPerPixel =\n (156543.03392 * Math.cos((viewport.latitude * Math.PI) / 180)) / Math.pow(2, viewport.zoom);\n\n return (metersPerPixel * (pointerDownScreenCoords[1] - screenCoords[1])) / 2;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ClickEvent, PointerMoveEvent, ModeProps, TentativeFeature} from './types';\nimport {FeatureCollection, Point} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class DrawPointMode extends GeoJsonEditMode {\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n return {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'Point',\n coordinates: lastCoords[0]\n }\n };\n }\n\n handleClick({mapCoords}: ClickEvent, props: ModeProps<FeatureCollection>): void {\n const geometry: Point = {\n type: 'Point',\n coordinates: mapCoords\n };\n\n props.onEdit(this.getAddFeatureAction(geometry, props.data));\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport distance from '@turf/distance';\nimport {memoize} from '../utils/memoize';\nimport {LineString, FeatureCollection, Position} from '../utils/geojson-types';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n GuideFeature,\n Tooltip\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class DrawLineStringMode extends GeoJsonEditMode {\n // declaration of variables for the calculation of the distance of linestring\n dist = 0;\n position: Position = null!;\n elems: Position[] = [];\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n\n let positionAdded = false;\n if (!clickedEditHandle) {\n // Don't add another point right next to an existing one\n this.addClickSequence(event);\n positionAdded = true;\n }\n const clickSequence = this.getClickSequence();\n\n // check if the pointer is on editable state calculate the distance of new point\n if (!clickedEditHandle) {\n this.calculateInfoDraw(clickSequence);\n }\n\n if (\n clickSequence.length > 1 &&\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1\n ) {\n // They clicked the last point (or double-clicked), so add the LineString\n // reset distance to new calculate\n this.dist = 0;\n const lineStringToAdd: LineString = {\n type: 'LineString',\n coordinates: [...clickSequence]\n };\n\n this.resetClickSequence();\n\n const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);\n if (editAction) {\n props.onEdit(editAction);\n }\n } else if (positionAdded) {\n // new tentative point\n props.onEdit({\n // data is the same\n updatedData: props.data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n const {key} = event;\n if (key === 'Enter') {\n const clickSequence = this.getClickSequence();\n if (clickSequence.length > 1) {\n const lineStringToAdd: LineString = {\n type: 'LineString',\n coordinates: [...clickSequence]\n };\n this.resetClickSequence();\n const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n } else if (key === 'Escape') {\n this.resetClickSequence();\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n let tentativeFeature;\n if (clickSequence.length > 0) {\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, ...lastCoords]\n }\n };\n }\n\n if (tentativeFeature) {\n guides.features.push(tentativeFeature);\n }\n\n const editHandles: GuideFeature[] = clickSequence.map((clickedCoord, index) => ({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'existing',\n featureIndex: -1,\n positionIndexes: [index]\n },\n geometry: {\n type: 'Point',\n coordinates: clickedCoord\n }\n }));\n\n guides.features.push(...editHandles);\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n\n /**\n * define the default function to display the tooltip for\n * nebula geometry mode type\n * @param props properties of geometry nebula mode\n */\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return this._getTooltips({\n modeConfig: props.modeConfig,\n dist: this.dist\n });\n }\n\n // utility function\n calculateInfoDraw(clickSequence) {\n // check if the selected points are at least 2\n if (clickSequence.length > 1) {\n // setting the last point\n this.position = clickSequence[clickSequence.length - 1];\n // calculate the new distance by adding the\n // distance of the new drawn linestring\n this.dist += distance(\n clickSequence[clickSequence.length - 2],\n clickSequence[clickSequence.length - 1]\n );\n }\n }\n\n /**\n * redefine the tooltip of geometry\n * @param modeConfig\n * @param dist\n */\n _getTooltips = memoize(({modeConfig, dist}) => {\n let tooltips: Tooltip[] = [];\n const {formatTooltip} = modeConfig || {};\n let text;\n if (dist) {\n if (formatTooltip) {\n text = formatTooltip(dist);\n } else {\n // By default, round to 2 decimal places and append units\n text = `Distance: ${parseFloat(dist).toFixed(2)} kilometers`;\n }\n\n tooltips = [\n {\n position: this.position,\n text\n }\n ];\n }\n return tooltips;\n });\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// port from @deck.gl/core\nfunction isEqual(a: any, b: any) {\n if (a === b) {\n return true;\n }\n if (Array.isArray(a)) {\n // Special treatment for arrays: compare 1-level deep\n // This is to support equality of matrix/coordinate props\n const len = a.length;\n if (!b || b.length !== len) {\n return false;\n }\n\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n\n/**\n * Speed up consecutive function calls by caching the result of calls with identical input\n * https://en.wikipedia.org/wiki/Memoization\n * @param {function} compute - the function to be memoized\n */\nexport function memoize(compute: Function) {\n let cachedArgs = {};\n let cachedResult;\n\n return (args: any) => {\n for (const key in args) {\n if (!isEqual(args[key], cachedArgs[key])) {\n cachedResult = compute(args);\n cachedArgs = args;\n break;\n }\n }\n return cachedResult;\n };\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport lineIntersect from '@turf/line-intersect';\nimport {lineString as turfLineString} from '@turf/helpers';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature,\n GuideFeature\n} from './types';\nimport {Polygon, FeatureCollection} from '../utils/geojson-types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class DrawPolygonMode extends GeoJsonEditMode {\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n let tentativeFeature;\n if (clickSequence.length === 1 || clickSequence.length === 2) {\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, ...lastCoords]\n }\n };\n } else if (clickSequence.length > 2) {\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'Polygon',\n coordinates: [[...clickSequence, ...lastCoords, clickSequence[0]]]\n }\n };\n }\n\n return tentativeFeature;\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n const tentativeFeature = this.createTentativeFeature(props);\n if (tentativeFeature) {\n guides.features.push(tentativeFeature);\n }\n\n const editHandles: GuideFeature[] = clickSequence.map((clickedCoord, index) => ({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'existing',\n featureIndex: -1,\n positionIndexes: [index]\n },\n geometry: {\n type: 'Point',\n coordinates: clickedCoord\n }\n }));\n\n guides.features.push(...editHandles);\n\n return guides;\n }\n\n // eslint-disable-next-line complexity\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n const clickSequence = this.getClickSequence();\n\n let overlappingLines = false;\n if (clickSequence.length > 2 && props.modeConfig && props.modeConfig.preventOverlappingLines) {\n const currentLine = turfLineString([\n clickSequence[clickSequence.length - 1],\n event.mapCoords\n ]);\n const otherLines = turfLineString([...clickSequence.slice(0, clickSequence.length - 1)]);\n const intersectingPoints = lineIntersect(currentLine, otherLines);\n if (intersectingPoints.features.length > 0) {\n overlappingLines = true;\n }\n }\n\n let positionAdded = false;\n if (!clickedEditHandle && !overlappingLines) {\n // Don't add another point right next to an existing one\n this.addClickSequence(event);\n positionAdded = true;\n }\n\n if (\n clickSequence.length > 2 &&\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n (clickedEditHandle.properties.positionIndexes[0] === 0 ||\n clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1)\n ) {\n // They clicked the first or last point (or double-clicked), so complete the polygon\n\n // Remove the hovered position\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: [[...clickSequence, clickSequence[0]]]\n };\n\n this.resetClickSequence();\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n } else if (positionAdded) {\n // new tentative point\n props.onEdit({\n // data is the same\n updatedData: props.data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n if (event.key === 'Enter') {\n const clickSequence = this.getClickSequence();\n if (clickSequence.length > 2) {\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: [[...clickSequence, clickSequence[0]]]\n };\n this.resetClickSequence();\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n } else if (event.key === 'Escape') {\n this.resetClickSequence();\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawRectangleMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n const rectangle = bboxPolygon([coord1[0], coord1[1], coord2[0], coord2[1]]);\n rectangle.properties = rectangle.properties || {};\n rectangle.properties.shape = 'Rectangle';\n\n // @ts-expect-error turf typing too wide\n return rectangle;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n ClickEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {Polygon, FeatureCollection, FeatureOf, Position} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport omit from 'lodash.omit';\n\nexport class TwoClickPolygonMode extends GeoJsonEditMode {\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n if (props.modeConfig && props.modeConfig.dragToDraw) {\n // handled in drag handlers\n return;\n }\n\n this.addClickSequence(event);\n\n this.checkAndFinishPolygon(props);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>): void {\n if (!props.modeConfig || !props.modeConfig.dragToDraw) {\n // handled in click handlers\n return;\n }\n\n this.addClickSequence(event);\n event.cancelPan();\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>): void {\n if (!props.modeConfig || !props.modeConfig.dragToDraw) {\n // handled in click handlers\n return;\n }\n this.addClickSequence(event);\n\n this.checkAndFinishPolygon(props);\n }\n\n checkAndFinishPolygon(props: ModeProps<FeatureCollection>) {\n const clickSequence = this.getClickSequence();\n const tentativeFeature = this.getTentativeGuide(props);\n\n if (\n clickSequence.length > 1 &&\n tentativeFeature &&\n tentativeFeature.geometry.type === 'Polygon'\n ) {\n const feature: FeatureOf<Polygon> = {\n type: 'Feature',\n properties: omit(tentativeFeature.properties, 'guideType'),\n geometry: {\n type: 'Polygon',\n coordinates: tentativeFeature.geometry.coordinates\n }\n };\n const editAction = this.getAddFeatureOrBooleanPolygonAction(feature, props);\n\n this.resetClickSequence();\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent, modeConfig} = props;\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length === 0 || !lastPointerMoveEvent) {\n // nothing to do yet\n return guides;\n }\n\n const corner1 = clickSequence[0];\n const corner2 = lastPointerMoveEvent.mapCoords;\n\n const polygon = this.getTwoClickPolygon(corner1, corner2, modeConfig);\n if (polygon) {\n guides.features.push({\n type: 'Feature',\n properties: {\n ...polygon.properties,\n guideType: 'tentative'\n },\n geometry: polygon.geometry\n });\n }\n\n return guides;\n }\n\n getTwoClickPolygon(\n coord1: Position,\n coord2: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n return null;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n let tentativeFeature;\n if (clickSequence.length === 1) {\n tentativeFeature = this.getTwoClickPolygon(clickSequence[0], lastCoords[0], props.modeConfig);\n }\n\n return tentativeFeature;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport turfDistance from '@turf/distance';\nimport turfAlong from '@turf/along';\nimport {point, lineString as turfLineString} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawSquareMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // get the coordinates of the other two rectangle vertices\n const coord3 = [coord2[0], coord1[1]];\n const coord4 = [coord1[0], coord2[1]];\n\n // determine the shortest distance to the origin, which will be the length of each square side\n const distance1 = turfDistance(point(coord3), point(coord1));\n const distance2 = turfDistance(point(coord4), point(coord1));\n const shortestDistance = distance1 <= distance2 ? distance1 : distance2;\n\n // determine which coordinate pair of the two is closest to the origin\n const closestPoint = distance1 <= distance2 ? coord3 : coord4;\n\n // create a linestring which will used to locate the second square vertex\n const line = turfLineString([closestPoint, coord2]);\n\n // get the coordinates of the second square vertex\n const newPoint = turfAlong(line, shortestDistance);\n const corner = newPoint.geometry.coordinates;\n\n const square = bboxPolygon([coord1[0], coord1[1], corner[0], corner[1]]);\n square.properties = square.properties || {};\n square.properties.shape = 'Square';\n\n // @ts-expect-error turf types too wide\n return square;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawRectangleFromCenterMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n const longitude =\n coord1[0] > coord2[0]\n ? coord1[0] + Math.abs(coord1[0] - coord2[0])\n : coord1[0] - Math.abs(coord1[0] - coord2[0]);\n const latitude =\n coord1[1] > coord2[1]\n ? coord1[1] + Math.abs(coord1[1] - coord2[1])\n : coord1[1] - Math.abs(coord1[1] - coord2[1]);\n\n const rectangle = bboxPolygon([longitude, latitude, coord2[0], coord2[1]]);\n rectangle.properties = rectangle.properties || {};\n rectangle.properties.shape = 'Rectangle';\n\n // @ts-expect-error turf typing too wide\n return rectangle;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport turfDistance from '@turf/distance';\nimport turfAlong from '@turf/along';\nimport {point, lineString as turfLineString} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawSquareFromCenterMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // get the coordinates of the other two rectangle vertices\n const coord3 = [coord2[0], coord1[1]];\n const coord4 = [coord1[0], coord2[1]];\n\n // determine the shortest distance to the origin, which will be the length of each square side\n const distance1 = turfDistance(point(coord3), point(coord1));\n const distance2 = turfDistance(point(coord4), point(coord1));\n const shortestDistance = distance1 <= distance2 ? distance1 : distance2;\n\n // determine which coordinate pair of the two is closest to the origin\n const closestPoint = distance1 <= distance2 ? coord3 : coord4;\n\n // create a linestring which will used to locate the second square vertex\n const line = turfLineString([closestPoint, coord2]);\n\n // get the coordinates of the second square vertex\n const newPoint = turfAlong(line, shortestDistance);\n const corner = newPoint.geometry.coordinates;\n\n // determine the longitude and latitude values of the opposite corner\n const longitude =\n coord1[0] > corner[0]\n ? coord1[0] + Math.abs(coord1[0] - corner[0])\n : coord1[0] - Math.abs(coord1[0] - corner[0]);\n const latitude =\n coord1[1] > corner[1]\n ? coord1[1] + Math.abs(coord1[1] - corner[1])\n : coord1[1] - Math.abs(coord1[1] - corner[1]);\n\n const square = bboxPolygon([longitude, latitude, corner[0], corner[1]]);\n square.properties = square.properties || {};\n square.properties.shape = 'Square';\n\n // @ts-expect-error turf typing too wide\n return square;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport circle from '@turf/circle';\nimport distance from '@turf/distance';\nimport area from '@turf/area';\nimport {memoize} from '../utils/memoize';\nimport {ModeProps, Tooltip} from './types';\nimport {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawCircleFromCenterMode extends TwoClickPolygonMode {\n radius: number | null | undefined = null;\n position: Position = null!;\n areaCircle: number | null | undefined = null;\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // Default turf value for circle is 64\n const {steps = 64} = modeConfig || {};\n const options = {steps};\n // setting with position of center of circle\n this.position = coord2;\n\n if (steps < 4) {\n console.warn('Minimum steps to draw a circle is 4 '); // eslint-disable-line no-console,no-undef\n options.steps = 4;\n }\n\n // setting value of radius as distance of center and other point\n this.radius = Math.max(distance(coord1, coord2), 0.001);\n const geometry = circle(coord1, this.radius, options);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.shape = 'Circle';\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Circle';\n geometry.properties.editProperties.radius = {value: this.radius, unit: 'kilometers'};\n geometry.properties.editProperties.center = coord1;\n // calculate area of circle with turf function\n this.areaCircle = area(geometry);\n // @ts-expect-error turf types diff\n return geometry;\n }\n\n /**\n * define the default function to display the tooltip for\n * nebula geometry mode type\n * @param props properties of geometry nebula mode\n */\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return this._getTooltips({\n modeConfig: props?.modeConfig,\n radius: this.radius,\n areaCircle: this.areaCircle\n });\n }\n\n /**\n * redefine the tooltip of geometry\n * @param modeConfig\n * @param radius\n * @param areaCircle\n */\n _getTooltips = memoize(({modeConfig, radius, areaCircle}) => {\n let tooltips: Tooltip[] = [];\n const {formatTooltip} = modeConfig || {};\n let text: string;\n if (radius && areaCircle) {\n if (formatTooltip) {\n text = formatTooltip(radius);\n } else {\n // By default, round to 2 decimal places and append units\n text = `Radius: ${parseFloat(radius).toFixed(2)} kilometers\n \\n Area: ${parseFloat(areaCircle).toFixed(2)}`;\n }\n\n tooltips = [\n {\n position: this.position,\n text\n }\n ];\n }\n\n return tooltips;\n });\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport circle from '@turf/circle';\nimport distance from '@turf/distance';\nimport area from '@turf/area';\nimport {memoize} from '../utils/memoize';\nimport {ModeProps, Tooltip} from './types';\nimport {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';\nimport {getIntermediatePosition} from './geojson-edit-mode';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawCircleByDiameterMode extends TwoClickPolygonMode {\n radius: number | null | undefined = null;\n position: Position = null!;\n areaCircle: number | null | undefined = null;\n diameter: number | null | undefined = null;\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // Default turf value for circle is 64\n const {steps = 64} = modeConfig || {};\n const options = {steps};\n\n if (steps < 4) {\n console.warn('Minimum steps to draw a circle is 4 '); // eslint-disable-line no-console,no-undef\n options.steps = 4;\n }\n\n const centerCoordinates = getIntermediatePosition(coord1, coord2);\n // setting value of radius as distance of center and other point\n this.radius = Math.max(distance(coord1, centerCoordinates), 0.001);\n // setting value of diameter as distance of points\n this.diameter = Math.max(distance(coord1, coord2), 0.001);\n // setting position tooltip as center of circle\n this.position = centerCoordinates;\n\n const geometry = circle(centerCoordinates, this.radius, options);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.shape = 'Circle';\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Circle';\n geometry.properties.editProperties.radius = {value: this.radius, unit: 'kilometers'};\n geometry.properties.editProperties.center = centerCoordinates;\n // calculate area of circle with turf function\n this.areaCircle = area(geometry);\n // @ts-expect-error turf types diff\n return geometry;\n }\n\n /**\n * define the default function to display the tooltip for\n * nebula geometry mode type\n * @param props properties of geometry nebula mode\n */\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return this._getTooltips({\n modeConfig: props.modeConfig,\n radius: this.radius,\n areaCircle: this.areaCircle,\n diameter: this.diameter\n });\n }\n\n /**\n * redefine the tooltip of geometry\n * @param modeConfig\n * @param radius\n * @param areaCircle\n * @param diameter\n */\n _getTooltips = memoize(({modeConfig, radius, areaCircle, diameter}) => {\n let tooltips: Tooltip[] = [];\n const {formatTooltip} = modeConfig || {};\n let text;\n if (radius && areaCircle) {\n if (formatTooltip) {\n text = formatTooltip(radius);\n } else {\n // By default, round to 2 decimal places and append units\n text = `Radius: ${parseFloat(radius).toFixed(2)} kilometers\n \\n Area: ${parseFloat(areaCircle).toFixed(2)}\n \\n Diameter: ${parseFloat(diameter).toFixed(2)} kilometers`;\n }\n\n tooltips = [\n {\n position: this.position,\n text\n }\n ];\n }\n\n return tooltips;\n });\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport distance from '@turf/distance';\nimport ellipse from '@turf/ellipse';\nimport {point} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {getIntermediatePosition} from './geojson-edit-mode';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawEllipseByBoundingBoxMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n const minX = Math.min(coord1[0], coord2[0]);\n const minY = Math.min(coord1[1], coord2[1]);\n const maxX = Math.max(coord1[0], coord2[0]);\n const maxY = Math.max(coord1[1], coord2[1]);\n\n const polygonPoints = bboxPolygon([minX, minY, maxX, maxY]).geometry.coordinates[0];\n const centerCoordinates = getIntermediatePosition(coord1, coord2);\n\n const xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001);\n const ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001);\n\n const geometry = ellipse(centerCoordinates, xSemiAxis, ySemiAxis);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Ellipse';\n geometry.properties.editProperties.xSemiAxis = {value: xSemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.ySemiAxis = {value: ySemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.angle = 0;\n geometry.properties.editProperties.center = centerCoordinates;\n // @ts-expect-error fix return types\n return geometry;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport omit from 'lodash.omit';\n\nexport class ThreeClickPolygonMode extends GeoJsonEditMode {\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n this.addClickSequence(event);\n const clickSequence = this.getClickSequence();\n const tentativeFeature = this.getTentativeGuide(props);\n\n if (\n clickSequence.length > 2 &&\n tentativeFeature &&\n tentativeFeature.geometry.type === 'Polygon'\n ) {\n const editAction = this.getAddFeatureOrBooleanPolygonAction(\n tentativeFeature.geometry,\n props,\n omit(tentativeFeature.properties, 'guideType')\n );\n this.resetClickSequence();\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent, modeConfig} = props;\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length === 0) {\n // nothing to do yet\n return guides;\n }\n\n const hoveredCoord = lastPointerMoveEvent.mapCoords;\n\n if (clickSequence.length === 1) {\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [clickSequence[0], hoveredCoord]\n }\n });\n } else {\n const polygon = this.getThreeClickPolygon(\n clickSequence[0],\n clickSequence[1],\n hoveredCoord,\n modeConfig\n );\n if (polygon) {\n guides.features.push({\n type: 'Feature',\n properties: {\n ...polygon.properties,\n guideType: 'tentative'\n },\n geometry: polygon.geometry\n });\n }\n }\n\n return guides;\n }\n\n getThreeClickPolygon(\n coord1: Position,\n coord2: Position,\n coord3: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n return null;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n let tentativeFeature;\n if (clickSequence.length === 2) {\n tentativeFeature = this.getThreeClickPolygon(\n clickSequence[0],\n clickSequence[1],\n lastCoords[0],\n props.modeConfig\n );\n }\n\n return tentativeFeature;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {generatePointsParallelToLinePoints} from './utils';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {ThreeClickPolygonMode} from './three-click-polygon-mode';\n\nexport class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode {\n getThreeClickPolygon(\n coord1: Position,\n coord2: Position,\n coord3: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n const [p3, p4] = generatePointsParallelToLinePoints(coord1, coord2, coord3);\n\n return {\n type: 'Feature',\n properties: {\n shape: 'Rectangle'\n },\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n // Draw a polygon containing all the points of the LineString,\n // then the points orthogonal to the lineString,\n // then back to the starting position\n coord1,\n coord2,\n p3,\n p4,\n coord1\n ]\n ]\n }\n };\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport distance from '@turf/distance';\nimport ellipse from '@turf/ellipse';\nimport bearing from '@turf/bearing';\nimport {point} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {getIntermediatePosition} from './geojson-edit-mode';\nimport {ThreeClickPolygonMode} from './three-click-polygon-mode';\n\nexport class DrawEllipseUsingThreePointsMode extends ThreeClickPolygonMode {\n getThreeClickPolygon(\n coord1: Position,\n coord2: Position,\n coord3: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n const centerCoordinates = getIntermediatePosition(coord1, coord2);\n const xSemiAxis = Math.max(distance(centerCoordinates, point(coord3)), 0.001);\n const ySemiAxis = Math.max(distance(coord1, coord2), 0.001) / 2;\n const options = {angle: bearing(coord1, coord2)};\n // @ts-expect-error fix return types\n const geometry = ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Ellipse';\n geometry.properties.editProperties.xSemiAxis = {value: xSemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.ySemiAxis = {value: ySemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.angle = options.angle;\n geometry.properties.editProperties.center = centerCoordinates;\n // @ts-expect-error fix return types\n return geometry;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport destination from '@turf/destination';\nimport bearing from '@turf/bearing';\nimport lineIntersect from '@turf/line-intersect';\nimport turfDistance from '@turf/distance';\nimport {point, lineString as turfLineString} from '@turf/helpers';\nimport {\n generatePointsParallelToLinePoints,\n getPickedEditHandle,\n getEditHandlesForGeometry\n} from './utils';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {Polygon, LineString, Position, FeatureCollection} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class Draw90DegreePolygonMode extends GeoJsonEditMode {\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const clickSequence = this.getClickSequence();\n\n const {mapCoords} = props.lastPointerMoveEvent;\n\n let p3;\n if (clickSequence.length <= 1) {\n p3 = mapCoords;\n } else {\n const p1 = clickSequence[clickSequence.length - 2];\n const p2 = clickSequence[clickSequence.length - 1];\n [p3] = generatePointsParallelToLinePoints(p1, p2, mapCoords);\n }\n\n let tentativeFeature;\n\n if (clickSequence.length < 3) {\n // Draw a LineString connecting all the clicked points with the hovered point\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, p3]\n }\n };\n } else {\n // Draw a Polygon connecting all the clicked points with the hovered point\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'Polygon',\n coordinates: [[...clickSequence, p3, clickSequence[0]]]\n }\n };\n }\n\n return tentativeFeature;\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n const clickSequence = this.getClickSequence();\n\n if (clickSequence.length === 0 || !props.lastPointerMoveEvent) {\n return guides;\n }\n const tentativeFeature = this.createTentativeFeature(props);\n\n guides.features.push(tentativeFeature);\n\n guides.features = guides.features.concat(\n getEditHandlesForGeometry(tentativeFeature.geometry, -1)\n );\n\n // Slice off the handles that are are next to the pointer\n guides.features = guides.features.slice(0, -1);\n\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const tentativeFeature = this.getTentativeGuide(props);\n this.addClickSequence(event);\n const clickSequence = this.getClickSequence();\n\n if (!tentativeFeature) {\n // nothing else to do\n return;\n }\n\n if (clickSequence.length === 3 && tentativeFeature.geometry.type === 'LineString') {\n const lineString: LineString = tentativeFeature.geometry;\n\n // Tweak the clicked position to be the snapped 90 degree point along the polygon\n clickSequence[clickSequence.length - 1] =\n lineString.coordinates[lineString.coordinates.length - 1];\n } else if (clickSequence.length > 3 && tentativeFeature.geometry.type === 'Polygon') {\n const polygon: Polygon = tentativeFeature.geometry;\n\n // Tweak the clicked position to be the snapped 90 degree point along the polygon\n clickSequence[clickSequence.length - 1] =\n polygon.coordinates[0][polygon.coordinates[0].length - 2];\n\n const clickedEditHandle = getPickedEditHandle(picks);\n\n if (\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n (clickedEditHandle.properties.positionIndexes[1] === 0 ||\n clickedEditHandle.properties.positionIndexes[1] === polygon.coordinates[0].length - 3)\n ) {\n // They clicked the first or last point (or double-clicked), so complete the polygon\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: this.finalizedCoordinates([...polygon.coordinates[0]])\n };\n\n this.resetClickSequence();\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n } else {\n // Trigger pointer move right away in order for it to update edit handles (to support double-click)\n const fakePointerMoveEvent: PointerMoveEvent = {\n screenCoords: [-1, -1],\n mapCoords: event.mapCoords,\n picks: [],\n pointerDownPicks: null,\n pointerDownScreenCoords: null,\n pointerDownMapCoords: null,\n cancelPan: () => {},\n sourceEvent: null\n };\n\n this.handlePointerMove(fakePointerMoveEvent, props);\n }\n }\n\n finalizedCoordinates(coords: Position[]) {\n // Remove the hovered position\n let coordinates = [[...coords.slice(0, -2), coords[0]]];\n let pt = this.getIntermediatePoint([...coords]);\n if (!pt) {\n // if intermediate point with 90 degree not available\n // try remove the last clicked point and get the intermediate point.\n const tc = [...coords];\n tc.splice(-3, 1);\n pt = this.getIntermediatePoint([...tc]);\n if (pt) {\n coordinates = [[...coords.slice(0, -3), pt, coords[0]]];\n }\n } else {\n coordinates = [[...coords.slice(0, -2), pt, coords[0]]];\n }\n return coordinates;\n }\n\n getIntermediatePoint(coordinates: Position[]): Position | null {\n let pt: Position | null = null;\n if (coordinates.length > 4) {\n const [p1, p2] = [...coordinates];\n const angle1 = bearing(p1, p2);\n const p3 = coordinates[coordinates.length - 3];\n const p4 = coordinates[coordinates.length - 4];\n const angle2 = bearing(p3, p4);\n\n const angles = {first: [] as number[], second: [] as number[]};\n // calculate 3 right angle points for first and last points in lineString\n [1, 2, 3].forEach((factor) => {\n const newAngle1 = angle1 + factor * 90;\n // convert angles to 0 to -180 for anti-clock and 0 to 180 for clock wise\n angles.first.push(newAngle1 > 180 ? newAngle1 - 360 : newAngle1);\n const newAngle2 = angle2 + factor * 90;\n angles.second.push(newAngle2 > 180 ? newAngle2 - 360 : newAngle2);\n });\n\n const distance = turfDistance(point(p1), point(p3));\n // Draw imaginary right angle lines for both first and last points in lineString\n // If there is intersection point for any 2 lines, will be the 90 degree point.\n [0, 1, 2].forEach((indexFirst) => {\n const line1 = turfLineString([\n p1,\n destination(p1, distance, angles.first[indexFirst]).geometry.coordinates\n ]);\n [0, 1, 2].forEach((indexSecond) => {\n const line2 = turfLineString([\n p3,\n destination(p3, distance, angles.second[indexSecond]).geometry.coordinates\n ]);\n const fc = lineIntersect(line1, line2);\n if (fc && fc.features.length) {\n // found the intersect point\n pt = fc.features[0].geometry.coordinates;\n }\n });\n });\n }\n return pt;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport throttle from 'lodash.throttle';\nimport {ClickEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps} from './types';\nimport {Polygon, FeatureCollection} from '../utils/geojson-types';\nimport {getPickedEditHandle} from './utils';\nimport {DrawPolygonMode} from './draw-polygon-mode';\n\ntype DraggingHandler = (event: DraggingEvent, props: ModeProps<FeatureCollection>) => void;\n\nexport class DrawPolygonByDraggingMode extends DrawPolygonMode {\n handleDraggingThrottled: DraggingHandler | null | undefined = null;\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n // No-op\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n event.cancelPan();\n if (props.modeConfig && props.modeConfig.throttleMs) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.handleDraggingThrottled = throttle(this.handleDraggingAux, props.modeConfig.throttleMs);\n } else {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.handleDraggingThrottled = this.handleDraggingAux;\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n this.addClickSequence(event);\n const clickSequence = this.getClickSequence();\n // @ts-expect-error cancel() not typed\n if (this.handleDraggingThrottled && this.handleDraggingThrottled.cancel) {\n // @ts-expect-error cancel() not typed\n this.handleDraggingThrottled.cancel();\n }\n\n if (clickSequence.length > 2) {\n // Complete the polygon.\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: [[...clickSequence, clickSequence[0]]]\n };\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n this.resetClickSequence();\n }\n\n handleDraggingAux(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n\n if (!clickedEditHandle) {\n // Don't add another point right next to an existing one.\n this.addClickSequence(event);\n props.onEdit({\n updatedData: props.data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this.handleDraggingThrottled) {\n this.handleDraggingThrottled(event, props);\n }\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n if (event.key === 'Enter') {\n const clickSequence = this.getClickSequence();\n if (clickSequence.length > 2) {\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: [[...clickSequence, clickSequence[0]]]\n };\n this.resetClickSequence();\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n } else if (event.key === 'Escape') {\n this.resetClickSequence();\n if (this.handleDraggingThrottled) {\n this.handleDraggingThrottled = null;\n }\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Position, Feature, FeatureCollection} from '../utils/geojson-types';\nimport {\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps,\n Pick,\n GuideFeatureCollection,\n EditHandleFeature\n} from './types';\nimport {\n getPickedSnapSourceEditHandle,\n getPickedEditHandles,\n getEditHandlesForGeometry\n} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\ntype MovementTypeEvent = PointerMoveEvent | StartDraggingEvent | StopDraggingEvent | DraggingEvent;\n\nexport class SnappableMode extends GeoJsonEditMode {\n _handler: GeoJsonEditMode;\n\n constructor(handler: GeoJsonEditMode) {\n super();\n this._handler = handler;\n }\n\n _getSnappedMouseEvent<T extends MovementTypeEvent>(\n event: T,\n snapSource: EditHandleFeature,\n snapTarget: EditHandleFeature\n ): T {\n return Object.assign(event, {\n mapCoords: snapTarget.geometry.coordinates,\n pointerDownMapCoords: snapSource && snapSource.geometry.coordinates\n });\n }\n\n _getPickedSnapTarget(picks: Pick[]): EditHandleFeature | null | undefined {\n return getPickedEditHandles(picks).find(\n (handle) => handle.properties.editHandleType === 'snap-target'\n );\n }\n\n _getPickedSnapSource(\n pointerDownPicks: Pick[] | null | undefined\n ): EditHandleFeature | null | undefined {\n return getPickedSnapSourceEditHandle(pointerDownPicks);\n }\n\n _getUpdatedSnapSourceHandle(\n snapSourceHandle: EditHandleFeature,\n data: FeatureCollection\n ): EditHandleFeature {\n const {featureIndex, positionIndexes} = snapSourceHandle.properties;\n if (!Array.isArray(positionIndexes)) {\n return snapSourceHandle;\n }\n const snapSourceFeature = data.features[featureIndex];\n\n // $FlowFixMe\n const snapSourceCoordinates = positionIndexes.reduce(\n (a: any[], b: number) => a[b],\n snapSourceFeature.geometry.coordinates\n ) as Position;\n\n return {\n ...snapSourceHandle,\n geometry: {\n type: 'Point',\n coordinates: snapSourceCoordinates\n }\n };\n }\n\n // If additionalSnapTargets is present in modeConfig and is populated, this\n // method will return those features along with the features\n // that live in the current layer. Otherwise, this method will simply return the\n // features from the current layer\n _getSnapTargets(props: ModeProps<FeatureCollection>): Feature[] {\n let {additionalSnapTargets} = props.modeConfig || {};\n additionalSnapTargets = additionalSnapTargets || [];\n\n const features = [...props.data.features, ...additionalSnapTargets];\n return features;\n }\n\n _getSnapTargetHandles(props: ModeProps<FeatureCollection>): EditHandleFeature[] {\n const handles: EditHandleFeature[] = [];\n const features = this._getSnapTargets(props);\n\n for (let i = 0; i < features.length; i++) {\n // Filter out the currently selected feature(s)\n const isCurrentIndexFeatureNotSelected = !props.selectedIndexes.includes(i);\n\n if (isCurrentIndexFeatureNotSelected) {\n const {geometry} = features[i];\n handles.push(...getEditHandlesForGeometry(geometry, i, 'snap-target'));\n }\n }\n return handles;\n }\n\n // If no snap handle has been picked, only display the edit handles of the\n // selected feature. If a snap handle has been picked, display said snap handle\n // along with all snappable points on all non-selected features.\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {modeConfig, lastPointerMoveEvent} = props;\n const {enableSnapping} = modeConfig || {};\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: [...this._handler.getGuides(props).features]\n };\n\n if (!enableSnapping) {\n return guides;\n }\n\n const snapSourceHandle: EditHandleFeature | null | undefined =\n lastPointerMoveEvent && this._getPickedSnapSource(lastPointerMoveEvent.pointerDownPicks);\n\n // They started dragging a handle\n // So render the picked handle (in its updated location) and all possible snap targets\n if (snapSourceHandle) {\n guides.features.push(\n ...this._getSnapTargetHandles(props),\n this._getUpdatedSnapSourceHandle(snapSourceHandle, props.data)\n );\n\n return guides;\n }\n\n // Render the possible snap source handles\n const {features} = props.data;\n for (const index of props.selectedIndexes) {\n if (index < features.length) {\n const {geometry} = features[index];\n guides.features.push(...getEditHandlesForGeometry(geometry, index, 'snap-source'));\n }\n }\n\n return guides;\n }\n\n _getSnapAwareEvent<T extends MovementTypeEvent>(\n event: T,\n props: ModeProps<FeatureCollection>\n ): T {\n const snapSource = this._getPickedSnapSource(props.lastPointerMoveEvent.pointerDownPicks);\n const snapTarget = this._getPickedSnapTarget(event.picks);\n\n return snapSource && snapTarget\n ? this._getSnappedMouseEvent(event, snapSource, snapTarget)\n : event;\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handleStartDragging(event, props);\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handleStopDragging(this._getSnapAwareEvent(event, props), props);\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handleDragging(this._getSnapAwareEvent(event, props), props);\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handlePointerMove(this._getSnapAwareEvent(event, props), props);\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {featureCollection} from '@turf/helpers';\nimport {PointerMoveEvent, ModeProps, StartDraggingEvent} from './types';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {TranslateMode} from './translate-mode';\nimport {ScaleMode} from './scale-mode';\nimport {RotateMode} from './rotate-mode';\n\nimport {CompositeMode} from './composite-mode';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class TransformMode extends CompositeMode {\n constructor() {\n super([new TranslateMode(), new ScaleMode(), new RotateMode()]);\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n let updatedCursor: string | null = null;\n super.handlePointerMove(event, {\n ...props,\n onUpdateCursor: (cursor) => {\n updatedCursor = cursor || updatedCursor;\n }\n });\n props.onUpdateCursor(updatedCursor);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n let scaleMode: ScaleMode | null = null;\n let translateMode: TranslateMode | null = null;\n const filteredModes: GeoJsonEditMode[] = [];\n\n if (event.picks.length) {\n event.cancelPan();\n }\n\n // If the user selects a scaling edit handle that overlaps with part of the selected feature,\n // it is possible for both scale and translate actions to be triggered. This logic prevents\n // this simultaneous action trigger from happening by putting a higher priority on scaling\n // since the user needs to be more precise to hover over a scaling edit handle.\n this._modes.forEach((mode) => {\n if (mode instanceof TranslateMode) {\n translateMode = mode;\n } else {\n if (mode instanceof ScaleMode) {\n scaleMode = mode;\n }\n filteredModes.push(mode);\n }\n });\n\n if (scaleMode instanceof ScaleMode && !scaleMode.isEditHandleSelected()) {\n filteredModes.push(translateMode);\n }\n\n filteredModes.filter(Boolean).forEach((mode) => mode.handleStartDragging(event, props));\n }\n\n getGuides(props: ModeProps<FeatureCollection>) {\n let compositeGuides = super.getGuides(props);\n const rotateMode = (this._modes || []).find((mode) => mode instanceof RotateMode);\n\n if (rotateMode instanceof RotateMode) {\n const nonEnvelopeGuides = compositeGuides.features.filter((guide) => {\n const {editHandleType, mode} = (guide.properties as any) || {};\n // Both scale and rotate modes have the same enveloping box as a guide - only need one\n const guidesToFilterOut = [mode];\n // Do not render scaling edit handles if rotating\n if (rotateMode.getIsRotating()) {\n guidesToFilterOut.push(editHandleType);\n }\n return !guidesToFilterOut.includes('scale');\n });\n\n // @ts-expect-error turf types\n compositeGuides = featureCollection(nonEnvelopeGuides);\n }\n return compositeGuides;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {\n ModeProps,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n GuideFeatureCollection,\n GuideFeature\n} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class CompositeMode extends GeoJsonEditMode {\n _modes: Array<GeoJsonEditMode>;\n\n constructor(modes: Array<GeoJsonEditMode>) {\n super();\n this._modes = modes;\n }\n\n _coalesce<T>(\n callback: (arg0: GeoJsonEditMode) => T,\n resultEval: ((arg0: T) => boolean | null | undefined) | null = null\n ): T {\n let result: T | null = null;\n\n for (let i = 0; i < this._modes.length; i++) {\n // eslint-disable-next-line callback-return\n result = callback(this._modes[i]);\n if (resultEval ? resultEval(result) : result) {\n break;\n }\n }\n\n return result;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {\n this._coalesce((handler) => handler.handleClick(event, props));\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handlePointerMove(event, props));\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handleStartDragging(event, props));\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handleStopDragging(event, props));\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handleDragging(event, props));\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n // TODO: Combine the guides *BUT* make sure if none of the results have\n // changed to return the same object so that \"guides !== this.state.guides\"\n // in editable-geojson-layer works.\n\n const allGuides: GuideFeature[] = [];\n for (const mode of this._modes) {\n allGuides.push(...mode.getGuides(props).features);\n }\n\n return {\n type: 'FeatureCollection',\n features: allGuides\n };\n }\n}\n", "import {FeatureCollection} from '../utils/geojson-types';\n\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ClickEvent, ModeProps} from './types';\nexport class DeleteMode extends GeoJsonEditMode {\n handleClick(_event: ClickEvent, props: ModeProps<FeatureCollection>): void {\n const selectedFeatureIndexes = props.lastPointerMoveEvent.picks.map((pick) => pick.index);\n if (selectedFeatureIndexes.length > 0) {\n const indexToDelete = selectedFeatureIndexes[0];\n\n const features = props.data.features.filter((_, index) => index !== indexToDelete);\n const updatedData = {\n ...props.data,\n features\n };\n\n const editAction = {\n updatedData,\n editType: 'deleteFeature',\n editContext: {\n featureIndexes: selectedFeatureIndexes\n }\n };\n\n props.onEdit(editAction);\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.\n * Required in order to maintain the same appearance after upgrading to deck.gl v8.5.\n * https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md\n */\nexport const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;\n\n/**\n * Unit literal to shader unit number conversion.\n */\nexport const UNIT = {\n common: 0,\n meters: 1,\n pixels: 2\n};\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {CompositeLayerProps} from '@deck.gl/core';\nimport {CompositeLayer} from '@deck.gl/core';\nimport {\n DraggingEvent,\n ClickEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n PointerMoveEvent\n} from '../edit-modes/types';\nimport {Position} from '../utils/geojson-types';\n\nconst EVENT_TYPES = ['click', 'pointermove', 'panstart', 'panmove', 'panend', 'keyup'];\n\n// TODO(v9): remove generic layer\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type EditableLayerProps<DataType = any> = CompositeLayerProps & {\n pickingRadius?: number;\n pickingDepth?: number;\n onCancelPan?: () => void;\n};\n\nexport abstract class EditableLayer<\n DataT = any,\n ExtraPropsT = Record<string, unknown>\n> extends CompositeLayer<ExtraPropsT & Required<EditableLayerProps<DataT>>> {\n static layerName = 'EditableLayer';\n\n state: {_editableLayerState: any} = undefined!;\n\n // Overridable interaction event handlers\n onLayerClick(event: ClickEvent): void {\n // default implementation - do nothing\n }\n\n onStartDragging(event: StartDraggingEvent): void {\n // default implementation - do nothing\n }\n\n onStopDragging(event: StopDraggingEvent): void {\n // default implementation - do nothing\n }\n\n onDragging(event: DraggingEvent): void {\n // default implementation - do nothing\n }\n\n onPointerMove(event: PointerMoveEvent): void {\n // default implementation - do nothing\n }\n\n onLayerKeyUp(event: KeyboardEvent): void {\n // default implementation - do nothing;\n }\n // TODO: implement onCancelDragging (e.g. drag off screen)\n\n initializeState() {\n this.setState({\n _editableLayerState: {\n // Picked objects at the time the pointer went down\n pointerDownPicks: null,\n // Screen coordinates where the pointer went down\n pointerDownScreenCoords: null,\n // Ground coordinates where the pointer went down\n pointerDownMapCoords: null,\n\n // Keep track of the mjolnir.js event handler so it can be deregistered\n eventHandler: this._forwardEventToCurrentLayer.bind(this)\n }\n });\n\n this._addEventHandlers();\n }\n\n finalizeState() {\n this._removeEventHandlers();\n }\n\n _addEventHandlers() {\n // @ts-expect-error accessing protected props\n const {eventManager} = this.context.deck;\n const {eventHandler} = this.state._editableLayerState;\n\n for (const eventType of EVENT_TYPES) {\n eventManager.on(eventType as any, eventHandler, {\n // give nebula a higher priority so that it can stop propagation to deck.gl's map panning handlers\n priority: 100\n });\n }\n }\n\n _removeEventHandlers() {\n // @ts-expect-error accessing protected props\n const {eventManager} = this.context.deck;\n const {eventHandler} = this.state._editableLayerState;\n\n for (const eventType of EVENT_TYPES) {\n eventManager.off(eventType as any, eventHandler);\n }\n }\n\n // A new layer instance is created on every render, so forward the event to the current layer\n // This means that the first layer instance will stick around to be the event listener, but will forward the event\n // to the latest layer instance.\n _forwardEventToCurrentLayer(event: any) {\n const currentLayer = this.getCurrentLayer();\n\n // Use a naming convention to find the event handling function for this event type\n const func = currentLayer[`_on${event.type}`].bind(currentLayer);\n if (!func) {\n console.warn(`no handler for mjolnir.js event ${event.type}`); // eslint-disable-line\n return;\n }\n func(event);\n }\n\n _onclick({srcEvent}: any) {\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const picks = this.getPicks(screenCoords);\n\n this.onLayerClick({\n mapCoords,\n screenCoords,\n picks,\n sourceEvent: srcEvent\n });\n }\n\n _onkeyup({srcEvent}: {srcEvent: KeyboardEvent}) {\n this.onLayerKeyUp(srcEvent);\n }\n\n _onpanstart(event: any) {\n const screenCoords = this.getScreenCoords(event.srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n const picks = this.getPicks(screenCoords);\n\n this.setState({\n _editableLayerState: {\n ...this.state._editableLayerState,\n pointerDownScreenCoords: screenCoords,\n pointerDownMapCoords: mapCoords,\n pointerDownPicks: picks\n }\n });\n\n this.onStartDragging({\n picks,\n screenCoords,\n mapCoords,\n pointerDownScreenCoords: screenCoords,\n pointerDownMapCoords: mapCoords,\n cancelPan: () => {\n if (this.props.onCancelPan) {\n this.props.onCancelPan();\n }\n\n event.stopImmediatePropagation();\n },\n sourceEvent: event.srcEvent\n });\n }\n\n _onpanmove(event: any) {\n const {srcEvent} = event;\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const {pointerDownPicks, pointerDownScreenCoords, pointerDownMapCoords} =\n this.state._editableLayerState;\n\n const picks = this.getPicks(screenCoords);\n\n this.onDragging({\n screenCoords,\n mapCoords,\n picks,\n pointerDownPicks,\n pointerDownScreenCoords,\n pointerDownMapCoords,\n sourceEvent: srcEvent,\n cancelPan: event.stopImmediatePropagation\n // another (hacky) approach for cancelling map panning\n // const controller = this.context.deck.viewManager.controllers[\n // Object.keys(this.context.deck.viewManager.controllers)[0]\n // ];\n // controller._state.isDragging = false;\n });\n }\n\n _onpanend({srcEvent}: any) {\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const {pointerDownPicks, pointerDownScreenCoords, pointerDownMapCoords} =\n this.state._editableLayerState;\n\n const picks = this.getPicks(screenCoords);\n\n this.onStopDragging({\n picks,\n screenCoords,\n mapCoords,\n pointerDownPicks,\n pointerDownScreenCoords,\n pointerDownMapCoords,\n sourceEvent: srcEvent\n });\n\n this.setState({\n _editableLayerState: {\n ...this.state._editableLayerState,\n pointerDownScreenCoords: null,\n pointerDownMapCoords: null,\n pointerDownPicks: null\n }\n });\n }\n\n _onpointermove(event: any) {\n const {srcEvent} = event;\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const {pointerDownPicks, pointerDownScreenCoords, pointerDownMapCoords} =\n this.state._editableLayerState;\n\n const picks = this.getPicks(screenCoords);\n\n this.onPointerMove({\n screenCoords,\n mapCoords,\n picks,\n pointerDownPicks,\n pointerDownScreenCoords,\n pointerDownMapCoords,\n sourceEvent: srcEvent,\n cancelPan: event.stopImmediatePropagation\n });\n }\n\n getPicks(screenCoords: [number, number]) {\n return this.context.deck.pickMultipleObjects({\n x: screenCoords[0],\n y: screenCoords[1],\n layerIds: [this.props.id],\n radius: this.props.pickingRadius,\n depth: this.props.pickingDepth\n });\n }\n\n getScreenCoords(pointerEvent: any): Position {\n return [\n pointerEvent.clientX -\n (this.context.gl.canvas as HTMLCanvasElement).getBoundingClientRect().left,\n pointerEvent.clientY -\n (this.context.gl.canvas as HTMLCanvasElement).getBoundingClientRect().top\n ];\n }\n\n getMapCoords(screenCoords: Position): Position {\n return this.context.viewport.unproject([screenCoords[0], screenCoords[1]]) as Position;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {PathLayerProps} from '@deck.gl/layers';\nimport {PathLayer} from '@deck.gl/layers';\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\nimport {insertBefore} from '../utils/utils';\n\nconst uniformBlock = `\\\nuniform pickingLineWidthUniforms {\n float extraPixels;\n} pickingLineWidth;\n`;\n\nexport type PickingLineWidthProps = {\n extraPixels: number;\n};\n\nexport const pickingUniforms = {\n name: 'pickingLineWidth',\n vs: uniformBlock,\n fs: uniformBlock,\n uniformTypes: {\n extraPixels: 'f32'\n }\n} as const satisfies ShaderModule<PickingLineWidthProps>;\n\ninterface EditablePathLayerProps extends PathLayerProps<any> {\n pickingLineWidthExtraPixels?: number;\n}\n\nconst defaultProps = {\n ...PathLayer.defaultProps,\n pickingLineWidthExtraPixels: {type: 'number', min: 0, value: Number.MAX_SAFE_INTEGER}\n};\n\nexport class EditablePathLayer extends PathLayer<any, EditablePathLayerProps> {\n getShaders() {\n const shaders = super.getShaders();\n\n shaders.vs = insertBefore(\n shaders.vs,\n 'vec3 width;',\n `\n if(bool(picking.isActive)){\n widthPixels.xy += pickingLineWidth.extraPixels;\n }\n `\n );\n\n return {\n ...shaders,\n modules: [...shaders.modules, pickingUniforms]\n };\n }\n\n draw(props) {\n const {pickingLineWidthExtraPixels} = this.props;\n const pickingProps: PickingLineWidthProps = {extraPixels: pickingLineWidthExtraPixels};\n const model = this.state.model;\n model.shaderInputs.setProps({pickingLineWidth: pickingProps});\n super.draw(props);\n }\n}\n\nEditablePathLayer.defaultProps = defaultProps;\nEditablePathLayer.layerName = 'EditablePathLayer';\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {DefaultProps} from '@deck.gl/core';\nimport {H3ClusterLayer} from '@deck.gl/geo-layers';\n// TODO: Fix H3 support.\n// import { polyfill, geoToH3 } from 'h3-js';\nimport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from '../constants';\nimport {EditableGeoJsonLayer} from './editable-geojson-layer';\nimport {EditableLayer, EditableLayerProps} from './editable-layer';\nimport {ViewMode} from '../edit-modes/view-mode';\n\nconst DEFAULT_EDIT_MODE = ViewMode;\nconst DEFAULT_H3_RESOLUTION = 9;\nconst EMPTY_FEATURE_COLLECTION = {\n type: 'FeatureCollection',\n features: []\n};\n\nexport type EditableH3ClusterLayerProps<DataT> = EditableLayerProps & {\n data: DataT;\n resolution?: number;\n mode?: any;\n modeConfig?: any;\n selectedIndexes?: number[];\n getEditedCluster?: (updatedHexagons: any[], existingCluster: any) => any;\n getHexagons?: (d) => number[];\n onEdit?: (updatedData?, editType?: string, featureIndexes?: number[], editContext?) => void;\n filled?: boolean;\n stroked?: boolean;\n lineWidthScale?: number;\n lineWidthMinPixels?: number;\n lineWidthMaxPixels?: number;\n lineWidthUnits?: string;\n};\n\nconst defaultProps: DefaultProps<EditableH3ClusterLayerProps<any>> = {\n mode: DEFAULT_EDIT_MODE,\n\n ...EditableGeoJsonLayer.defaultProps,\n\n // h3 layer\n data: [],\n selectedIndexes: [],\n filled: false,\n stroked: true,\n lineWidthScale: PROJECTED_PIXEL_SIZE_MULTIPLIER,\n lineWidthMinPixels: 1,\n lineWidthMaxPixels: Number.MAX_SAFE_INTEGER,\n lineWidthUnits: 'pixels',\n getHexagons: (d) => d.hexIds,\n getEditedCluster: (updatedHexagons, existingCluster) => {\n if (existingCluster) {\n return {\n ...existingCluster,\n hexIds: updatedHexagons\n };\n }\n return {\n hexIds: updatedHexagons\n };\n },\n resolution: DEFAULT_H3_RESOLUTION\n};\n\nexport class EditableH3ClusterLayer extends EditableLayer<any, EditableH3ClusterLayerProps<any>> {\n static layerName = 'EditableH3ClusterLayer';\n static defaultProps = defaultProps;\n\n state: EditableLayer['state'] & {\n cursor?: 'grabbing' | 'grab' | null;\n tentativeHexagonIDs: string[];\n } = undefined!;\n\n initializeState() {\n super.initializeState();\n\n this.setState({\n tentativeHexagonIDs: []\n });\n }\n\n // convert array of (lng, lat) coords to cluster of hexes\n getDerivedHexagonIDs(coords) {\n throw new Error('not implemented'); // TODO\n // return polyfill(coords, this.props.resolution, true);\n }\n\n // convert pair of (lng, lat) coords into single hex\n getDerivedHexagonID(coords) {\n throw new Error('not implemented'); // TODO\n // return geoToH3(coords[1], coords[0], this.props.resolution);\n }\n\n renderLayers() {\n const layers: any = [\n new EditableGeoJsonLayer(\n this.getSubLayerProps({\n id: 'editable-geojson',\n\n mode: this.props.mode,\n data: EMPTY_FEATURE_COLLECTION,\n selectedFeatureIndexes: [],\n\n onEdit: (editAction) => {\n const {editType, editContext} = editAction;\n\n switch (editType) {\n case 'updateTentativeFeature':\n // tentative feature updates, updated on every pointer move\n if (editContext.feature.geometry.type === 'Polygon') {\n const coords = editContext.feature.geometry.coordinates;\n const hexIDs = this.getDerivedHexagonIDs(coords);\n\n this.setState({tentativeHexagonIDs: hexIDs});\n } else if (editContext.feature.geometry.type === 'Point') {\n const coords = editContext.feature.geometry.coordinates;\n const hexID = this.getDerivedHexagonID(coords);\n\n this.setState({tentativeHexagonIDs: [hexID]});\n }\n break;\n case 'addFeature':\n const updatedData = [...this.props.data];\n const {modeConfig} = this.props;\n\n if (!modeConfig || !modeConfig.booleanOperation) {\n // add new h3 cluster\n updatedData.push(\n this.props.getEditedCluster(this.state.tentativeHexagonIDs, null)\n );\n } else if (this.props.selectedIndexes.length !== 1) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('booleanOperation only supported for single cluster selection');\n } else {\n // they're affecting a selected cluster\n let finalHexagonIDs: (string | number)[];\n const committedHexagonIDs = new Set<string | number>(this.getSelectedHexIDs());\n const tentativeHexagonIDs = new Set<string | number>(\n this.state.tentativeHexagonIDs\n );\n\n switch (modeConfig.booleanOperation) {\n case 'union':\n default:\n finalHexagonIDs = [\n ...new Set([...committedHexagonIDs, ...tentativeHexagonIDs])\n ];\n break;\n case 'intersection':\n finalHexagonIDs = [...committedHexagonIDs].filter((hexID: string | number) =>\n tentativeHexagonIDs.has(hexID)\n );\n break;\n case 'difference':\n finalHexagonIDs = [...committedHexagonIDs].filter(\n (hexID: string | number) => !tentativeHexagonIDs.has(hexID)\n );\n break;\n }\n\n const selectedIndex = this.props.selectedIndexes[0];\n const existingCluster = this.props.data[selectedIndex];\n updatedData[selectedIndex] = this.props.getEditedCluster(\n finalHexagonIDs,\n existingCluster\n );\n }\n\n this.setState({\n tentativeHexagonIDs: []\n });\n\n this.props.onEdit({updatedData});\n\n break;\n default:\n break;\n }\n }\n })\n ),\n\n new H3ClusterLayer(\n this.getSubLayerProps({\n id: 'hexagons',\n data: this.props.data,\n getHexagons: this.props.getHexagons\n })\n ),\n new H3ClusterLayer(\n this.getSubLayerProps({\n id: 'tentative-hexagons',\n data: [\n {\n hexIds: this.state.tentativeHexagonIDs\n }\n ],\n getHexagons: (d) => d.hexIds\n })\n )\n ];\n return layers;\n }\n\n // because data is an array of hexagon data, we take the cumulative of all selected indexes,\n // using props.getHexagons to support multiple data types\n getSelectedHexIDs() {\n let cumulativeHexIDs: number[] = [];\n this.props.selectedIndexes.forEach((index) => {\n const selectedCluster = this.props.data[index];\n const hexIDs = this.props.getHexagons(selectedCluster);\n cumulativeHexIDs = cumulativeHexIDs.concat(hexIDs);\n });\n return cumulativeHexIDs;\n }\n\n getCursor({isDragging}: {isDragging: boolean}): 'grabbing' | 'grab' {\n let {cursor} = this.state || {};\n if (!cursor) {\n // default cursor\n cursor = isDragging ? 'grabbing' : 'grab';\n }\n return cursor;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {CompositeLayerProps, DefaultProps} from '@deck.gl/core';\nimport {CompositeLayer} from '@deck.gl/core';\nimport {PolygonLayer} from '@deck.gl/layers';\nimport {polygon} from '@turf/helpers';\nimport turfBuffer from '@turf/buffer';\nimport turfDifference from '@turf/difference';\n\nimport {EditableGeoJsonLayer} from './editable-geojson-layer';\nimport {DrawRectangleMode} from '../edit-modes/draw-rectangle-mode';\nimport {DrawPolygonMode} from '../edit-modes/draw-polygon-mode';\nimport {ViewMode} from '../edit-modes/view-mode';\n\nexport const SELECTION_TYPE = {\n NONE: null,\n RECTANGLE: 'rectangle',\n POLYGON: 'polygon'\n};\n\nconst MODE_MAP = {\n [SELECTION_TYPE.RECTANGLE]: DrawRectangleMode,\n [SELECTION_TYPE.POLYGON]: DrawPolygonMode\n};\n\nconst MODE_CONFIG_MAP = {\n [SELECTION_TYPE.RECTANGLE]: {dragToDraw: true}\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ninterface SelectionLayerProps<DataT> extends CompositeLayerProps {\n layerIds: any[];\n onSelect: (info: any) => any;\n selectionType: string | null;\n}\n\nconst defaultProps: DefaultProps<SelectionLayerProps<any>> = {\n selectionType: SELECTION_TYPE.RECTANGLE,\n layerIds: [],\n onSelect: () => {}\n};\n\nconst EMPTY_DATA = {\n type: 'FeatureCollection',\n features: []\n};\n\nconst EXPANSION_KM = 50;\nconst LAYER_ID_GEOJSON = 'selection-geojson';\nconst LAYER_ID_BLOCKER = 'selection-blocker';\n\nconst PASS_THROUGH_PROPS = [\n 'lineWidthScale',\n 'lineWidthMinPixels',\n 'lineWidthMaxPixels',\n 'lineWidthUnits',\n 'lineJointRounded',\n 'lineCapRounded',\n 'lineMiterLimit',\n 'pointRadiusScale',\n 'pointRadiusMinPixels',\n 'pointRadiusMaxPixels',\n 'lineDashJustified',\n 'getLineColor',\n 'getFillColor',\n 'getRadius',\n 'getLineWidth',\n 'getLineDashArray',\n 'getTentativeLineDashArray',\n 'getTentativeLineColor',\n 'getTentativeFillColor',\n 'getTentativeLineWidth'\n];\nexport class SelectionLayer<DataT, ExtraPropsT> extends CompositeLayer<\n ExtraPropsT & Required<SelectionLayerProps<DataT>>\n> {\n static layerName = 'SelectionLayer';\n static defaultProps = defaultProps;\n\n state: {\n pendingPolygonSelection: {\n bigPolygon: ReturnType<typeof turfDifference>;\n };\n } = undefined!;\n\n _selectRectangleObjects(coordinates: any) {\n const {layerIds, onSelect} = this.props;\n const [x1, y1] = this.context.viewport.project(coordinates[0][0]);\n const [x2, y2] = this.context.viewport.project(coordinates[0][2]);\n const pickingInfos = this.context.deck.pickObjects({\n x: Math.min(x1, x2),\n y: Math.min(y1, y2),\n width: Math.abs(x2 - x1),\n height: Math.abs(y2 - y1),\n layerIds\n });\n\n onSelect({pickingInfos});\n }\n\n _selectPolygonObjects(coordinates: any) {\n const {layerIds, onSelect} = this.props;\n const mousePoints = coordinates[0].map((c) => this.context.viewport.project(c));\n\n const allX = mousePoints.map((mousePoint) => mousePoint[0]);\n const allY = mousePoints.map((mousePoint) => mousePoint[1]);\n const x = Math.min(...allX);\n const y = Math.min(...allY);\n const maxX = Math.max(...allX);\n const maxY = Math.max(...allY);\n\n // Use a polygon to hide the outside, because pickObjects()\n // does not support polygons\n const landPointsPoly = polygon(coordinates);\n const bigBuffer = turfBuffer(landPointsPoly, EXPANSION_KM);\n let bigPolygon;\n try {\n // turfDifference throws an exception if the polygon\n // intersects with itself (TODO: check if true in all versions)\n bigPolygon = turfDifference(bigBuffer, landPointsPoly);\n } catch (e) {\n // invalid selection polygon\n console.log('turfDifference() error', e); // eslint-disable-line\n return;\n }\n\n this.setState({\n pendingPolygonSelection: {\n bigPolygon\n }\n });\n\n const blockerId = `${this.props.id}-${LAYER_ID_BLOCKER}`;\n\n // HACK, find a better way\n setTimeout(() => {\n const pickingInfos = this.context.deck.pickObjects({\n x,\n y,\n width: maxX - x,\n height: maxY - y,\n layerIds: [blockerId, ...layerIds]\n });\n\n onSelect({\n pickingInfos: pickingInfos.filter((item) => item.layer.id !== this.props.id)\n });\n }, 250);\n }\n\n renderLayers() {\n const {pendingPolygonSelection} = this.state;\n\n const mode = MODE_MAP[this.props.selectionType] || ViewMode;\n const modeConfig = MODE_CONFIG_MAP[this.props.selectionType];\n\n const inheritedProps = {};\n PASS_THROUGH_PROPS.forEach((p) => {\n if (this.props[p] !== undefined) inheritedProps[p] = this.props[p];\n });\n\n const layers: any[] = [\n new EditableGeoJsonLayer(\n this.getSubLayerProps({\n id: LAYER_ID_GEOJSON,\n pickable: true,\n mode,\n modeConfig,\n selectedFeatureIndexes: [],\n data: EMPTY_DATA,\n onEdit: ({updatedData, editType}) => {\n if (editType === 'addFeature') {\n const {coordinates} = updatedData.features[0].geometry;\n\n if (this.props.selectionType === SELECTION_TYPE.RECTANGLE) {\n this._selectRectangleObjects(coordinates);\n } else if (this.props.selectionType === SELECTION_TYPE.POLYGON) {\n this._selectPolygonObjects(coordinates);\n }\n }\n },\n ...inheritedProps\n })\n )\n ];\n\n if (pendingPolygonSelection) {\n const {bigPolygon} = pendingPolygonSelection as any;\n layers.push(\n new PolygonLayer(\n this.getSubLayerProps({\n id: LAYER_ID_BLOCKER,\n pickable: true,\n stroked: false,\n opacity: 1.0,\n data: [bigPolygon],\n getLineColor: (obj) => [0, 0, 0, 1],\n getFillColor: (obj) => [0, 0, 0, 1],\n getPolygon: (o) => o.geometry.coordinates\n })\n )\n );\n }\n\n return layers;\n }\n\n shouldUpdateState({changeFlags: {stateChanged, propsOrDataChanged}}: Record<string, any>) {\n return stateChanged || propsOrDataChanged;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport {CompositeLayer} from '@deck.gl/core';\nimport {ScatterplotLayer, LineLayer} from '@deck.gl/layers';\n\nconst defaultProps = {};\n\nexport class ElevatedEditHandleLayer extends CompositeLayer<any> {\n static layerName = 'ElevatedEditHandleLayer';\n static defaultProps = defaultProps;\n renderLayers() {\n const handles = new ScatterplotLayer(\n Object.assign({}, this.props, {\n id: `${this.props.id}-ScatterplotLayer`,\n data: this.props.data\n })\n );\n\n const lines = new LineLayer(\n Object.assign({}, this.props, {\n id: `${this.props.id}-LineLayer`,\n data: this.props.data,\n pickable: false,\n getSourcePosition: ({position}) => [position[0], position[1], 0],\n getTargetPosition: ({position}) => [position[0], position[1], position[2] || 0],\n getColor: [150, 150, 150, 200],\n getStrokeWidth: 3\n })\n );\n\n return [handles, lines];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport nearestPointOnLine from '@turf/nearest-point-on-line';\nimport {point, lineString as toLineString} from '@turf/helpers';\nimport circle from '@turf/circle';\nimport distance from '@turf/distance';\nimport turfCenter from '@turf/center';\nimport {\n recursivelyTraverseNestedArrays,\n nearestPointOnProjectedLine,\n getPickedEditHandles,\n getPickedEditHandle,\n NearestPointType\n} from './utils';\nimport {LineString, Point, FeatureCollection, FeatureOf} from '../utils/geojson-types';\nimport {Viewport} from '../utils/types';\nimport {\n ModeProps,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n EditHandleFeature,\n GuideFeatureCollection,\n GuideFeature\n} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ResizeCircleMode extends GeoJsonEditMode {\n _selectedEditHandle: EditHandleFeature | null | undefined;\n _isResizing = false;\n\n // eslint-disable-next-line complexity\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const handles: GuideFeature[] = [];\n const selectedFeatureIndexes = props.selectedIndexes;\n\n const {lastPointerMoveEvent} = props;\n const picks = lastPointerMoveEvent && lastPointerMoveEvent.picks;\n const mapCoords = lastPointerMoveEvent && lastPointerMoveEvent.mapCoords;\n\n // intermediate edit handle\n if (\n picks &&\n picks.length &&\n mapCoords &&\n selectedFeatureIndexes.length === 1 &&\n !this._isResizing\n ) {\n const featureAsPick = picks.find((pick) => !pick.isGuide);\n\n // is the feature in the pick selected\n if (\n featureAsPick &&\n featureAsPick.object.properties.shape &&\n featureAsPick.object.properties.shape.includes('Circle') &&\n props.selectedIndexes.includes(featureAsPick.index)\n ) {\n let intermediatePoint: NearestPointType | null = null;\n let positionIndexPrefix: number[] = [];\n const referencePoint = point(mapCoords);\n // process all lines of the (single) feature\n recursivelyTraverseNestedArrays(\n featureAsPick.object.geometry.coordinates,\n [],\n (lineString, prefix) => {\n const lineStringFeature = toLineString(lineString);\n const candidateIntermediatePoint = this.getNearestPoint(\n // @ts-expect-error turf types too wide\n lineStringFeature,\n referencePoint,\n props.modeConfig && props.modeConfig.viewport\n );\n if (\n !intermediatePoint ||\n candidateIntermediatePoint.properties.dist < intermediatePoint.properties.dist\n ) {\n intermediatePoint = candidateIntermediatePoint;\n positionIndexPrefix = prefix;\n }\n }\n );\n // tack on the lone intermediate point to the set of handles\n if (intermediatePoint) {\n const {\n geometry: {coordinates: position},\n properties: {index}\n } = intermediatePoint;\n handles.push({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'intermediate',\n featureIndex: featureAsPick.index,\n positionIndexes: [...positionIndexPrefix, index + 1]\n },\n geometry: {\n type: 'Point',\n coordinates: position\n }\n });\n }\n }\n }\n\n return {\n type: 'FeatureCollection',\n features: handles\n };\n }\n\n // turf.js does not support elevation for nearestPointOnLine\n getNearestPoint(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport | null | undefined\n ): NearestPointType {\n const {coordinates} = line.geometry;\n if (coordinates.some((coord) => coord.length > 2)) {\n if (viewport) {\n // This line has elevation, we need to use alternative algorithm\n return nearestPointOnProjectedLine(line, inPoint, viewport);\n }\n // eslint-disable-next-line no-console,no-undef\n console.log(\n 'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'\n );\n }\n // @ts-expect-error turf types diff\n return nearestPointOnLine(line, inPoint);\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n\n if (editHandle) {\n // Cancel map panning if pointer went down on an edit handle\n event.cancelPan();\n\n const editHandleProperties = editHandle.properties;\n\n const feature = this.getSelectedFeature(props);\n // @ts-expect-error turf types diff\n const center = turfCenter(feature).geometry.coordinates;\n const numberOfSteps = Object.entries(feature.geometry.coordinates[0]).length - 1;\n const radius = Math.max(distance(center, event.mapCoords), 0.001);\n\n const {steps = numberOfSteps} = {};\n const options = {steps};\n const updatedFeature = circle(center, radius, options);\n const geometry = updatedFeature.geometry;\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replaceGeometry(editHandleProperties.featureIndex, geometry)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'unionGeometry',\n editContext: {\n featureIndexes: [editHandleProperties.featureIndex]\n }\n });\n }\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n if (!this._isResizing) {\n const selectedEditHandle = getPickedEditHandle(event.picks);\n this._selectedEditHandle =\n selectedEditHandle && selectedEditHandle.properties.editHandleType === 'intermediate'\n ? selectedEditHandle\n : null;\n }\n\n const cursor = this.getCursor(event);\n props.onUpdateCursor(cursor);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n event.cancelPan();\n this._isResizing = true;\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._isResizing) {\n this._selectedEditHandle = null;\n this._isResizing = false;\n }\n }\n\n getCursor(event: PointerMoveEvent): string | null | undefined {\n const picks = (event && event.picks) || [];\n\n const handlesPicked = getPickedEditHandles(picks);\n if (handlesPicked.length) {\n return 'cell';\n }\n return null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Position, LineString, FeatureCollection} from '../utils/geojson-types';\nimport {ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ExtendLineStringMode extends GeoJsonEditMode {\n getSingleSelectedLineString(props: ModeProps<FeatureCollection>): LineString | null | undefined {\n const selectedGeometry = this.getSelectedGeometry(props);\n\n if (selectedGeometry && selectedGeometry.type === 'LineString') {\n return selectedGeometry;\n }\n return null;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {selectedIndexes} = props;\n const selectedLineString = this.getSingleSelectedLineString(props);\n\n if (!selectedLineString) {\n console.warn(`ExtendLineStringMode only supported for single LineString selection`); // eslint-disable-line\n return;\n }\n\n // Extend the LineString\n let positionIndexes = [selectedLineString.coordinates.length];\n\n const modeConfig = props.modeConfig;\n if (modeConfig && modeConfig.drawAtFront) {\n positionIndexes = [0];\n }\n const featureIndex = selectedIndexes[0];\n const updatedData = new ImmutableFeatureCollection(props.data)\n .addPosition(featureIndex, positionIndexes, event.mapCoords)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'addPosition',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: event.mapCoords\n }\n });\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n const selectedLineString = this.getSingleSelectedLineString(props);\n if (!selectedLineString) {\n return guides;\n }\n\n const mapCoords = props.lastPointerMoveEvent && props.lastPointerMoveEvent.mapCoords;\n\n if (!mapCoords) {\n return guides;\n }\n\n // Draw an extension line starting from one end of the selected LineString to the cursor\n let startPosition: Position | null | undefined = null;\n const {modeConfig} = props;\n if (modeConfig && modeConfig.drawAtFront) {\n startPosition = selectedLineString.coordinates[0];\n } else {\n startPosition = selectedLineString.coordinates[selectedLineString.coordinates.length - 1];\n }\n\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [startPosition, mapCoords]\n }\n });\n\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfDistance from '@turf/distance';\nimport turfMidpoint from '@turf/midpoint';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n Tooltip,\n GuideFeature\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class MeasureDistanceMode extends GeoJsonEditMode {\n _isMeasuringSessionFinished = false;\n _currentTooltips: Tooltip[] = [];\n _currentDistance = 0;\n\n _calculateDistanceForTooltip = ({positionA, positionB, modeConfig}) => {\n const {turfOptions, measurementCallback} = modeConfig || {};\n const distance = turfDistance(positionA, positionB, turfOptions);\n\n if (measurementCallback) {\n measurementCallback(distance);\n }\n\n return distance;\n };\n\n _formatTooltip(distance, modeConfig?) {\n const {formatTooltip, turfOptions} = modeConfig || {};\n const units = (turfOptions && turfOptions.units) || 'kilometers';\n\n let text;\n if (formatTooltip) {\n text = formatTooltip(distance);\n } else {\n // By default, round to 2 decimal places and append units\n text = `${parseFloat(distance).toFixed(2)} ${units}`;\n }\n\n return text;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {modeConfig, data, onEdit} = props;\n const {centerTooltipsOnLine = false} = modeConfig || {};\n\n // restart measuring session\n if (this._isMeasuringSessionFinished) {\n this._isMeasuringSessionFinished = false;\n this.resetClickSequence();\n this._currentTooltips = [];\n this._currentDistance = 0;\n }\n\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n\n let positionAdded = false;\n if (!clickedEditHandle) {\n // Don't add another point right next to an existing one\n this.addClickSequence(event);\n positionAdded = true;\n }\n const clickSequence = this.getClickSequence();\n\n if (\n clickSequence.length > 1 &&\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1\n ) {\n // They clicked the last point (or double-clicked), so add the LineString\n this._isMeasuringSessionFinished = true;\n } else if (positionAdded) {\n if (clickSequence.length > 1) {\n this._currentDistance += this._calculateDistanceForTooltip({\n positionA: clickSequence[clickSequence.length - 2],\n positionB: clickSequence[clickSequence.length - 1],\n modeConfig\n });\n\n const tooltipPosition = centerTooltipsOnLine\n ? turfMidpoint(\n clickSequence[clickSequence.length - 2],\n clickSequence[clickSequence.length - 1]\n ).geometry.coordinates\n : event.mapCoords;\n\n this._currentTooltips.push({\n position: tooltipPosition,\n text: this._formatTooltip(this._currentDistance, modeConfig)\n });\n }\n\n // new tentative point\n onEdit({\n // data is the same\n updatedData: data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n if (this._isMeasuringSessionFinished) return;\n\n event.stopPropagation();\n const {key} = event;\n\n const clickSequenceLength = this.getClickSequence().length;\n\n switch (key) {\n case 'Escape':\n this._isMeasuringSessionFinished = true;\n if (clickSequenceLength === 1) {\n this.resetClickSequence();\n this._currentTooltips = [];\n }\n // force update drawings\n props.onUpdateCursor('cell');\n break;\n case 'Enter':\n this.handleClick(props.lastPointerMoveEvent, props);\n this._isMeasuringSessionFinished = true;\n break;\n default:\n break;\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords =\n lastPointerMoveEvent && !this._isMeasuringSessionFinished\n ? [lastPointerMoveEvent.mapCoords]\n : [];\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length > 0) {\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, ...lastCoords]\n }\n });\n }\n\n const editHandles: GuideFeature[] = clickSequence.map((clickedCoord, index) => ({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'existing',\n featureIndex: -1,\n positionIndexes: [index]\n },\n geometry: {\n type: 'Point',\n coordinates: clickedCoord\n }\n }));\n\n guides.features.push(...editHandles);\n\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n const {lastPointerMoveEvent, modeConfig} = props;\n const {centerTooltipsOnLine = false} = modeConfig || {};\n const positions = this.getClickSequence();\n\n if (positions.length > 0 && lastPointerMoveEvent && !this._isMeasuringSessionFinished) {\n const distance = this._calculateDistanceForTooltip({\n positionA: positions[positions.length - 1],\n positionB: lastPointerMoveEvent.mapCoords,\n modeConfig: props.modeConfig\n });\n\n const tooltipPosition = centerTooltipsOnLine\n ? turfMidpoint(positions[positions.length - 1], lastPointerMoveEvent.mapCoords).geometry\n .coordinates\n : lastPointerMoveEvent.mapCoords;\n\n return [\n ...this._currentTooltips,\n {\n position: tooltipPosition,\n text: this._formatTooltip(this._currentDistance + distance, modeConfig)\n }\n ];\n }\n\n return this._currentTooltips;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfArea from '@turf/area';\nimport turfCentroid from '@turf/centroid';\nimport {ClickEvent, Tooltip, ModeProps} from './types';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {DrawPolygonMode} from './draw-polygon-mode';\n\nconst DEFAULT_TOOLTIPS = [];\n\nexport class MeasureAreaMode extends DrawPolygonMode {\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const propsWithoutEdit = {\n ...props,\n onEdit: () => {}\n };\n\n super.handleClick(event, propsWithoutEdit);\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>): void {\n const propsWithoutEdit = {\n ...props,\n onEdit: () => {}\n };\n\n super.handleKeyUp(event, propsWithoutEdit);\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n const tentativeGuide = this.getTentativeGuide(props);\n\n if (tentativeGuide && tentativeGuide.geometry.type === 'Polygon') {\n const {modeConfig} = props;\n const {formatTooltip, measurementCallback} = modeConfig || {};\n const units = 'sq. m';\n\n const centroid = turfCentroid(tentativeGuide);\n const area = turfArea(tentativeGuide);\n\n let text: string;\n if (formatTooltip) {\n text = formatTooltip(area);\n } else {\n // By default, round to 2 decimal places and append units\n // @ts-expect-error are isn't string\n text = `${parseFloat(area).toFixed(2)} ${units}`;\n }\n\n if (measurementCallback) {\n measurementCallback(area);\n }\n\n return [\n {\n position: centroid.geometry.coordinates,\n text\n }\n ];\n }\n return DEFAULT_TOOLTIPS;\n }\n}\n", "import turfBearing from '@turf/bearing';\nimport turfCenter from '@turf/center';\nimport {memoize} from '../utils/memoize';\n\nimport {ClickEvent, PointerMoveEvent, Tooltip, ModeProps, GuideFeatureCollection} from './types';\nimport {FeatureCollection, Position} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nconst DEFAULT_TOOLTIPS: Tooltip[] = [];\n\nexport class MeasureAngleMode extends GeoJsonEditMode {\n _getTooltips = memoize(\n ({\n modeConfig,\n vertex,\n point1,\n point2\n }: {\n modeConfig: any;\n vertex: any;\n point1: Position;\n point2: Position;\n }): Tooltip[] => {\n let tooltips = DEFAULT_TOOLTIPS;\n\n if (vertex && point1 && point2) {\n const {formatTooltip, measurementCallback} = modeConfig || {};\n const units = 'deg';\n\n const angle1 = turfBearing(vertex, point1);\n const angle2 = turfBearing(vertex, point2);\n let angle = Math.abs(angle1 - angle2);\n if (angle > 180) {\n angle = 360 - angle;\n }\n\n let text: string;\n if (formatTooltip) {\n text = formatTooltip(angle);\n } else {\n // By default, round to 2 decimal places and append units\n // @ts-expect-error angle isn't string\n text = `${parseFloat(angle).toFixed(2)} ${units}`;\n }\n\n if (measurementCallback) {\n measurementCallback(angle);\n }\n\n const position = turfCenter({\n type: 'FeatureCollection',\n features: [point1, point2].map((p) => ({\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: p\n },\n properties: {}\n }))\n }).geometry.coordinates;\n\n tooltips = [{position, text}];\n }\n\n return tooltips;\n }\n );\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {\n if (this.getClickSequence().length >= 3) {\n this.resetClickSequence();\n }\n\n this.addClickSequence(event);\n }\n\n // Called when the pointer moved, regardless of whether the pointer is down, up, and whether something was picked\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n props.onUpdateCursor('cell');\n }\n\n getPoints(props: ModeProps<FeatureCollection>): Position[] {\n const clickSequence = this.getClickSequence();\n\n const points = [...clickSequence];\n\n if (clickSequence.length < 3 && props.lastPointerMoveEvent) {\n points.push(props.lastPointerMoveEvent.mapCoords);\n }\n\n return points;\n }\n\n // Return features that can be used as a guide for editing the data\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const guides: GuideFeatureCollection = {type: 'FeatureCollection', features: []};\n const {features} = guides;\n\n const points = this.getPoints(props);\n\n if (points.length > 2) {\n features.push({\n type: 'Feature',\n properties: {guideType: 'tentative'},\n geometry: {\n type: 'LineString',\n coordinates: [points[1], points[0], points[2]]\n }\n });\n } else if (points.length > 1) {\n features.push({\n type: 'Feature',\n properties: {guideType: 'tentative'},\n geometry: {\n type: 'LineString',\n coordinates: [points[1], points[0]]\n }\n });\n }\n\n return guides;\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n const points = this.getPoints(props);\n\n return this._getTooltips({\n modeConfig: props.modeConfig,\n vertex: points[0],\n point1: points[1],\n point2: points[2]\n }) as Tooltip[];\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACKO,IAAM,cAAc;EACzB,MAAM;EACN,SAAS;EACT,UAAU;EACV,MAAM;;AAGD,IAAM,iBAAiB;AACvB,IAAM,aAAa;AAEnB,IAAM,gBAAgB;EAC3B,YAAY,CAAC,GAAG,GAAG,GAAG,CAAC;EACvB,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O,SAAS,GAAG;AACrB,eAAS,KAAK;QACZ,MAAM;QACN,YAAY,EAAC,WAAW,YAAW;QACnC,UAAU;UACR,MAAM;UACN,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;;OAEhD;IACH,WAAW,OAAO,SAAS,GAAG;AAC5B,eAAS,KAAK;QACZ,MAAM;QACN,YAAY,EAAC,WAAW,YAAW;QACnC,UAAU;UACR,MAAM;UACN,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;;OAErC;IACH;AAEA,WAAO;EACT;EAEA,YAAY,OAAmC;AAC7C,UAAM,SAAS,KAAK,UAAU,KAAK;AAEnC,WAAO,KAAK,aAAa;MACvB,YAAY,MAAM;MAClB,QAAQ,OAAO,CAAC;MAChB,QAAQ,OAAO,CAAC;MAChB,QAAQ,OAAO,CAAC;KACjB;EACH;;",
6
- "names": ["turfDistance", "turfBuffer", "turfBboxPolygon", "turfBbox", "turfDifference", "import_helpers", "mapCoords", "lineString", "pointToLineDistance", "bearing", "destination", "x", "y", "x2", "y2", "index", "x1", "y1", "distance", "import_layers", "import_layers", "import_layers", "import_eventemitter3", "import_core", "import_layers", "import_difference", "import_destination", "import_bearing", "import_point_to_line_distance", "import_helpers", "import_viewport_mercator_project", "recursivelyTraverseNestedArrays", "generatePointsParallelToLinePoints", "lineString", "pointToLineDistance", "bearing", "destination", "distance2d", "mix", "nearestPointOnProjectedLine", "x", "y", "x2", "y2", "index", "x1", "y1", "distance", "featureCollection", "polygon", "lineString", "mapCoords", "rewind", "turfUnion", "turfDifference", "turfIntersect", "import_bearing", "import_distance", "import_helpers", "import_viewport_mercator_project", "distance", "turfCenter", "turfRhumbDestination", "turfRhumbDistance", "turfRhumbBearing", "turfDistance", "turfBearing", "clone", "import_helpers", "mapCoords", "recursivelyTraverseNestedArrays", "lineString", "toLineString", "nearestPointOnProjectedLine", "import_bbox", "import_bearing", "import_bbox_polygon", "import_helpers", "import_meta", "import_distance", "import_invariant", "turfTransformScale", "turfCentroid", "bearing", "turfBearing", "bboxPolygon", "bbox", "turfDistance", "import_bbox", "import_centroid", "import_bearing", "import_bbox_polygon", "import_distance", "import_meta", "import_invariant", "import_helpers", "import_polygon_to_line", "turfCentroid", "bboxPolygon", "bbox", "turfDistance", "turfTransformRotate", "turfBearing", "bearing2", "import_difference", "import_buffer", "import_helpers", "import_bearing", "import_distance", "import_destination", "import_polygon_to_line", "mapCoords", "turfPolygonToLine", "nearestPointOnLine", "turfDistance", "turfBearing", "turfDestination", "generatePointsParallelToLinePoints", "booleanPointInPolygon", "lineIntersect", "turfBuffer", "turfDifference", "import_bearing", "generatePointsParallelToLinePoints", "bearing", "mapCoords", "import_distance", "distance", "import_line_intersect", "import_helpers", "turfLineString", "lineIntersect", "import_bbox_polygon", "omit", "polygon", "bboxPolygon", "import_bbox_polygon", "import_distance", "import_helpers", "turfDistance", "distance2", "turfLineString", "turfAlong", "bboxPolygon", "import_bbox_polygon", "bboxPolygon", "import_bbox_polygon", "import_distance", "import_along", "import_helpers", "turfDistance", "distance2", "turfLineString", "turfAlong", "bboxPolygon", "import_distance", "distance", "circle", "area", "import_circle", "import_distance", "import_area", "distance", "circle", "area", "import_bbox_polygon", "import_distance", "import_helpers", "bboxPolygon", "distance", "ellipse", "import_lodash", "omit", "polygon", "generatePointsParallelToLinePoints", "import_distance", "import_ellipse", "import_bearing", "import_helpers", "distance", "bearing", "ellipse", "import_destination", "import_bearing", "import_line_intersect", "import_distance", "import_helpers", "mapCoords", "generatePointsParallelToLinePoints", "lineString", "polygon", "bearing", "distance", "turfDistance", "turfLineString", "destination", "lineIntersect", "import_lodash", "throttle", "import_helpers", "PROJECTED_PIXEL_SIZE_MULTIPLIER", "import_core", "mapCoords", "import_layers", "PROJECTED_PIXEL_SIZE_MULTIPLIER", "defaultProps", "DEFAULT_EDIT_MODE", "defaultProps", "PROJECTED_PIXEL_SIZE_MULTIPLIER", "import_core", "import_layers", "import_helpers", "import_buffer", "import_difference", "SELECTION_TYPE", "defaultProps", "EXPANSION_KM", "turfBuffer", "turfDifference", "import_core", "import_layers", "defaultProps", "import_nearest_point_on_line", "import_helpers", "import_circle", "import_distance", "import_center", "mapCoords", "recursivelyTraverseNestedArrays", "lineString", "toLineString", "nearestPointOnProjectedLine", "nearestPointOnLine", "turfCenter", "distance", "circle", "mapCoords", "import_distance", "distance", "turfDistance", "turfMidpoint", "import_area", "import_centroid", "DEFAULT_TOOLTIPS", "turfCentroid", "area", "turfArea", "import_bearing", "import_center", "DEFAULT_TOOLTIPS", "point2", "turfBearing", "turfCenter"]
3
+ "sources": ["../src/index.ts", "../src/lib/style.ts", "../src/lib/deck-renderer/deck-drawer.ts", "../src/lib/feature.ts", "../src/lib/layer-mouse-event.ts", "../src/lib/nebula-layer.ts", "../src/utils/utils.ts", "../src/lib/deck-renderer/deck-cache.ts", "../src/editable-layers/junction-scatterplot-layer.ts", "../src/lib/layers/junctions-layer.ts", "../src/lib/layers/texts-layer.ts", "../src/lib/constants.ts", "../../layers/src/path-marker-layer/path-marker-layer.ts", "../../layers/src/path-outline-layer/path-outline-layer.ts", "../../layers/src/path-outline-layer/outline.ts", "../../layers/src/path-marker-layer/arrow-2d-geometry.ts", "../../layers/src/path-marker-layer/create-path-markers.ts", "../../layers/src/path-marker-layer/polyline.ts", "../src/lib/layers/segments-layer.ts", "../src/lib/nebula-core.ts", "../src/editable-layers/editable-geojson-layer.ts", "../src/edit-modes/geojson-edit-mode.ts", "../src/edit-modes/utils.ts", "../src/edit-modes/immutable-feature-collection.ts", "../src/edit-modes/view-mode.ts", "../src/edit-modes/translate-mode.ts", "../src/utils/translate-from-center.ts", "../src/edit-modes/modify-mode.ts", "../src/edit-modes/scale-mode.ts", "../src/edit-modes/rotate-mode.ts", "../src/edit-modes/duplicate-mode.ts", "../src/edit-modes/split-polygon-mode.ts", "../src/edit-modes/extrude-mode.ts", "../src/edit-modes/elevation-mode.ts", "../src/edit-modes/draw-point-mode.ts", "../src/edit-modes/draw-line-string-mode.ts", "../src/utils/memoize.ts", "../src/edit-modes/draw-polygon-mode.ts", "../src/edit-modes/draw-rectangle-mode.ts", "../src/edit-modes/two-click-polygon-mode.ts", "../src/edit-modes/draw-square-mode.ts", "../src/edit-modes/draw-rectangle-from-center-mode.ts", "../src/edit-modes/draw-square-from-center-mode.ts", "../src/edit-modes/draw-circle-from-center-mode.ts", "../src/edit-modes/draw-circle-by-diameter-mode.ts", "../src/edit-modes/draw-ellipse-by-bounding-box-mode.ts", "../src/edit-modes/three-click-polygon-mode.ts", "../src/edit-modes/draw-rectangle-using-three-points-mode.ts", "../src/edit-modes/draw-ellipse-using-three-points-mode.ts", "../src/edit-modes/draw-90degree-polygon-mode.ts", "../src/edit-modes/draw-polygon-by-dragging-mode.ts", "../src/edit-modes/snappable-mode.ts", "../src/edit-modes/transform-mode.ts", "../src/edit-modes/composite-mode.ts", "../src/edit-modes/delete-mode.ts", "../src/constants.ts", "../src/editable-layers/editable-layer.ts", "../src/editable-layers/editable-path-layer.ts", "../src/editable-layers/editable-h3-cluster-layer.ts", "../src/editable-layers/selection-layer.ts", "../src/editable-layers/elevated-edit-handle-layer.ts", "../src/edit-modes/resize-circle-mode.ts", "../src/edit-modes/extend-line-string-mode.ts", "../src/edit-modes/measure-distance-mode.ts", "../src/edit-modes/measure-area-mode.ts", "../src/edit-modes/measure-angle-mode.ts"],
4
+ "sourcesContent": ["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {ArrowStyles, DEFAULT_ARROWS, MAX_ARROWS} from './lib/style';\nexport {SELECTION_TYPE} from './lib/deck-renderer/deck-drawer';\n\nexport {Feature} from './lib/feature';\nexport {LayerMouseEvent} from './lib/layer-mouse-event';\n\nexport {NebulaLayer} from './lib/nebula-layer';\nexport {JunctionsLayer} from './lib/layers/junctions-layer';\nexport {TextsLayer} from './lib/layers/texts-layer';\nexport {SegmentsLayer} from './lib/layers/segments-layer';\n\nexport {NebulaCore} from './lib/nebula-core';\n\nexport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from './lib/constants';\n\n// Utils\nexport {toDeckColor} from './utils/utils';\n\n// Types\nexport type {Color, Style, Viewport} from './utils/types';\n\n// Layers\nexport {EditableGeoJsonLayer} from './editable-layers/editable-geojson-layer';\nexport {EditableH3ClusterLayer} from './editable-layers/editable-h3-cluster-layer';\nexport {SelectionLayer} from './editable-layers/selection-layer';\nexport {ElevatedEditHandleLayer} from './editable-layers/elevated-edit-handle-layer';\n\n// Layers move to deck.gl-community/layers?\nexport {JunctionScatterplotLayer} from './editable-layers/junction-scatterplot-layer';\n\n// Types\n\nimport * as utils from './utils/utils';\n\nexport {utils};\n\nexport {getPickedEditHandle, getEditHandlesForGeometry} from './edit-modes/utils';\n\nexport type {EditMode} from './edit-modes/edit-mode';\nexport type {GeoJsonEditModeType} from './edit-modes/geojson-edit-mode';\nexport type {GeoJsonEditModeConstructor} from './edit-modes/geojson-edit-mode';\n\nexport type {EditableGeoJsonLayerProps} from './editable-layers/editable-geojson-layer';\n\nexport {GeoJsonEditMode} from './edit-modes/geojson-edit-mode';\n\n// Alter modes\nexport {ModifyMode} from './edit-modes/modify-mode';\nexport {ResizeCircleMode} from './edit-modes/resize-circle-mode';\nexport {TranslateMode} from './edit-modes/translate-mode';\nexport {ScaleMode} from './edit-modes/scale-mode';\nexport {RotateMode} from './edit-modes/rotate-mode';\nexport {DuplicateMode} from './edit-modes/duplicate-mode';\nexport {ExtendLineStringMode} from './edit-modes/extend-line-string-mode';\nexport {SplitPolygonMode} from './edit-modes/split-polygon-mode';\nexport {ExtrudeMode} from './edit-modes/extrude-mode';\nexport {ElevationMode} from './edit-modes/elevation-mode';\nexport {TransformMode} from './edit-modes/transform-mode';\n\n// Draw modes\nexport {DrawPointMode} from './edit-modes/draw-point-mode';\nexport {DrawLineStringMode} from './edit-modes/draw-line-string-mode';\nexport {DrawPolygonMode} from './edit-modes/draw-polygon-mode';\nexport {DrawRectangleMode} from './edit-modes/draw-rectangle-mode';\nexport {DrawSquareMode} from './edit-modes/draw-square-mode';\nexport {DrawRectangleFromCenterMode} from './edit-modes/draw-rectangle-from-center-mode';\nexport {DrawSquareFromCenterMode} from './edit-modes/draw-square-from-center-mode';\nexport {DrawCircleByDiameterMode} from './edit-modes/draw-circle-by-diameter-mode';\nexport {DrawCircleFromCenterMode} from './edit-modes/draw-circle-from-center-mode';\nexport {DrawEllipseByBoundingBoxMode} from './edit-modes/draw-ellipse-by-bounding-box-mode';\nexport {DrawEllipseUsingThreePointsMode} from './edit-modes/draw-ellipse-using-three-points-mode';\nexport {DrawRectangleUsingThreePointsMode} from './edit-modes/draw-rectangle-using-three-points-mode';\nexport {Draw90DegreePolygonMode} from './edit-modes/draw-90degree-polygon-mode';\nexport {DrawPolygonByDraggingMode} from './edit-modes/draw-polygon-by-dragging-mode';\nexport {ImmutableFeatureCollection} from './edit-modes/immutable-feature-collection';\n\n// Other modes\nexport {ViewMode} from './edit-modes/view-mode';\nexport {MeasureDistanceMode} from './edit-modes/measure-distance-mode';\nexport {MeasureAreaMode} from './edit-modes/measure-area-mode';\nexport {MeasureAngleMode} from './edit-modes/measure-angle-mode';\nexport {CompositeMode} from './edit-modes/composite-mode';\nexport {SnappableMode} from './edit-modes/snappable-mode';\n\nexport type {\n ScreenCoordinates,\n EditAction,\n Pick,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps,\n GuideFeatureCollection,\n // Viewport,\n Tooltip\n} from './edit-modes/types';\n\nexport type {\n Position,\n PointCoordinates,\n LineStringCoordinates,\n PolygonCoordinates,\n MultiPointCoordinates,\n MultiLineStringCoordinates,\n MultiPolygonCoordinates,\n AnyCoordinates,\n Point,\n LineString,\n Polygon,\n MultiPoint,\n MultiLineString,\n MultiPolygon,\n Geometry,\n Polygonal,\n BoundingBoxArray,\n FeatureOf,\n FeatureWithProps,\n // Feature,\n FeatureCollection,\n AnyGeoJson\n} from './utils/geojson-types';\n\n// Experimental\nexport {memoize as _memoize} from './utils/memoize';\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Describes the arrow style of polylines\nexport const ArrowStyles = {\n NONE: 0,\n FORWARD: 1,\n BACKWARD: 2,\n BOTH: 3\n};\n\nexport const DEFAULT_ARROWS = 1;\nexport const MAX_ARROWS = 3;\n\nexport const DEFAULT_STYLE = {\n arrowColor: [0, 0, 0, 1],\n arrowCount: DEFAULT_ARROWS,\n arrowStyle: ArrowStyles.NONE,\n fillColor: [0, 0, 0, 1],\n lineColor: [0, 0, 0, 1],\n lineWidthMeters: 5,\n outlineRadiusMeters: 0,\n opacity: 1,\n zLevel: 0\n};\n", "import {PolygonLayer} from '@deck.gl/layers';\nimport {point, polygon} from '@turf/helpers';\nimport turfBbox from '@turf/bbox';\nimport turfBboxPolygon from '@turf/bbox-polygon';\nimport turfBuffer from '@turf/buffer';\nimport turfDifference from '@turf/difference';\nimport turfDistance from '@turf/distance';\n\nimport {Color} from '../../utils/types';\n\nconst POLYGON_LINE_COLOR = [0, 255, 0, 255];\nconst POLYGON_FILL_COLOR = [255, 255, 255, 90];\nconst POLYGON_LINE_WIDTH = 2;\n// const POLYGON_DASHES = [20, 20];\nconst POLYGON_THRESHOLD = 0.01;\nconst EXPANSION_KM = 10;\nconst LAYER_ID_VIEW = 'DeckDrawerView';\nconst LAYER_ID_PICK = 'DeckDrawerPick';\n\nexport const SELECTION_TYPE = {\n NONE: null,\n RECTANGLE: 'rectangle',\n POLYGON: 'polygon'\n};\n\nexport class DeckDrawer {\n nebula: Record<string, any>;\n usePolygon: boolean;\n validPolygon: boolean;\n landPoints: [number, number][];\n mousePoints: [number, number][];\n\n constructor(nebula: Record<string, any>) {\n this.nebula = nebula;\n this.usePolygon = false;\n this.validPolygon = true;\n this.landPoints = [];\n this.mousePoints = [];\n }\n\n _getLayerIds() {\n // TODO: sort by mouse priority\n return this.nebula.deckgl.props.layers\n .filter((l) => l && l.props && l.props.nebulaLayer && l.props.nebulaLayer.enableSelection)\n .map((l) => l.id);\n }\n\n _selectFromPickingInfos(pickingInfos: Record<string, any>[]) {\n const objects = pickingInfos.map(\n ({layer, index, object}) =>\n object.original || layer.props.nebulaLayer.deckCache.originals[index]\n );\n this.nebula.props.onSelection(objects);\n }\n\n _getBoundingBox(): Record<string, any> {\n const {mousePoints} = this;\n const allX = mousePoints.map((mousePoint) => mousePoint[0]);\n const allY = mousePoints.map((mousePoint) => mousePoint[1]);\n const x = Math.min(...allX);\n const y = Math.min(...allY);\n const maxX = Math.max(...allX);\n const maxY = Math.max(...allY);\n\n return {x, y, width: maxX - x, height: maxY - y};\n }\n\n _selectRectangleObjects() {\n if (this.landPoints.length !== 2) return;\n\n const [x1, y1] = this.mousePoints[0];\n const [x2, y2] = this.mousePoints[1];\n const pickingInfos = this.nebula.deckgl.pickObjects({\n x: Math.min(x1, x2),\n y: Math.min(y1, y2),\n width: Math.abs(x2 - x1),\n height: Math.abs(y2 - y1),\n layerIds: this._getLayerIds()\n });\n\n this._selectFromPickingInfos(pickingInfos);\n }\n\n _selectPolygonObjects() {\n const pickingInfos = this.nebula.deckgl.pickObjects({\n ...this._getBoundingBox(),\n layerIds: [LAYER_ID_PICK, ...this._getLayerIds()]\n });\n\n this._selectFromPickingInfos(pickingInfos.filter((item) => item.layer.id !== LAYER_ID_PICK));\n }\n\n _getMousePosFromEvent(event: Record<string, any>): [number, number] {\n const {offsetX, offsetY} = event;\n return [offsetX, offsetY];\n }\n\n // eslint-disable-next-line max-statements, complexity\n handleEvent(\n event: Record<string, any>,\n lngLat: [number, number],\n selectionType: number\n ): {redraw: boolean; deactivate: boolean} {\n // capture all events (mouse-up is needed to prevent us stuck in moving map)\n if (event.type !== 'mouseup') event.stopPropagation();\n\n // @ts-expect-error revisit selectionType type\n this.usePolygon = selectionType === SELECTION_TYPE.POLYGON;\n\n let redraw = false;\n let deactivate = false;\n\n const {usePolygon, landPoints, mousePoints} = this;\n\n if (event.type === 'mousedown') {\n if (usePolygon && landPoints.length) {\n // if landPoints.length is zero we want to insert two points (so we let it run the else)\n // also don't insert if polygon is invalid\n if (this.landPoints.length < 3 || this.validPolygon) {\n landPoints.push(lngLat);\n mousePoints.push(this._getMousePosFromEvent(event));\n }\n } else {\n this.landPoints = [lngLat, lngLat];\n const m = this._getMousePosFromEvent(event);\n this.mousePoints = [m, m];\n }\n redraw = true;\n } else if (event.type === 'mousemove' && landPoints.length) {\n // update last point\n landPoints[landPoints.length - 1] = lngLat;\n mousePoints[mousePoints.length - 1] = this._getMousePosFromEvent(event);\n redraw = true;\n } else if (event.type === 'mouseup') {\n if (usePolygon) {\n // check to see if completed\n // TODO: Maybe double-click to finish?\n if (\n landPoints.length > 4 &&\n turfDistance(landPoints[0], landPoints[landPoints.length - 1]) < POLYGON_THRESHOLD &&\n this.validPolygon\n ) {\n this._selectPolygonObjects();\n this.reset();\n redraw = true;\n deactivate = true;\n }\n } else {\n this._selectRectangleObjects();\n this.reset();\n redraw = true;\n deactivate = true;\n }\n }\n\n return {redraw, deactivate};\n }\n\n reset() {\n this.landPoints = [];\n this.mousePoints = [];\n }\n\n _makeStartPointHighlight(center: [number, number]): number[] {\n const buffer = turfBuffer(point(center), POLYGON_THRESHOLD / 4.0);\n // @ts-expect-error revisit return type\n return turfBboxPolygon(turfBbox(buffer)).geometry.coordinates;\n }\n\n render() {\n const data: any[] = [];\n const dataPick: any[] = [];\n\n if (!this.usePolygon && this.landPoints.length === 2) {\n // Use mouse points instead of land points so we get the right shape\n // no matter what bearing is.\n const [[x1, y1], [x2, y2]] = this.mousePoints;\n const selPolygon = [\n [x1, y1],\n [x1, y2],\n [x2, y2],\n [x2, y1],\n [x1, y1]\n ].map((mousePos) => this.nebula.unprojectMousePosition(mousePos));\n data.push({\n polygon: selPolygon,\n lineColor: POLYGON_LINE_COLOR,\n fillColor: POLYGON_FILL_COLOR\n });\n } else if (this.usePolygon && this.landPoints.length) {\n data.push({\n polygon: this.landPoints,\n lineColor: POLYGON_LINE_COLOR,\n fillColor: POLYGON_FILL_COLOR\n });\n\n // Hack: use a polygon to hide the outside, because pickObjects()\n // does not support polygons\n if (this.landPoints.length >= 3) {\n const landPointsPoly = polygon([[...this.landPoints, this.landPoints[0]]]);\n const bigBuffer = turfBuffer(point(this.landPoints[0]), EXPANSION_KM);\n let bigPolygon;\n try {\n // turfDifference throws an exception if the polygon\n // intersects with itself\n bigPolygon = turfDifference(bigBuffer, landPointsPoly);\n dataPick.push({\n polygon: bigPolygon.geometry.coordinates,\n fillColor: [0, 0, 0, 1]\n });\n this.validPolygon = true;\n } catch (e) {\n // invalid selection polygon\n this.validPolygon = false;\n }\n }\n }\n\n if (this.landPoints.length) {\n // highlight start point\n data.push({\n polygon: this._makeStartPointHighlight(this.landPoints[0]),\n lineColor: [0, 0, 0, 0],\n fillColor: POLYGON_LINE_COLOR\n });\n }\n\n // Hack to make the PolygonLayer() stay active,\n // otherwise it takes 3 seconds (!) to init!\n // TODO: fix this\n data.push({polygon: [[0, 0]]});\n dataPick.push({polygon: [[0, 0]]});\n\n return [\n new PolygonLayer({\n id: LAYER_ID_VIEW,\n data,\n fp64: false,\n opacity: 1.0,\n pickable: false,\n lineWidthMinPixels: POLYGON_LINE_WIDTH,\n lineWidthMaxPixels: POLYGON_LINE_WIDTH,\n lineDashJustified: true,\n // TODO(v9) Add extension\n // getLineDashArray: (x) => POLYGON_DASHES,\n getLineColor: (obj: {lineColor?: Color}) => obj.lineColor || [0, 0, 0, 255],\n getFillColor: (obj: {fillColor?: Color}) => obj.fillColor || [0, 0, 0, 255],\n getPolygon: (o: {polygon?: any}) => o.polygon\n }),\n new PolygonLayer({\n id: LAYER_ID_PICK,\n data: dataPick,\n getLineColor: (obj: {lineColor?: Color}) => obj.lineColor || [0, 0, 0, 255],\n getFillColor: (obj: {fillColor?: Color}) => obj.fillColor || [0, 0, 0, 255],\n fp64: false,\n opacity: 1.0,\n stroked: false,\n pickable: true,\n getPolygon: (o: {polygon?: any}) => o.polygon\n })\n ];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Feature as GeoJson} from '../utils/geojson-types';\n\nimport {Style} from '../utils/types';\n\nexport class Feature {\n // geo json coordinates\n geoJson: GeoJson;\n style: Style;\n original: any | null | undefined;\n metadata: Record<string, any>;\n\n constructor(\n geoJson: GeoJson,\n style: Style,\n original: any | null | undefined = null,\n metadata: Record<string, any> = {}\n ) {\n this.geoJson = geoJson;\n this.style = style;\n this.original = original;\n this.metadata = metadata;\n }\n\n getCoords() {\n return this.geoJson.geometry.coordinates;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Position} from '../utils/geojson-types';\n\nexport class LayerMouseEvent {\n canceled: boolean = false;\n // original item that this event is related to\n data: Record<string, any>;\n // internal nebula info about the object\n metadata: Record<string, any>;\n // the mouse [lng,lat] raycasted onto the ground\n groundPoint: Position;\n // browser event\n nativeEvent: MouseEvent;\n // reference to nebula\n nebula: Record<string, any>;\n\n constructor(nativeEvent: MouseEvent, {data, groundPoint, nebula, metadata}: Record<string, any>) {\n this.nativeEvent = nativeEvent;\n\n this.data = data;\n this.groundPoint = groundPoint;\n this.nebula = nebula;\n this.metadata = metadata;\n }\n\n stopPropagation() {\n this.nativeEvent.stopPropagation();\n this.canceled = true;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {EventEmitter} from 'eventemitter3';\nimport {v4} from 'uuid';\n\nimport {Feature} from './feature';\n\nexport class NebulaLayer extends EventEmitter {\n getData: () => Record<string, any>[];\n toNebulaFeature: (data: Record<string, any>) => Feature;\n id: string;\n helperLayers: Record<string, any>[];\n\n // flags\n usesMapEvents = false;\n enablePicking = false;\n enableSelection = false;\n //\n\n constructor({getData, on, toNebulaFeature}: Record<string, any>) {\n super();\n this.id = v4();\n this.getData = getData;\n this.toNebulaFeature = toNebulaFeature;\n this.helperLayers = [];\n\n if (on) {\n Object.keys(on).forEach((key) => this.on(key, on[key]));\n }\n }\n\n render(config: Record<string, any>): unknown {\n return null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport destination from '@turf/destination';\nimport bearing from '@turf/bearing';\nimport pointToLineDistance from '@turf/point-to-line-distance';\nimport {point} from '@turf/helpers';\nimport {WebMercatorViewport} from 'viewport-mercator-project';\nimport {FeatureOf, FeatureWithProps, LineString, Point, Position} from './geojson-types';\nimport {Viewport} from './types';\n\n// TODO edit-modes: delete and use edit-modes/utils instead\n\nexport type NearestPointType = FeatureWithProps<Point, {dist: number; index: number}>;\n\nexport function toDeckColor(\n color?: [number, number, number, number] | number,\n defaultColor: [number, number, number, number] = [255, 0, 0, 255]\n): [number, number, number, number] {\n if (!Array.isArray(color)) {\n return defaultColor;\n }\n return [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255];\n}\n\n//\n// a GeoJSON helper function that calls the provided function with\n// an argument that is the most deeply-nested array having elements\n// that are arrays of primitives as an argument, e.g.\n//\n// {\n// \"type\": \"MultiPolygon\",\n// \"coordinates\": [\n// [\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n// ],\n// [\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n// ]\n// ]\n// }\n//\n// the function would be called on:\n//\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n//\n// and\n//\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n//\nexport function recursivelyTraverseNestedArrays(\n array: Array<any>,\n prefix: Array<number>,\n fn: Function\n) {\n if (!Array.isArray(array[0])) {\n return true;\n }\n for (let i = 0; i < array.length; i++) {\n if (recursivelyTraverseNestedArrays(array[i], [...prefix, i], fn)) {\n fn(array, prefix);\n break;\n }\n }\n return false;\n}\n\nexport function generatePointsParallelToLinePoints(\n p1: Position,\n p2: Position,\n mapCoords: Position\n): Position[] {\n const lineString: LineString = {\n type: 'LineString',\n coordinates: [p1, p2]\n };\n const pt = point(mapCoords);\n const ddistance = pointToLineDistance(pt, lineString);\n const lineBearing = bearing(p1, p2);\n\n // Check if current point is to the left or right of line\n // Line from A=(x1,y1) to B=(x2,y2) a point P=(x,y)\n // then (x\u2212x1)(y2\u2212y1)\u2212(y\u2212y1)(x2\u2212x1)\n const isPointToLeftOfLine =\n (mapCoords[0] - p1[0]) * (p2[1] - p1[1]) - (mapCoords[1] - p1[1]) * (p2[0] - p1[0]);\n\n // Bearing to draw perpendicular to the line string\n const orthogonalBearing = isPointToLeftOfLine < 0 ? lineBearing - 90 : lineBearing - 270;\n\n // Get coordinates for the point p3 and p4 which are perpendicular to the lineString\n // Add the distance as the current position moves away from the lineString\n const p3 = destination(p2, ddistance, orthogonalBearing);\n const p4 = destination(p1, ddistance, orthogonalBearing);\n return [p3.geometry.coordinates, p4.geometry.coordinates] as [Position, Position];\n}\n\nexport function distance2d(x1: number, y1: number, x2: number, y2: number): number {\n const dx = x1 - x2;\n const dy = y1 - y2;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nexport function mix(a: number, b: number, ratio: number): number {\n return b * ratio + a * (1 - ratio);\n}\n\nexport function nearestPointOnProjectedLine(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport\n): NearestPointType {\n const wmViewport = new WebMercatorViewport(viewport);\n // Project the line to viewport, then find the nearest point\n const coordinates: Array<Array<number>> = line.geometry.coordinates as any;\n const projectedCoords = coordinates.map(([x, y, z = 0]) => wmViewport.project([x, y, z]));\n const [x, y] = wmViewport.project(inPoint.geometry.coordinates);\n // console.log('projectedCoords', JSON.stringify(projectedCoords));\n\n let minDistance = Infinity;\n let minPointInfo = {};\n\n projectedCoords.forEach(([x2, y2], index) => {\n if (index === 0) {\n return;\n }\n\n const [x1, y1] = projectedCoords[index - 1];\n\n // line from projectedCoords[index - 1] to projectedCoords[index]\n // convert to Ax + By + C = 0\n const A = y1 - y2;\n const B = x2 - x1;\n const C = x1 * y2 - x2 * y1;\n\n // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line\n const div = A * A + B * B;\n const distance = Math.abs(A * x + B * y + C) / Math.sqrt(div);\n\n // TODO: Check if inside bounds\n\n if (distance < minDistance) {\n minDistance = distance;\n minPointInfo = {\n index,\n x0: (B * (B * x - A * y) - A * C) / div,\n y0: (A * (-B * x + A * y) - B * C) / div\n };\n }\n });\n const {index, x0, y0} = minPointInfo as any;\n const [x1, y1, z1 = 0] = projectedCoords[index - 1];\n const [x2, y2, z2 = 0] = projectedCoords[index];\n\n // calculate what ratio of the line we are on to find the proper z\n const lineLength = distance2d(x1, y1, x2, y2);\n const startToPointLength = distance2d(x1, y1, x0, y0);\n const ratio = startToPointLength / lineLength;\n const z0 = mix(z1, z2, ratio);\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: wmViewport.unproject([x0, y0, z0])\n },\n properties: {\n // TODO: calculate the distance in proper units\n dist: minDistance,\n index: index - 1\n }\n };\n}\n\n/**\n * Inserts toInsert string into base string before insertBefore string.\n * @param base A string to insert into.\n * @param insertBeforeText A sub string in `base` string to insert before.\n * @param toInsert A string to insert.\n * @returns Combined string. `base` string if `insertBefore` string isn't found.\n */\nexport function insertBefore(base: string, insertBeforeText: string, toInsert: string): string {\n const at = base.indexOf(insertBeforeText);\n if (at < 0) {\n return base;\n }\n return base.slice(0, at) + toInsert + base.slice(at);\n}\n", "export class DeckCache<TORIG, TCONV> {\n objects: TCONV[];\n originals: TORIG[];\n updateTrigger: number;\n _idToPosition: Map<string, number>;\n _getData: () => TORIG[];\n _convert: (arg0: TORIG) => TCONV;\n\n constructor(getData: () => TORIG[], convert: (arg0: TORIG) => TCONV) {\n this.objects = [];\n this.originals = [];\n this.updateTrigger = 0;\n\n this._idToPosition = new Map();\n this._getData = getData;\n this._convert = convert;\n }\n\n updateAllDeckObjects() {\n if (!this._getData || !this._convert) return;\n\n this.originals.length = 0;\n this.objects.length = 0;\n this._idToPosition.clear();\n\n this._getData().forEach((d) => {\n this._idToPosition.set((d as any).id, this.objects.length);\n this.originals.push(d);\n this.objects.push(this._convert(d));\n });\n\n this.triggerUpdate();\n }\n\n updateDeckObjectsByIds(ids: string[]) {\n if (!this._getData || !this._convert) return;\n\n ids.forEach((id) => {\n const p = this._idToPosition.get(id);\n if (p !== undefined) {\n this.objects[p] = this._convert(this.originals[p]);\n }\n });\n\n this.triggerUpdate();\n }\n\n triggerUpdate() {\n this.updateTrigger++;\n }\n\n getDeckObjectById(id: string): TCONV | null | undefined {\n const p = this._idToPosition.get(id);\n return p !== undefined ? this.objects[p] : null;\n }\n\n getOriginalById(id: string): TORIG | null | undefined {\n const p = this._idToPosition.get(id);\n return p !== undefined ? this.originals[p] : null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CompositeLayerProps, DefaultProps} from '@deck.gl/core';\nimport {CompositeLayer} from '@deck.gl/core';\nimport type {ScatterplotLayerProps} from '@deck.gl/layers';\nimport {ScatterplotLayer} from '@deck.gl/layers';\n\nimport {Color} from '../utils/types';\n\ntype JunctionScatterplotLayerProps = CompositeLayerProps &\n Omit<ScatterplotLayerProps, 'getFillColor'> & {\n getFillColor?: Color | ((d) => Color);\n getStrokeColor?: Color | ((d) => Color);\n getInnerRadius?: number | ((d) => number);\n };\n\nexport class JunctionScatterplotLayer extends CompositeLayer<JunctionScatterplotLayerProps> {\n static layerName = 'JunctionScatterplotLayer';\n static defaultProps: DefaultProps<JunctionScatterplotLayerProps> = {\n ...ScatterplotLayer.defaultProps,\n getFillColor: (d) => [0, 0, 0, 255],\n getStrokeColor: (d) => [255, 255, 255, 255],\n getInnerRadius: (d) => 1\n };\n\n renderLayers() {\n const {id, getFillColor, getStrokeColor, getInnerRadius, updateTriggers} = this.props;\n\n // data needs to be passed explicitly after deck.gl 5.3\n return [\n // the full circles\n new ScatterplotLayer<any>({\n ...this.props,\n id: `${id}-full`,\n data: this.props.data as any,\n getLineColor: getStrokeColor,\n updateTriggers: {\n ...updateTriggers,\n getStrokeColor: updateTriggers.getStrokeColor\n }\n }), // the inner part\n new ScatterplotLayer<any>({\n ...this.props,\n id: `${id}-inner`,\n data: this.props.data as any,\n getFillColor,\n getRadius: getInnerRadius,\n pickable: false,\n updateTriggers: {\n ...updateTriggers,\n getFillColor: updateTriggers.getFillColor,\n getRadius: updateTriggers.getInnerRadius\n }\n })\n ];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {NebulaLayer} from '../nebula-layer';\nimport {toDeckColor} from '../../utils/utils';\nimport {DeckCache} from '../deck-renderer/deck-cache';\nimport {JunctionScatterplotLayer} from '../../editable-layers/junction-scatterplot-layer';\n\nexport class JunctionsLayer extends NebulaLayer {\n deckCache: DeckCache<any, any>;\n\n constructor(config: Record<string, any>) {\n super(config);\n this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));\n this.enablePicking = true;\n }\n\n render({nebula}: Record<string, any>) {\n const defaultColor: [number, number, number, number] = [0x0, 0x0, 0x0, 0xff];\n const {objects, updateTrigger} = this.deckCache;\n\n return new JunctionScatterplotLayer({\n id: `junctions-${this.id}`,\n data: objects,\n opacity: 1,\n pickable: true,\n getPosition: (nf: any) => nf.geoJson.geometry.coordinates,\n getFillColor: (nf: any) => toDeckColor(nf.style.fillColor) || defaultColor,\n getStrokeColor: (nf: any) =>\n toDeckColor(nf.style.outlineColor) || toDeckColor(nf.style.fillColor) || defaultColor,\n getRadius: (nf: any) => nf.style.pointRadiusMeters + nf.style.outlineRadiusMeters || 1,\n getInnerRadius: (nf: any) => nf.style.pointRadiusMeters || 0.5,\n parameters: {\n depthCompare: 'always'\n },\n\n updateTriggers: {all: updateTrigger},\n\n // @ts-expect-error TODO\n nebulaLayer: this\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TextLayer} from '@deck.gl/layers';\nimport {NebulaLayer} from '../nebula-layer';\nimport {toDeckColor} from '../../utils/utils';\nimport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from '../constants';\nimport {DeckCache} from '../deck-renderer/deck-cache';\nimport {Color} from '../../utils/types';\n\nexport class TextsLayer extends NebulaLayer {\n deckCache: DeckCache<any, any>;\n\n constructor(config: Record<string, any>) {\n super(config);\n this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));\n }\n\n render({nebula}: Record<string, any>): TextLayer {\n const defaultColor: Color = [0x0, 0x0, 0x0, 0xff];\n const {objects, updateTrigger} = this.deckCache;\n\n const {zoom} = nebula.props.viewport;\n\n return new TextLayer({\n id: `texts-${this.id}`,\n data: objects,\n opacity: 1,\n fp64: false,\n pickable: false,\n\n getText: (nf: any) => nf.style.text,\n getPosition: (nf: any) => nf.geoJson.geometry.coordinates,\n getColor: (nf: {style: {fillColor: Color}}) =>\n toDeckColor(nf.style.fillColor) || defaultColor,\n\n // TODO: layer should offer option to scale with zoom\n sizeScale: 1 / Math.pow(2, 20 - zoom),\n getSize: PROJECTED_PIXEL_SIZE_MULTIPLIER,\n\n updateTriggers: {all: updateTrigger},\n\n nebulaLayer: this\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.\n * Required in order to maintain the same appearance after upgrading to deck.gl v8.5.\n * https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md\n */\nexport const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {DefaultProps} from '@deck.gl/core';\nimport {CompositeLayer, COORDINATE_SYSTEM} from '@deck.gl/core';\nimport {ScatterplotLayer} from '@deck.gl/layers';\nimport {SimpleMeshLayer} from '@deck.gl/mesh-layers';\nimport {PathOutlineLayer, PathOutlineLayerProps} from '../path-outline-layer/path-outline-layer';\nimport {Arrow2DGeometry} from './arrow-2d-geometry';\n\nimport {createPathMarkers} from './create-path-markers';\nimport {getClosestPointOnPolyline} from './polyline';\nimport {Vector3} from '@math.gl/core';\n\nconst DISTANCE_FOR_MULTI_ARROWS = 0.1;\nconst ARROW_HEAD_SIZE = 0.2;\nconst ARROW_TAIL_WIDTH = 0.05;\n// const ARROW_CENTER_ADJUST = -0.8;\n\nconst DEFAULT_MARKER_LAYER = SimpleMeshLayer;\n\nexport type PathMarkerLayerProps<DataT> = PathOutlineLayerProps<DataT> & {\n getDirection?: (x) => any;\n getMarkerColor?: (x) => number[];\n getMarkerPercentages?: (x: any, info: any) => number[];\n highlightPoint?: any;\n highlightIndex?: number;\n MarkerLayer?: any;\n markerLayerProps?: any;\n sizeScale?: number;\n fp64?: boolean;\n nebulaLayer?: any;\n};\n\nconst DEFAULT_MARKER_LAYER_PROPS = {\n mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH})\n};\n\nconst defaultProps: DefaultProps<PathMarkerLayerProps<any>> = Object.assign(\n {},\n PathOutlineLayer.defaultProps,\n {\n MarkerLayer: DEFAULT_MARKER_LAYER,\n markerLayerProps: DEFAULT_MARKER_LAYER_PROPS,\n\n sizeScale: 100,\n fp64: false,\n\n highlightIndex: -1,\n highlightPoint: null,\n\n getPath: (x) => x.path,\n getColor: (x) => x.color,\n getMarkerColor: (x) => [0, 0, 0, 255],\n getDirection: (x) => x.direction,\n getMarkerPercentages: (object, {lineLength}) =>\n lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]\n }\n);\n\nexport class PathMarkerLayer<\n DataT = any,\n ExtraPropsT = Record<string, unknown>\n> extends CompositeLayer<ExtraPropsT & Required<PathMarkerLayerProps<DataT>>> {\n static layerName = 'PathMarkerLayer';\n static defaultProps = defaultProps;\n\n state: {\n closestPoint: Vector3 | null;\n closestPoints?: {position: Vector3}[];\n markers: any[];\n mesh: Arrow2DGeometry;\n } = undefined!;\n\n initializeState() {\n this.state = {\n markers: [],\n mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH}),\n closestPoint: null,\n closestPoints: []\n };\n }\n\n projectFlat(xyz, viewport, coordinateSystem, coordinateOrigin) {\n if (coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {\n const [dx, dy] = viewport.metersToLngLatDelta(xyz);\n const [x, y] = coordinateOrigin;\n return viewport.projectFlat([x + dx, dy + y]);\n } else if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS) {\n const [dx, dy] = xyz;\n const [x, y] = coordinateOrigin;\n return viewport.projectFlat([x + dx, dy + y]);\n }\n\n return viewport.projectFlat(xyz);\n }\n\n updateState({props, oldProps, changeFlags}) {\n if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) {\n const {\n data,\n getPath,\n getDirection,\n getMarkerColor,\n getMarkerPercentages,\n coordinateSystem,\n coordinateOrigin\n } = this.props;\n\n const {viewport} = this.context;\n const projectFlat = (o) => this.projectFlat(o, viewport, coordinateSystem, coordinateOrigin);\n this.state.markers = createPathMarkers({\n data,\n getPath,\n getDirection,\n getColor: getMarkerColor,\n getMarkerPercentages,\n projectFlat\n });\n this._recalculateClosestPoint();\n }\n if (changeFlags.propsChanged) {\n if (props.point !== oldProps.point) {\n this._recalculateClosestPoint();\n }\n }\n }\n\n _recalculateClosestPoint() {\n const {highlightPoint, highlightIndex} = this.props;\n if (highlightPoint && highlightIndex >= 0) {\n const object = this.props.data[highlightIndex];\n const points = this.props.getPath(object, null as any);\n const {point} = getClosestPointOnPolyline({points, p: highlightPoint});\n this.state.closestPoints = [{position: point}];\n } else {\n this.state.closestPoints = [];\n }\n }\n\n getPickingInfo({info}) {\n return Object.assign(info, {\n // override object with picked feature\n object: (info.object && info.object.path) || info.object\n });\n }\n\n renderLayers() {\n return [\n new PathOutlineLayer(\n this.props,\n this.getSubLayerProps({\n id: 'paths',\n // Note: data has to be passed explicitly like this to avoid being empty\n data: this.props.data\n })\n ),\n new this.props.MarkerLayer(\n this.getSubLayerProps(\n Object.assign({}, this.props.markerLayerProps, {\n id: 'markers',\n data: this.state.markers,\n getOrientation: (x) => [0, -x.angle, 0],\n getColor: (x) => x.color,\n sizeScale: this.props.sizeScale,\n fp64: this.props.fp64,\n pickable: false,\n parameters: {\n blend: false,\n depthTest: false\n }\n })\n )\n ),\n this.state.closestPoints &&\n new ScatterplotLayer({\n id: `${this.props.id}-highlight`,\n data: this.state.closestPoints,\n fp64: this.props.fp64\n })\n ];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {PathLayerProps} from '@deck.gl/layers';\nimport {PathLayer} from '@deck.gl/layers';\nimport type {DefaultProps, LayerContext} from '@deck.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {Framebuffer, Texture} from '@luma.gl/core';\nimport {outline} from './outline';\n\n/**\n * Unit literal to shader unit number conversion.\n */\nexport const UNIT = {\n common: 0,\n meters: 1,\n pixels: 2\n};\n\n// TODO - this should be built into assembleShaders\nfunction injectShaderCode({source, code = ''}) {\n const INJECT_CODE = /}[^{}]*$/;\n return source.replace(INJECT_CODE, code.concat('\\n}\\n'));\n}\n\nconst VS_CODE = `\\\n outline_setUV(gl_Position);\n outline_setZLevel(instanceZLevel);\n`;\n\nconst FS_CODE = `\\\n fragColor = outline_filterColor(fragColor);\n`;\n\nexport type PathOutlineLayerProps<DataT> = PathLayerProps<DataT> & {\n dashJustified?: boolean;\n getDashArray?: [number, number] | ((d: DataT) => [number, number] | null);\n getZLevel?: (d: DataT, index: number) => number;\n};\n\nconst defaultProps: DefaultProps<PathOutlineLayerProps<any>> = {\n getZLevel: () => 0\n};\n\nexport class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>> extends PathLayer<\n DataT,\n ExtraPropsT & Required<PathOutlineLayerProps<DataT>>\n> {\n static layerName = 'PathOutlineLayer';\n static defaultProps = defaultProps;\n\n state: {\n model?: any;\n pathTesselator: any;\n outlineFramebuffer: Framebuffer;\n dummyTexture: Texture;\n } = undefined!;\n\n // Override getShaders to inject the outline module\n getShaders() {\n const shaders = super.getShaders();\n return Object.assign({}, shaders, {\n modules: shaders.modules.concat([outline]),\n vs: injectShaderCode({source: shaders.vs, code: VS_CODE}),\n fs: injectShaderCode({source: shaders.fs, code: FS_CODE})\n });\n }\n\n // @ts-expect-error PathLayer is missing LayerContext arg\n initializeState(context: LayerContext) {\n super.initializeState();\n\n // Create an outline \"shadow\" map\n // TODO - we should create a single outlineMap for all layers\n this.setState({\n outlineFramebuffer: context.device.createFramebuffer({}),\n dummyTexture: context.device.createTexture({width: 1, height: 1})\n });\n\n // Create an attribute manager\n // @ts-expect-error check whether this.getAttributeManager works here\n this.state.attributeManager.addInstanced({\n instanceZLevel: {\n size: 1,\n type: GL.UNSIGNED_BYTE,\n accessor: 'getZLevel'\n }\n });\n }\n\n // Override draw to add render module\n draw({moduleParameters = {}, parameters, uniforms, context}) {\n // Need to calculate same uniforms as base layer\n const {\n jointRounded,\n capRounded,\n billboard,\n miterLimit,\n widthUnits,\n widthScale,\n widthMinPixels,\n widthMaxPixels\n } = this.props;\n\n uniforms = Object.assign({}, uniforms, {\n jointType: Number(jointRounded),\n capType: Number(capRounded),\n billboard,\n widthUnits: UNIT[widthUnits],\n widthScale,\n miterLimit,\n widthMinPixels,\n widthMaxPixels\n });\n\n // Render the outline shadowmap (based on segment z orders)\n const {outlineFramebuffer, dummyTexture} = this.state;\n // TODO(v9): resize, see 'sf' example.\n // outlineFramebuffer.resize();\n // TODO(v9) clear FBO\n // outlineFramebuffer.clear({ color: true, depth: true, stencil: true });\n\n this.state.model.updateModuleSettings({\n outlineEnabled: true,\n outlineRenderShadowmap: true,\n outlineShadowmap: dummyTexture\n });\n\n this.state.model.draw({\n uniforms: Object.assign({}, uniforms, {\n jointType: 0,\n widthScale: this.props.widthScale * 1.3\n }),\n parameters: {\n depthTest: false,\n // Biggest value needs to go into buffer\n blendEquation: GL.MAX\n },\n framebuffer: outlineFramebuffer\n });\n\n // Now use the outline shadowmap to render the lines (with outlines)\n this.state.model.updateModuleSettings({\n outlineEnabled: true,\n outlineRenderShadowmap: false,\n outlineShadowmap: outlineFramebuffer\n });\n this.state.model.draw({\n uniforms: Object.assign({}, uniforms, {\n jointType: Number(jointRounded),\n capType: Number(capRounded),\n widthScale: this.props.widthScale\n }),\n parameters: {\n depthTest: false\n }\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\n/* eslint-disable camelcase */\nconst INITIAL_STATE: Record<string, any> = {\n outlineEnabled: false,\n outlineRenderShadowmap: false,\n outlineShadowmap: null\n};\n\nfunction getUniforms({outlineEnabled, outlineRenderShadowmap, outlineShadowmap} = INITIAL_STATE) {\n const uniforms: Record<string, any> = {};\n if (outlineEnabled !== undefined) {\n // ? 1.0 : 0.0;\n uniforms.outline_uEnabled = outlineEnabled;\n }\n if (outlineRenderShadowmap !== undefined) {\n // ? 1.0 : 0.0;\n uniforms.outline_uRenderOutlines = outlineRenderShadowmap;\n }\n if (outlineShadowmap !== undefined) {\n uniforms.outline_uShadowmap = outlineShadowmap;\n }\n return uniforms;\n}\n\nconst vs = `\\\n#version 300 es\nin float instanceZLevel;\nout float outline_vzLevel;\nout vec4 outline_vPosition;\n\n// Set the z level for the outline shadowmap rendering\nvoid outline_setZLevel(float zLevel) {\n outline_vzLevel = zLevel;\n}\n\n// Store an adjusted position for texture2DProj\nvoid outline_setUV(vec4 position) {\n // mat4(\n // 0.5, 0.0, 0.0, 0.0,\n // 0.0, 0.5, 0.0, 0.0,\n // 0.0, 0.0, 0.5, 0.0,\n // 0.5, 0.5, 0.5, 1.0\n // ) * position;\n outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);\n}\n`;\n\nconst fs = `\\\nuniform bool outline_uEnabled;\nuniform bool outline_uRenderOutlines;\nuniform sampler2D outline_uShadowmap;\n\nin float outline_vzLevel;\n// in vec2 outline_vUV;\nin vec4 outline_vPosition;\n\nout vec4 fragColor;\n\nconst float OUTLINE_Z_LEVEL_ERROR = 0.01;\n\n// Return a darker color in shadowmap\nvec4 outline_filterShadowColor(vec4 color) {\n return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);\n}\n\n// Return a darker color if in shadowmap\nvec4 outline_filterDarkenColor(vec4 color) {\n if (outline_uEnabled) {\n float maxZLevel;\n if (outline_vPosition.q > 0.0) {\n maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;\n } else {\n discard;\n }\n if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {\n vec4(color.rgb * 0.5, color.a);\n } else {\n discard;\n }\n }\n return color;\n}\n\n// if enabled and rendering outlines - Render depth to shadowmap\n// if enabled and rendering colors - Return a darker color if in shadowmap\n// if disabled, just return color\nvec4 outline_filterColor(vec4 color) {\n if (outline_uEnabled) {\n return outline_uRenderOutlines ?\n outline_filterShadowColor(color) :\n outline_filterDarkenColor(color);\n }\n return color;\n}\n`;\n\nexport const outline = {\n name: 'outline',\n vs,\n fs,\n getUniforms\n} as const satisfies ShaderModule;\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Geometry} from '@luma.gl/engine';\n\nexport class Arrow2DGeometry extends Geometry {\n constructor(opts = {}) {\n super(\n Object.assign({}, opts, {\n attributes: getArrowAttributes(opts),\n topology: 'triangle-list' as const\n })\n );\n }\n}\n\nfunction getArrowAttributes({length = 1, headSize = 0.2, tailWidth = 0.05, tailStart = 0.05}) {\n const texCoords = [\n // HEAD\n 0.5,\n 1.0,\n 0,\n 0.5 - headSize / 2,\n 1.0 - headSize,\n 0,\n 0.5 + headSize / 2,\n 1.0 - headSize,\n 0,\n 0.5 - tailWidth / 2,\n tailStart,\n 0,\n 0.5 + tailWidth / 2,\n 1.0 - headSize,\n 0,\n 0.5 + tailWidth / 2,\n tailStart,\n 0,\n 0.5 - tailWidth / 2,\n tailStart,\n 0,\n 0.5 - tailWidth / 2,\n 1.0 - headSize,\n 0,\n 0.5 + tailWidth / 2,\n 1.0 - headSize,\n 0\n ];\n\n const normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1];\n\n // Center and scale\n const positions = new Array(texCoords.length);\n for (let i = 0; i < texCoords.length / 3; i++) {\n const i3 = i * 3;\n positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length;\n positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length;\n positions[i3 + 2] = 0;\n }\n return {\n positions: {size: 3, value: new Float32Array(positions)},\n normals: {size: 3, value: new Float32Array(normals)},\n texCoords: {size: 2, value: new Float32Array(texCoords)}\n };\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector2} from '@math.gl/core';\n\n/** GeoJSON style position coordinate vector */\nexport type Position = [number, number] | [number, number, number];\n\n/** [red, green, blue, alpha] in premultiplied alpha format */\nexport type Color = [number, number, number, number];\n\nexport interface PathMarker {\n position: Position;\n angle: number;\n color: Color;\n object: unknown;\n}\n\nfunction getLineLength(vPoints) {\n // calculate total length\n let lineLength = 0;\n for (let i = 0; i < vPoints.length - 1; i++) {\n lineLength += vPoints[i].distance(vPoints[i + 1]);\n }\n return lineLength;\n}\n\nconst DEFAULT_COLOR = [0, 0, 0, 255];\nconst DEFAULT_DIRECTION = {forward: true, backward: false};\n\nexport function createPathMarkers({\n data,\n getPath = (x, context) => x.path,\n getDirection = (x) => x.direction,\n getColor = (x) => DEFAULT_COLOR,\n getMarkerPercentages = (x, info) => [0.5],\n projectFlat\n}): PathMarker[] {\n const markers: PathMarker[] = [];\n\n for (const object of data) {\n const path = getPath(object, null);\n const direction = getDirection(object) || DEFAULT_DIRECTION;\n const color = getColor(object);\n\n const vPoints = path.map((p) => new Vector2(p));\n const vPointsReverse = vPoints.slice(0).reverse();\n\n // calculate total length\n const lineLength = getLineLength(vPoints);\n\n // Ask for where to put markers\n const percentages = getMarkerPercentages(object, {lineLength});\n\n // Create the markers\n for (const percentage of percentages) {\n if (direction.forward) {\n const marker = createMarkerAlongPath({\n path: vPoints,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n });\n markers.push(marker);\n }\n\n if (direction.backward) {\n const marker = createMarkerAlongPath({\n path: vPointsReverse,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n });\n markers.push(marker);\n }\n }\n }\n\n return markers;\n}\n\nfunction createMarkerAlongPath({\n path,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n}): PathMarker {\n const distanceAlong = lineLength * percentage;\n let currentDistance = 0;\n let previousDistance = 0;\n let i = 0;\n for (i = 0; i < path.length - 1; i++) {\n currentDistance += path[i].distance(path[i + 1]);\n if (currentDistance > distanceAlong) {\n break;\n }\n previousDistance = currentDistance;\n }\n\n // If reached the end of the loop without exiting early,\n // undo the final increment to avoid a null-pointer exception\n if (i === path.length - 1) {\n i -= 1;\n }\n\n const vDirection = path[i + 1].clone().subtract(path[i]).normalize();\n const along = distanceAlong - previousDistance;\n const vCenter = vDirection.clone().multiply(new Vector2(along, along)).add(path[i]);\n\n const vDirection2 = new Vector2(projectFlat(path[i + 1])).subtract(projectFlat(path[i]));\n\n const angle = (vDirection2.verticalAngle() * 180) / Math.PI;\n\n return {position: [vCenter.x, vCenter.y, 0], angle, color, object};\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector3, clamp} from '@math.gl/core';\n\n// Return the closest point on a line segment\nexport function getClosestPointOnLine({p, p1, p2, clampToLine = true}) {\n const lineVector = new Vector3(p2).subtract(p1);\n const pointVector = new Vector3(p).subtract(p1);\n let dotProduct = lineVector.dot(pointVector);\n if (clampToLine) {\n dotProduct = clamp(dotProduct, 0, 1);\n }\n\n return lineVector.lerp(p1, p2, dotProduct);\n}\n\n// Return the closest point on a line segment\nexport function getClosestPointOnPolyline({p, points}) {\n p = new Vector3(p);\n let pClosest: Vector3 | null = null;\n let distanceSquared = Infinity;\n let index = -1;\n for (let i = 0; i < points.length - 1; ++i) {\n const p1 = points[i];\n const p2 = points[i + 1];\n const pClosestOnLine = getClosestPointOnLine({p, p1, p2});\n const distanceToLineSquared = p.distanceSquared(pClosestOnLine);\n if (distanceToLineSquared < distanceSquared) {\n distanceSquared = distanceToLineSquared;\n pClosest = pClosestOnLine;\n index = i;\n }\n }\n return {\n point: pClosest,\n index,\n p1: points[index],\n p2: points[index + 1],\n distanceSquared,\n distance: Math.sqrt(distanceSquared)\n };\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ArrowStyles, DEFAULT_STYLE, MAX_ARROWS} from '../style';\nimport {NebulaLayer} from '../nebula-layer';\nimport {toDeckColor} from '../../utils/utils';\nimport {DeckCache} from '../deck-renderer/deck-cache';\nimport {PathMarkerLayer} from '../../../../layers/src/path-marker-layer/path-marker-layer';\n\nconst NEBULA_TO_DECK_DIRECTIONS = {\n [ArrowStyles.NONE]: {forward: false, backward: false},\n [ArrowStyles.FORWARD]: {forward: true, backward: false},\n [ArrowStyles.BACKWARD]: {forward: false, backward: true},\n [ArrowStyles.BOTH]: {forward: true, backward: true}\n};\n\nexport class SegmentsLayer extends NebulaLayer {\n deckCache: DeckCache<any, any>;\n noBlend: boolean;\n highlightColor: [number, number, number, number];\n arrowSize: number;\n jointRounded: boolean;\n capRounded: boolean;\n dashed: boolean;\n markerLayerProps: Record<string, any> | null | undefined;\n\n constructor(config: Record<string, any>) {\n super(config);\n this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));\n this.enableSelection = true;\n this.enablePicking = config.enablePicking ?? true;\n this.noBlend = config.noBlend ?? false;\n this.jointRounded = config.jointRounded ?? true;\n this.capRounded = config.capRounded ?? true;\n this.dashed = config.dashed ?? false;\n this.markerLayerProps = config.markerLayerProps ?? null;\n this.highlightColor = [1, 1, 1, 1];\n this.arrowSize = 1;\n }\n\n getMouseOverSegment(): any {\n // TODO: remove references\n return null;\n }\n\n _calcMarkerPercentages(nf: Record<string, any>): number[] {\n const {arrowPercentages} = nf.style;\n if (arrowPercentages) {\n return arrowPercentages;\n }\n\n const arrowStyle = nf.style.arrowStyle || DEFAULT_STYLE.arrowStyle;\n if (arrowStyle === ArrowStyles.NONE) return [];\n\n const arrowCount = Math.min(nf.style.arrowCount || DEFAULT_STYLE.arrowCount, MAX_ARROWS);\n return [[0.5], [0.33, 0.66], [0.25, 0.5, 0.75]][arrowCount - 1];\n }\n\n _getHighlightedObjectIndex({nebula}: Record<string, any>): number {\n const {deckglMouseOverInfo} = nebula;\n if (deckglMouseOverInfo) {\n const {originalLayer, index} = deckglMouseOverInfo;\n if (originalLayer === this) {\n return index;\n }\n }\n\n // no object\n return -1;\n }\n\n render({nebula}: Record<string, any>) {\n const defaultColor: [number, number, number, number] = [0x0, 0x0, 0x0, 0xff];\n const {objects, updateTrigger} = this.deckCache;\n\n return new PathMarkerLayer<any>({\n id: `segments-${this.id}`,\n data: objects,\n opacity: 1,\n fp64: false,\n jointRounded: this.jointRounded,\n capRounded: this.capRounded,\n pickable: true,\n sizeScale: this.arrowSize || 6,\n parameters: {\n depthCompare: 'always',\n blendColorOperation: this.noBlend ? undefined : 'max'\n },\n getPath: (nf: any) => nf.geoJson.geometry.coordinates,\n getColor: (nf: any) => toDeckColor(nf.style.lineColor, defaultColor),\n getWidth: (nf: any) => nf.style.lineWidthMeters || 1,\n getZLevel: (nf: any) => nf.style.zLevel * 255,\n getDirection: (nf: any) => NEBULA_TO_DECK_DIRECTIONS[nf.style.arrowStyle],\n getMarkerColor: (nf: any) => toDeckColor(nf.style.arrowColor, defaultColor),\n // eslint-disable-next-line @typescript-eslint/unbound-method\n getMarkerPercentages: this._calcMarkerPercentages,\n updateTriggers: {all: updateTrigger},\n\n highlightedObjectIndex: this._getHighlightedObjectIndex({nebula}),\n highlightColor: toDeckColor(this.highlightColor),\n\n dashJustified: this.dashed,\n getDashArray: this.dashed ? (nf) => nf.style.dashArray : undefined,\n markerLayerProps:\n this.markerLayerProps ||\n (PathMarkerLayer as Record<string, any>).defaultProps.markerLayerProps,\n\n nebulaLayer: this\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {EventEmitter} from 'eventemitter3';\nimport {WebMercatorViewport} from '@deck.gl/core';\n\nimport {DeckDrawer} from './deck-renderer/deck-drawer';\nimport {LayerMouseEvent} from './layer-mouse-event';\nimport {NebulaLayer} from './nebula-layer';\n\nconst LOGGER_PREFIX = 'Nebula: ';\n\nexport class NebulaCore {\n init(props: Record<string, any>) {\n this.props = props;\n this.wmViewport = new WebMercatorViewport(this.props.viewport);\n\n // TODO: Properly use pointer events: ['click', 'pointermove', 'pointerup', 'pointerdown']\n ['click', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>\n document.addEventListener(name, this._onMouseEvent as any, true)\n );\n }\n\n detach() {\n // TODO: Properly use pointer events: ['click', 'pointermove', 'pointerup', 'pointerdown']\n ['click', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>\n document.removeEventListener(name, this._onMouseEvent as any, true)\n );\n }\n\n updateProps(newProps: Record<string, any>) {\n this.props = newProps;\n const {viewport} = this.props;\n\n this.wmViewport = new WebMercatorViewport(viewport);\n }\n\n props: Record<string, any> = null!;\n deckgl: Record<string, any> | null = null;\n mainContainer: Record<string, any> | null = null;\n deckglMouseOverInfo: Record<string, any> | null | undefined = null;\n _deckDrawer: DeckDrawer = null!;\n _mouseWasDown: boolean = null!;\n wmViewport: WebMercatorViewport = null!;\n queryObjectEvents = new EventEmitter();\n forceUpdate: () => any = null!;\n inited: boolean = null!;\n\n log(message: string) {\n const {logger} = this.props;\n if (logger && logger.info) {\n logger.info(LOGGER_PREFIX + message);\n }\n }\n\n updateAllDeckObjects() {\n this.getAllLayers().forEach((layer) => {\n if (layer && layer.deckCache) {\n layer.deckCache.updateAllDeckObjects();\n }\n });\n this.forceUpdate();\n }\n\n updateDeckObjectsByIds(ids: string[]) {\n this.getAllLayers().forEach((layer) => {\n if (layer && layer.deckCache) {\n layer.deckCache.updateDeckObjectsByIds(ids);\n }\n });\n this.forceUpdate();\n }\n\n rerenderLayers() {\n this.updateAllDeckObjects();\n }\n\n _isNebulaEvent({buttons, target, type}: Record<string, any>) {\n const {viewport} = this.props;\n\n // allow mouseup event aggressively to cancel drag properly\n // TODO: use pointer capture setPointerCapture() to capture mouseup properly after deckgl\n if (this._mouseWasDown && type === 'mouseup') {\n this._mouseWasDown = false;\n return true;\n }\n\n // allow mousemove event while dragging\n if (type === 'mousemove' && buttons > 0) {\n return true;\n }\n\n if (!target.getBoundingClientRect) {\n return false;\n }\n\n const rect = target.getBoundingClientRect();\n // Only listen to events coming from the basemap\n // identified by the canvas of the same size as viewport.\n // Need to round the rect dimension as some monitors\n // have some sub-pixel difference with viewport.\n return (\n Math.round(rect.width) === Math.round(viewport.width) &&\n Math.round(rect.height) === Math.round(viewport.height)\n );\n }\n\n _onMouseEvent = (event: MouseEvent) => {\n if (!this._isNebulaEvent(event)) {\n return;\n }\n\n if (event.type === 'mousedown') {\n this._mouseWasDown = true;\n }\n\n // offsetX/Y of the MouseEvent provides the offset in the X/Y coordinate\n // of the mouse pointer between that event and the padding edge of the target node.\n // We set our listener to document so we need to adjust offsetX/Y\n // in case the target is not be our WebGL canvas.\n const {top = 0, left = 0} = this.mainContainer\n ? this.mainContainer.getBoundingClientRect()\n : {};\n const proxyEvent = new Proxy(event, {\n get: (original: any, propertyName: string) => {\n if (propertyName === 'offsetX') {\n return original.pageX - left;\n }\n\n if (propertyName === 'offsetY') {\n return original.pageY - top;\n }\n\n // TODO: Properly use pointer events\n if (propertyName === 'type') {\n return original.type.replace('pointer', 'mouse');\n }\n\n const result = original[propertyName];\n if (typeof result === 'function') {\n return result.bind(original);\n }\n return result;\n }\n });\n\n this._handleDeckGLEvent(proxyEvent);\n };\n\n getMouseGroundPosition(event: Record<string, any>) {\n return this.wmViewport.unproject([event.offsetX, event.offsetY]) as [number, number];\n }\n\n unprojectMousePosition(mousePosition: [number, number]): [number, number] {\n return this.wmViewport.unproject(mousePosition) as [number, number];\n }\n\n // eslint-disable-next-line max-statements, complexity\n _handleDeckGLEvent(event: Record<string, any>) {\n const {\n deckgl,\n props: {onMapMouseEvent, selectionType, eventFilter}\n } = this;\n let sendMapEvent = true;\n let cursor = 'auto';\n\n if (event && deckgl && selectionType) {\n if (!this._deckDrawer) this._deckDrawer = new DeckDrawer(this);\n\n const lngLat = this.getMouseGroundPosition(event);\n if (eventFilter && !eventFilter(lngLat, event)) return;\n const drawerResult = this._deckDrawer.handleEvent(event, lngLat, selectionType);\n if (drawerResult.redraw) this.forceUpdate();\n return;\n }\n\n if (event && deckgl && (!event.buttons || event.type !== 'mousemove')) {\n // TODO: sort by mouse priority\n const layerIds = deckgl.props.layers\n .filter(\n (l: any) => l && l.props && l.props.nebulaLayer && l.props.nebulaLayer.enablePicking\n )\n .map((l: any) => l.id);\n\n const pickingInfo = deckgl.pickObject({\n x: event.offsetX,\n y: event.offsetY,\n radius: 5,\n layerIds\n });\n this.queryObjectEvents.emit('pick', {event, pickingInfo});\n if (pickingInfo) {\n sendMapEvent = false;\n\n const {index, lngLat} = pickingInfo;\n if (eventFilter && !eventFilter(lngLat, event)) return;\n\n const {layer: deckLayer, object} = pickingInfo;\n\n if (\n deckLayer &&\n deckLayer.props &&\n deckLayer.props.nebulaLayer &&\n deckLayer.props.nebulaLayer.eventHandler\n ) {\n deckLayer.props.nebulaLayer.eventHandler(event, pickingInfo);\n }\n\n const original =\n object.original ||\n (deckLayer.props.nebulaLayer &&\n deckLayer.props.nebulaLayer.deckCache &&\n deckLayer.props.nebulaLayer.deckCache.originals[index]);\n\n if (original) {\n this.deckglMouseOverInfo = {originalLayer: deckLayer.props.nebulaLayer, index};\n // @ts-expect-error narrow event type\n const nebulaMouseEvent = new LayerMouseEvent(event, {\n data: original,\n metadata: object.metadata,\n groundPoint: lngLat,\n nebula: this\n });\n deckLayer.props.nebulaLayer.emit(event.type, nebulaMouseEvent);\n this.forceUpdate();\n }\n\n cursor = 'pointer';\n }\n }\n\n if (document.documentElement) {\n document.documentElement.style.cursor = cursor;\n }\n\n if (sendMapEvent) {\n this.deckglMouseOverInfo = null;\n\n const lngLat = this.getMouseGroundPosition(event);\n if (eventFilter && !eventFilter(lngLat, event)) return;\n\n // send to layers first\n // @ts-expect-error narrow event type\n const nebulaMouseEvent = new LayerMouseEvent(event, {\n groundPoint: lngLat,\n nebula: this\n });\n this.getAllLayers()\n .filter((layer) => layer && layer.usesMapEvents)\n .forEach((layer) => layer.emit('mapMouseEvent', nebulaMouseEvent));\n\n this.getAllLayers()\n .filter(\n (layer) =>\n layer && layer.props && layer.props.nebulaLayer && layer.props.nebulaLayer.mapMouseEvent\n )\n .forEach((layer) => layer.props.nebulaLayer.mapMouseEvent(nebulaMouseEvent, layer));\n\n if (onMapMouseEvent) {\n onMapMouseEvent(event, lngLat);\n }\n }\n }\n\n getExtraDeckLayers(): Record<string, any>[] {\n const result: Record<string, any>[] = [];\n\n if (this._deckDrawer) result.push(...this._deckDrawer.render());\n\n return result;\n }\n\n renderDeckLayers() {\n return this.getAllLayers()\n .map((layer) => (layer instanceof NebulaLayer ? layer.render({nebula: this}) : layer))\n .filter(Boolean);\n }\n\n getAllLayers() {\n const result: Record<string, any>[] = [];\n\n this.props.layers.filter(Boolean).forEach((layer) => {\n result.push(layer);\n // Only NebulaLayers have helpers, Deck GL layers don't.\n if (layer instanceof NebulaLayer) {\n result.push(...layer.helperLayers);\n }\n });\n\n return result.filter(Boolean);\n }\n\n getRenderedLayers() {\n return [...this.renderDeckLayers(), ...this.getExtraDeckLayers()];\n }\n\n updateAndGetRenderedLayers(\n layers: Record<string, any>[],\n viewport: WebMercatorViewport,\n container: Record<string, any>\n ) {\n if (this.inited) {\n this.updateProps({layers, viewport});\n this.forceUpdate = () => container.forceUpdate();\n } else {\n this.inited = true;\n this.init({layers, viewport});\n this.forceUpdate = () => container.forceUpdate();\n this.updateAllDeckObjects();\n }\n\n return this.getRenderedLayers();\n }\n\n setDeck(deckgl: Record<string, any> | null) {\n if (deckgl) {\n this.deckgl = deckgl;\n }\n }\n\n setMainContainer(mainContainer: Record<string, any> | null) {\n if (mainContainer) {\n this.mainContainer = mainContainer;\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {UpdateParameters, DefaultProps} from '@deck.gl/core';\nimport {GeoJsonLayer, ScatterplotLayer, IconLayer, TextLayer} from '@deck.gl/layers';\nimport {\n EditAction,\n ClickEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n PointerMoveEvent,\n DoubleClickEvent\n} from '../edit-modes/types';\n\nimport {ViewMode} from '../edit-modes/view-mode';\nimport {TranslateMode} from '../edit-modes/translate-mode';\nimport {ModifyMode} from '../edit-modes/modify-mode';\nimport {ScaleMode} from '../edit-modes/scale-mode';\nimport {RotateMode} from '../edit-modes/rotate-mode';\nimport {DuplicateMode} from '../edit-modes/duplicate-mode';\nimport {SplitPolygonMode} from '../edit-modes/split-polygon-mode';\nimport {ExtrudeMode} from '../edit-modes/extrude-mode';\nimport {ElevationMode} from '../edit-modes/elevation-mode';\nimport {DrawPointMode} from '../edit-modes/draw-point-mode';\nimport {DrawLineStringMode} from '../edit-modes/draw-line-string-mode';\nimport {DrawPolygonMode} from '../edit-modes/draw-polygon-mode';\nimport {DrawRectangleMode} from '../edit-modes/draw-rectangle-mode';\nimport {DrawSquareMode} from '../edit-modes/draw-square-mode';\nimport {DrawRectangleFromCenterMode} from '../edit-modes/draw-rectangle-from-center-mode';\nimport {DrawSquareFromCenterMode} from '../edit-modes/draw-square-from-center-mode';\nimport {DrawCircleFromCenterMode} from '../edit-modes/draw-circle-from-center-mode';\nimport {DrawCircleByDiameterMode} from '../edit-modes/draw-circle-by-diameter-mode';\nimport {DrawEllipseByBoundingBoxMode} from '../edit-modes/draw-ellipse-by-bounding-box-mode';\nimport {DrawRectangleUsingThreePointsMode} from '../edit-modes/draw-rectangle-using-three-points-mode';\nimport {DrawEllipseUsingThreePointsMode} from '../edit-modes/draw-ellipse-using-three-points-mode';\nimport {Draw90DegreePolygonMode} from '../edit-modes/draw-90degree-polygon-mode';\nimport {DrawPolygonByDraggingMode} from '../edit-modes/draw-polygon-by-dragging-mode';\nimport {SnappableMode} from '../edit-modes/snappable-mode';\nimport {TransformMode} from '../edit-modes/transform-mode';\nimport {DeleteMode} from '../edit-modes/delete-mode';\nimport {GeoJsonEditModeType} from '../edit-modes/geojson-edit-mode';\n\nimport {Color} from '../utils/types';\nimport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from '../constants';\n\nimport {EditableLayer, EditableLayerProps} from './editable-layer';\nimport {EditablePathLayer} from './editable-path-layer';\nimport {Feature, FeatureCollection} from '../utils/geojson-types';\n\nconst DEFAULT_LINE_COLOR: Color = [0x0, 0x0, 0x0, 0x99];\nconst DEFAULT_FILL_COLOR: Color = [0x0, 0x0, 0x0, 0x90];\nconst DEFAULT_SELECTED_LINE_COLOR: Color = [0x0, 0x0, 0x0, 0xff];\nconst DEFAULT_SELECTED_FILL_COLOR: Color = [0x0, 0x0, 0x90, 0x90];\nconst DEFAULT_TENTATIVE_LINE_COLOR: Color = [0x90, 0x90, 0x90, 0xff];\nconst DEFAULT_TENTATIVE_FILL_COLOR: Color = [0x90, 0x90, 0x90, 0x90];\nconst DEFAULT_EDITING_EXISTING_POINT_COLOR: Color = [0xc0, 0x0, 0x0, 0xff];\nconst DEFAULT_EDITING_INTERMEDIATE_POINT_COLOR: Color = [0x0, 0x0, 0x0, 0x80];\nconst DEFAULT_EDITING_SNAP_POINT_COLOR: Color = [0x7c, 0x00, 0xc0, 0xff];\nconst DEFAULT_EDITING_POINT_OUTLINE_COLOR: Color = [0xff, 0xff, 0xff, 0xff];\nconst DEFAULT_EDITING_EXISTING_POINT_RADIUS = 5;\nconst DEFAULT_EDITING_INTERMEDIATE_POINT_RADIUS = 3;\nconst DEFAULT_EDITING_SNAP_POINT_RADIUS = 7;\nconst DEFAULT_TOOLTIP_FONT_SIZE = 32 * PROJECTED_PIXEL_SIZE_MULTIPLIER;\n\nconst DEFAULT_EDIT_MODE = DrawPolygonMode;\n\nfunction guideAccessor(accessor) {\n if (!accessor || typeof accessor !== 'function') {\n return accessor;\n }\n return (guideMaybeWrapped) => accessor(unwrapGuide(guideMaybeWrapped));\n}\n\n// The object handed to us from deck.gl is different depending on the version of deck.gl used, unwrap as necessary\nfunction unwrapGuide(guideMaybeWrapped) {\n if (guideMaybeWrapped.__source) {\n return guideMaybeWrapped.__source.object;\n } else if (guideMaybeWrapped.sourceFeature) {\n return guideMaybeWrapped.sourceFeature.feature;\n }\n // It is not wrapped, return as is\n return guideMaybeWrapped;\n}\n\nfunction getEditHandleColor(handle) {\n switch (handle.properties.editHandleType) {\n case 'existing':\n return DEFAULT_EDITING_EXISTING_POINT_COLOR;\n case 'snap-source':\n return DEFAULT_EDITING_SNAP_POINT_COLOR;\n case 'intermediate':\n default:\n return DEFAULT_EDITING_INTERMEDIATE_POINT_COLOR;\n }\n}\n\nfunction getEditHandleOutlineColor(handle) {\n return DEFAULT_EDITING_POINT_OUTLINE_COLOR;\n}\n\nfunction getEditHandleRadius(handle) {\n switch (handle.properties.editHandleType) {\n case 'existing':\n return DEFAULT_EDITING_EXISTING_POINT_RADIUS;\n case 'snap':\n return DEFAULT_EDITING_SNAP_POINT_RADIUS;\n case 'intermediate':\n default:\n return DEFAULT_EDITING_INTERMEDIATE_POINT_RADIUS;\n }\n}\n\nexport type EditableGeoJsonLayerProps<DataT = any> = EditableLayerProps & {\n data: DataT;\n mode?: any;\n modeConfig?: any;\n selectedFeatureIndexes?: number[];\n onEdit?: (updatedData?, editType?: string, featureIndexes?: number[], editContext?) => void;\n\n pickable?: boolean;\n pickingRadius?: number;\n pickingDepth?: number;\n fp64?: boolean;\n filled?: boolean;\n stroked?: boolean;\n lineWidthScale?: number;\n lineWidthMinPixels?: number;\n lineWidthMaxPixels?: number;\n pickingLineWidthExtraPixels?: number;\n lineWidthUnits?: string;\n lineJointRounded?: boolean;\n lineCapRounded?: boolean;\n lineMiterLimit?: number;\n pointRadiusScale?: number;\n pointRadiusMinPixels?: number;\n pointRadiusMaxPixels?: number;\n\n getLineColor?: Color | ((feature, isSelected, mode) => Color);\n getFillColor?: Color | ((feature, isSelected, mode) => Color);\n getRadius?: number | ((f) => number);\n getLineWidth?: number | ((f) => number);\n\n getTentativeLineColor?: Color | ((feature, isSelected, mode) => Color);\n getTentativeFillColor?: Color | ((feature, isSelected, mode) => Color);\n getTentativeLineWidth?: number | ((f) => number);\n\n editHandleType?: string;\n\n editHandlePointRadiusScale?: number;\n editHandlePointOutline?: boolean;\n editHandlePointStrokeWidth?: number;\n editHandlePointRadiusUnits?: string;\n editHandlePointRadiusMinPixels?: number;\n editHandlePointRadiusMaxPixels?: number;\n getEditHandlePointColor?: Color | ((handle) => Color);\n getEditHandlePointOutlineColor?: Color | ((handle) => Color);\n getEditHandlePointRadius?: number | ((handle) => number);\n\n // icon handles\n editHandleIconAtlas?: any;\n editHandleIconMapping?: any;\n editHandleIconSizeScale?: number;\n editHandleIconSizeUnits?: string;\n getEditHandleIcon?: (handle) => string;\n getEditHandleIconSize?: number;\n getEditHandleIconColor?: Color | ((handle) => Color);\n getEditHandleIconAngle?: number | ((handle) => number);\n\n // misc\n billboard?: boolean;\n};\n\nconst defaultProps: DefaultProps<EditableGeoJsonLayerProps<any>> = {\n mode: DEFAULT_EDIT_MODE,\n\n // Edit and interaction events\n onEdit: () => {},\n\n pickable: true,\n pickingRadius: 10,\n pickingDepth: 5,\n fp64: false,\n filled: true,\n stroked: true,\n lineWidthScale: PROJECTED_PIXEL_SIZE_MULTIPLIER,\n lineWidthMinPixels: 1,\n lineWidthMaxPixels: Number.MAX_SAFE_INTEGER,\n pickingLineWidthExtraPixels: 0,\n lineWidthUnits: 'pixels',\n lineJointRounded: false,\n lineCapRounded: false,\n lineMiterLimit: 4,\n pointRadiusScale: 1,\n pointRadiusMinPixels: 2,\n pointRadiusMaxPixels: Number.MAX_SAFE_INTEGER,\n getLineColor: (feature, isSelected, mode) =>\n isSelected ? DEFAULT_SELECTED_LINE_COLOR : DEFAULT_LINE_COLOR,\n getFillColor: (feature, isSelected, mode) =>\n isSelected ? DEFAULT_SELECTED_FILL_COLOR : DEFAULT_FILL_COLOR,\n getRadius: (f) =>\n (f && f.properties && f.properties.radius) || (f && f.properties && f.properties.size) || 1,\n getLineWidth: (f) => (f && f.properties && f.properties.lineWidth) || 3,\n\n // Tentative feature rendering\n getTentativeLineColor: (f) => DEFAULT_TENTATIVE_LINE_COLOR,\n getTentativeFillColor: (f) => DEFAULT_TENTATIVE_FILL_COLOR,\n getTentativeLineWidth: (f) => (f && f.properties && f.properties.lineWidth) || 3,\n\n editHandleType: 'point',\n\n // point handles\n editHandlePointRadiusScale: 1,\n editHandlePointOutline: true,\n editHandlePointStrokeWidth: 2,\n editHandlePointRadiusUnits: 'pixels',\n editHandlePointRadiusMinPixels: 4,\n editHandlePointRadiusMaxPixels: 8,\n getEditHandlePointColor: getEditHandleColor,\n getEditHandlePointOutlineColor: getEditHandleOutlineColor,\n getEditHandlePointRadius: getEditHandleRadius,\n\n // icon handles\n editHandleIconAtlas: null,\n editHandleIconMapping: null,\n editHandleIconSizeScale: 1,\n editHandleIconSizeUnits: 'pixels',\n getEditHandleIcon: (handle) => handle.properties.editHandleType,\n getEditHandleIconSize: 10,\n getEditHandleIconColor: getEditHandleColor,\n getEditHandleIconAngle: 0,\n\n // misc\n billboard: true\n};\n\n// Mapping of mode name to mode class (for legacy purposes)\nconst modeNameMapping = {\n view: ViewMode,\n\n // Alter modes\n modify: ModifyMode,\n translate: new SnappableMode(new TranslateMode()),\n\n transform: new SnappableMode(new TransformMode()),\n scale: ScaleMode,\n rotate: RotateMode,\n duplicate: DuplicateMode,\n split: SplitPolygonMode,\n extrude: ExtrudeMode,\n elevation: ElevationMode,\n delete: DeleteMode,\n\n // Draw modes\n drawPoint: DrawPointMode,\n drawLineString: DrawLineStringMode,\n drawPolygon: DrawPolygonMode,\n drawRectangle: DrawRectangleMode,\n drawSquare: DrawSquareMode,\n drawRectangleFromCenter: DrawRectangleFromCenterMode,\n drawSquareFromCenter: DrawSquareFromCenterMode,\n drawCircleFromCenter: DrawCircleFromCenterMode,\n drawCircleByBoundingBox: DrawCircleByDiameterMode,\n drawEllipseByBoundingBox: DrawEllipseByBoundingBoxMode,\n drawRectangleUsing3Points: DrawRectangleUsingThreePointsMode,\n drawEllipseUsing3Points: DrawEllipseUsingThreePointsMode,\n draw90DegreePolygon: Draw90DegreePolygonMode,\n drawPolygonByDragging: DrawPolygonByDraggingMode\n};\n\nexport class EditableGeoJsonLayer extends EditableLayer<\n FeatureCollection,\n EditableGeoJsonLayerProps<FeatureCollection>\n> {\n static layerName = 'EditableGeoJsonLayer';\n static defaultProps = defaultProps;\n\n state: EditableLayer['state'] & {\n cursor?: 'grabbing' | 'grab' | null;\n mode: GeoJsonEditModeType;\n lastPointerMoveEvent: PointerMoveEvent;\n tentativeFeature?: Feature;\n editHandles: any[];\n selectedFeatures: Feature[];\n } = undefined!;\n\n // setState: ($Shape<State>) => void;\n renderLayers() {\n const subLayerProps = this.getSubLayerProps({\n id: 'geojson',\n\n // Proxy most GeoJsonLayer props as-is\n data: this.props.data,\n fp64: this.props.fp64,\n filled: this.props.filled,\n stroked: this.props.stroked,\n lineWidthScale: this.props.lineWidthScale,\n lineWidthMinPixels: this.props.lineWidthMinPixels,\n lineWidthMaxPixels: this.props.lineWidthMaxPixels,\n lineWidthUnits: this.props.lineWidthUnits,\n lineJointRounded: this.props.lineJointRounded,\n lineCapRounded: this.props.lineCapRounded,\n lineMiterLimit: this.props.lineMiterLimit,\n pointRadiusScale: this.props.pointRadiusScale,\n pointRadiusMinPixels: this.props.pointRadiusMinPixels,\n pointRadiusMaxPixels: this.props.pointRadiusMaxPixels,\n getLineColor: this.selectionAwareAccessor(this.props.getLineColor),\n getFillColor: this.selectionAwareAccessor(this.props.getFillColor),\n getPointRadius: this.selectionAwareAccessor(this.props.getRadius),\n getLineWidth: this.selectionAwareAccessor(this.props.getLineWidth),\n\n _subLayerProps: {\n linestrings: {\n billboard: this.props.billboard,\n updateTriggers: {\n // required to update dashed array attribute\n all: [this.props.selectedFeatureIndexes, this.props.mode]\n }\n },\n 'polygons-stroke': {\n billboard: this.props.billboard,\n pickingLineWidthExtraPixels: this.props.pickingLineWidthExtraPixels,\n type: EditablePathLayer,\n updateTriggers: {\n // required to update dashed array attribute\n all: [this.props.selectedFeatureIndexes, this.props.mode]\n }\n }\n },\n\n updateTriggers: {\n getLineColor: [this.props.selectedFeatureIndexes, this.props.mode],\n getFillColor: [this.props.selectedFeatureIndexes, this.props.mode],\n getPointRadius: [this.props.selectedFeatureIndexes, this.props.mode],\n getLineWidth: [this.props.selectedFeatureIndexes, this.props.mode]\n }\n });\n\n let layers: any = [new GeoJsonLayer(subLayerProps)];\n\n layers = layers.concat(this.createGuidesLayers(), this.createTooltipsLayers());\n\n return layers;\n }\n\n initializeState() {\n super.initializeState();\n\n this.setState({\n selectedFeatures: [],\n editHandles: []\n });\n }\n\n // TODO: is this the best way to properly update state from an outside event handler?\n shouldUpdateState(opts: any) {\n // console.log(\n // 'shouldUpdateState',\n // opts.changeFlags.propsOrDataChanged,\n // opts.changeFlags.stateChanged\n // );\n return super.shouldUpdateState(opts) || opts.changeFlags.stateChanged;\n }\n\n updateState({props, oldProps, changeFlags, context}: UpdateParameters<this>) {\n super.updateState({oldProps, props, changeFlags, context});\n\n if (changeFlags.propsOrDataChanged) {\n const modePropChanged = Object.keys(oldProps).length === 0 || props.mode !== oldProps.mode;\n if (modePropChanged) {\n let mode: DrawPolygonMode;\n if (typeof props.mode === 'function') {\n // They passed a constructor/class, so new it up\n const ModeConstructor = props.mode;\n mode = new ModeConstructor();\n } else if (typeof props.mode === 'string') {\n // Lookup the mode based on its name (for backwards compatibility)\n mode = modeNameMapping[props.mode];\n // eslint-disable-next-line no-console\n console.warn(\n \"Deprecated use of passing `mode` as a string. Pass the mode's class constructor instead.\"\n );\n } else {\n // Should be an instance of EditMode in this case\n mode = props.mode;\n }\n\n if (!mode) {\n console.warn(`No mode configured for ${String(props.mode)}`); // eslint-disable-line no-console,no-undef\n // Use default mode\n mode = new DEFAULT_EDIT_MODE();\n }\n\n if (mode !== this.state.mode) {\n this.setState({mode, cursor: null});\n }\n }\n }\n\n let selectedFeatures = [];\n if (\n Array.isArray(props.selectedFeatureIndexes) &&\n typeof props.data === 'object' &&\n 'features' in props.data\n ) {\n // TODO: needs improved testing, i.e. checking for duplicates, NaNs, out of range numbers, ...\n const propsData = props.data;\n selectedFeatures = props.selectedFeatureIndexes.map((elem) => propsData.features[elem]);\n }\n\n this.setState({selectedFeatures});\n }\n\n getModeProps(props: EditableGeoJsonLayerProps<any>) {\n return {\n modeConfig: props.modeConfig,\n data: props.data,\n selectedIndexes: props.selectedFeatureIndexes,\n lastPointerMoveEvent: this.state.lastPointerMoveEvent,\n cursor: this.state.cursor,\n onEdit: (editAction: EditAction<FeatureCollection>) => {\n // Force a re-render\n // This supports double-click where we need to ensure that there's a re-render between the two clicks\n // even though the data wasn't changed, just the internal tentative feature.\n this.setNeedsUpdate();\n props.onEdit(editAction);\n },\n onUpdateCursor: (cursor: string | null | undefined) => {\n this.setState({cursor});\n }\n };\n }\n\n selectionAwareAccessor(accessor: any) {\n if (typeof accessor !== 'function') {\n return accessor;\n }\n return (feature: Feature) =>\n accessor(feature, this.isFeatureSelected(feature), this.props.mode);\n }\n\n isFeatureSelected(feature: Feature) {\n if (!this.props.data || !this.props.selectedFeatureIndexes) {\n return false;\n }\n if (!this.props.selectedFeatureIndexes.length) {\n return false;\n }\n\n return this.state.selectedFeatures.includes(feature);\n }\n\n getPickingInfo({info, sourceLayer}: Record<string, any>) {\n if (sourceLayer.id.endsWith('guides')) {\n // If user is picking an editing handle, add additional data to the info\n info.isGuide = true;\n }\n\n return info;\n }\n\n _updateAutoHighlight(info) {\n // Extra handling for guides\n if (info?.sourceLayer) {\n if (info.isGuide) {\n for (const layer of info.sourceLayer.getSubLayers()) {\n layer.updateAutoHighlight(info);\n }\n } else {\n info.sourceLayer.updateAutoHighlight(info);\n }\n }\n }\n\n createGuidesLayers() {\n const mode = this.getActiveMode();\n const guides: FeatureCollection = mode.getGuides(this.getModeProps(this.props));\n\n if (!guides || !guides.features.length) {\n return [];\n }\n\n const subLayerProps = {\n linestrings: {\n billboard: this.props.billboard,\n autoHighlight: false\n },\n 'polygons-fill': {\n autoHighlight: false\n },\n 'polygons-stroke': {\n billboard: this.props.billboard\n }\n };\n\n if (this.props.editHandleType === 'icon') {\n subLayerProps['points-icon'] = {\n type: IconLayer,\n iconAtlas: this.props.editHandleIconAtlas,\n iconMapping: this.props.editHandleIconMapping,\n sizeUnits: this.props.editHandleIconSizeUnits,\n sizeScale: this.props.editHandleIconSizeScale,\n getIcon: guideAccessor(this.props.getEditHandleIcon),\n getSize: guideAccessor(this.props.getEditHandleIconSize),\n getColor: guideAccessor(this.props.getEditHandleIconColor),\n getAngle: guideAccessor(this.props.getEditHandleIconAngle),\n billboard: this.props.billboard\n };\n } else {\n subLayerProps['points-circle'] = {\n type: ScatterplotLayer,\n radiusScale: this.props.editHandlePointRadiusScale,\n stroked: this.props.editHandlePointOutline,\n getLineWidth: this.props.editHandlePointStrokeWidth,\n radiusUnits: this.props.editHandlePointRadiusUnits,\n radiusMinPixels: this.props.editHandlePointRadiusMinPixels,\n radiusMaxPixels: this.props.editHandlePointRadiusMaxPixels,\n getRadius: guideAccessor(this.props.getEditHandlePointRadius),\n getFillColor: guideAccessor(this.props.getEditHandlePointColor),\n getLineColor: guideAccessor(this.props.getEditHandlePointOutlineColor),\n billboard: this.props.billboard\n };\n }\n\n const layer = new GeoJsonLayer(\n this.getSubLayerProps({\n id: 'guides',\n data: guides,\n fp64: this.props.fp64,\n _subLayerProps: subLayerProps,\n lineWidthScale: this.props.lineWidthScale,\n lineWidthMinPixels: this.props.lineWidthMinPixels,\n lineWidthMaxPixels: this.props.lineWidthMaxPixels,\n lineWidthUnits: this.props.lineWidthUnits,\n lineJointRounded: this.props.lineJointRounded,\n lineCapRounded: this.props.lineCapRounded,\n lineMiterLimit: this.props.lineMiterLimit,\n getLineColor: guideAccessor(this.props.getTentativeLineColor),\n getLineWidth: guideAccessor(this.props.getTentativeLineWidth),\n getFillColor: guideAccessor(this.props.getTentativeFillColor),\n pointType: this.props.editHandleType === 'icon' ? 'icon' : 'circle',\n iconAtlas: this.props.editHandleIconAtlas\n })\n );\n\n return [layer];\n }\n\n createTooltipsLayers() {\n const mode = this.getActiveMode();\n const tooltips = mode.getTooltips(this.getModeProps(this.props) as any);\n\n const layer = new TextLayer({\n getSize: DEFAULT_TOOLTIP_FONT_SIZE,\n ...this.getSubLayerProps({\n id: 'tooltips',\n data: tooltips\n })\n });\n\n return [layer];\n }\n\n onLayerClick(event: ClickEvent): void {\n this.getActiveMode().handleClick(event, this.getModeProps(this.props) as any);\n }\n\n onLayerDoubleClick(event: DoubleClickEvent): void {\n if (this.getActiveMode().handleDoubleClick) {\n this.getActiveMode().handleDoubleClick(event, this.getModeProps(this.props) as any);\n }\n }\n\n onLayerKeyUp(event: KeyboardEvent): void {\n this.getActiveMode().handleKeyUp(event, this.getModeProps(this.props) as any);\n }\n\n onStartDragging(event: StartDraggingEvent): void {\n this.getActiveMode().handleStartDragging(event, this.getModeProps(this.props) as any);\n }\n\n onDragging(event: DraggingEvent): void {\n this.getActiveMode().handleDragging(event, this.getModeProps(this.props) as any);\n }\n\n onStopDragging(event: StopDraggingEvent): void {\n this.getActiveMode().handleStopDragging(event, this.getModeProps(this.props) as any);\n }\n\n onPointerMove(event: PointerMoveEvent): void {\n this.setState({lastPointerMoveEvent: event});\n this.getActiveMode().handlePointerMove(event, this.getModeProps(this.props) as any);\n }\n\n getCursor({isDragging}: {isDragging: boolean}): null | 'grabbing' | 'grab' {\n if (this.state === null || this.state === undefined) {\n // Layer in 'Awaiting state'\n return null;\n }\n\n let {cursor} = this.state;\n if (!cursor) {\n // default cursor\n cursor = isDragging ? 'grabbing' : 'grab';\n }\n return cursor;\n }\n\n getActiveMode(): GeoJsonEditModeType {\n return this.state.mode;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfUnion from '@turf/union';\nimport turfDifference from '@turf/difference';\nimport turfIntersect from '@turf/intersect';\nimport rewind from '@turf/rewind';\n\nimport {\n EditAction,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n Pick,\n Tooltip,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {FeatureCollection, Feature, Polygon, Geometry, Position} from '../utils/geojson-types';\nimport {getPickedEditHandles, getNonGuidePicks} from './utils';\nimport {EditMode} from './edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport type GeoJsonEditAction = EditAction<FeatureCollection>;\n\nconst DEFAULT_GUIDES: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n};\nconst DEFAULT_TOOLTIPS: Tooltip[] = [];\n\n// Main interface for `EditMode`s that edit GeoJSON\nexport type GeoJsonEditModeType = EditMode<FeatureCollection, FeatureCollection>;\n\nexport interface GeoJsonEditModeConstructor {\n new (): GeoJsonEditModeType;\n}\n\nexport class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeatureCollection> {\n _clickSequence: Position[] = [];\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n return DEFAULT_GUIDES;\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return DEFAULT_TOOLTIPS;\n }\n\n getSelectedFeature(props: ModeProps<FeatureCollection>): Feature | null | undefined {\n if (props.selectedIndexes.length === 1) {\n return props.data.features[props.selectedIndexes[0]];\n }\n return null;\n }\n\n getSelectedGeometry(props: ModeProps<FeatureCollection>): Geometry | null | undefined {\n const feature = this.getSelectedFeature(props);\n if (feature) {\n return feature.geometry;\n }\n return null;\n }\n\n getSelectedFeaturesAsFeatureCollection(props: ModeProps<FeatureCollection>): FeatureCollection {\n const {features} = props.data;\n const selectedFeatures = props.selectedIndexes.map((selectedIndex) => features[selectedIndex]);\n return {\n type: 'FeatureCollection',\n features: selectedFeatures\n };\n }\n\n getClickSequence(): Position[] {\n return this._clickSequence;\n }\n\n addClickSequence({mapCoords}: ClickEvent): void {\n this._clickSequence.push(mapCoords);\n }\n\n resetClickSequence(): void {\n this._clickSequence = [];\n }\n\n getTentativeGuide(props: ModeProps<FeatureCollection>): TentativeFeature | null | undefined {\n const guides = this.getGuides(props);\n return guides.features.find(\n (f) => f.properties && f.properties.guideType === 'tentative'\n ) as TentativeFeature;\n }\n\n isSelectionPicked(picks: Pick[], props: ModeProps<FeatureCollection>): boolean {\n if (!picks.length) return false;\n const pickedFeatures = getNonGuidePicks(picks).map(({index}) => index);\n const pickedHandles = getPickedEditHandles(picks).map(\n ({properties}) => properties.featureIndex\n );\n const pickedIndexes = new Set([...pickedFeatures, ...pickedHandles]);\n return props.selectedIndexes.some((index) => pickedIndexes.has(index));\n }\n\n rewindPolygon(feature: Feature): Feature {\n const {geometry} = feature;\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n if (isPolygonal) {\n // @ts-expect-error turf type too wide\n return rewind(feature);\n }\n\n return feature;\n }\n\n getAddFeatureAction(\n featureOrGeometry: Geometry | Feature,\n features: FeatureCollection,\n featureProperties?: {}\n ): GeoJsonEditAction {\n // Unsure why flow can't deal with Geometry type, but there I fixed it\n const featureOrGeometryAsAny: any = featureOrGeometry;\n featureProperties = featureProperties || {};\n\n const feature: any =\n featureOrGeometryAsAny.type === 'Feature'\n ? featureOrGeometryAsAny\n : {\n type: 'Feature',\n properties: featureProperties,\n geometry: featureOrGeometryAsAny\n };\n\n const rewindFeature = this.rewindPolygon(feature);\n const updatedData = new ImmutableFeatureCollection(features)\n .addFeature(rewindFeature)\n .getObject();\n\n return {\n updatedData,\n editType: 'addFeature',\n editContext: {\n featureIndexes: [updatedData.features.length - 1]\n }\n };\n }\n\n getAddManyFeaturesAction(\n {features: featuresToAdd}: FeatureCollection,\n features: FeatureCollection\n ): GeoJsonEditAction {\n let updatedData = new ImmutableFeatureCollection(features);\n const initialIndex = updatedData.getObject().features.length;\n const updatedIndexes: number[] = [];\n for (const feature of featuresToAdd) {\n const {properties, geometry} = feature;\n const geometryAsAny: any = geometry;\n updatedData = updatedData.addFeature({\n type: 'Feature',\n properties,\n geometry: geometryAsAny\n });\n updatedIndexes.push(initialIndex + updatedIndexes.length);\n }\n\n return {\n updatedData: updatedData.getObject(),\n editType: 'addFeature',\n editContext: {\n featureIndexes: updatedIndexes\n }\n };\n }\n\n // eslint-disable-next-line complexity\n getAddFeatureOrBooleanPolygonAction(\n featureOrGeometry: Polygon | Feature,\n props: ModeProps<FeatureCollection>,\n featureProperties?: {}\n ): GeoJsonEditAction | null | undefined {\n const featureOrGeometryAsAny: any = featureOrGeometry;\n featureProperties = featureProperties || {};\n\n const selectedFeature = this.getSelectedFeature(props);\n const {modeConfig} = props;\n if (modeConfig && modeConfig.booleanOperation) {\n if (\n !selectedFeature ||\n (selectedFeature.geometry.type !== 'Polygon' &&\n selectedFeature.geometry.type !== 'MultiPolygon')\n ) {\n // eslint-disable-next-line no-console,no-undef\n console.warn(\n 'booleanOperation only supported for single Polygon or MultiPolygon selection'\n );\n return null;\n }\n\n const feature =\n featureOrGeometryAsAny.type === 'Feature'\n ? featureOrGeometryAsAny\n : {\n type: 'Feature',\n geometry: featureOrGeometryAsAny\n };\n\n let updatedGeometry;\n if (modeConfig.booleanOperation === 'union') {\n // @ts-expect-error selectedFeature type too wide\n updatedGeometry = turfUnion(selectedFeature, feature);\n } else if (modeConfig.booleanOperation === 'difference') {\n // @ts-expect-error selectedFeature type too wide\n updatedGeometry = turfDifference(selectedFeature, feature);\n } else if (modeConfig.booleanOperation === 'intersection') {\n // @ts-expect-error selectedFeature type too wide\n updatedGeometry = turfIntersect(selectedFeature, feature);\n } else {\n // eslint-disable-next-line no-console,no-undef\n console.warn(`Invalid booleanOperation ${modeConfig.booleanOperation}`);\n return null;\n }\n\n if (!updatedGeometry) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('Canceling edit. Boolean operation erased entire polygon.');\n return null;\n }\n\n const featureIndex = props.selectedIndexes[0];\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replaceGeometry(featureIndex, updatedGeometry.geometry)\n .getObject();\n\n const editAction: GeoJsonEditAction = {\n updatedData,\n editType: 'unionGeometry',\n editContext: {\n featureIndexes: [featureIndex]\n }\n };\n\n return editAction;\n }\n return this.getAddFeatureAction(featureOrGeometry, props.data, featureProperties);\n }\n\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature | null {\n return null;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {}\n handleDoubleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {}\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n const tentativeFeature = this.createTentativeFeature(props);\n if (tentativeFeature) {\n props.onEdit({\n updatedData: props.data,\n editType: 'updateTentativeFeature',\n editContext: {\n feature: tentativeFeature\n }\n });\n }\n }\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>): void {}\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>): void {}\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {}\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>): void {\n if (event.key === 'Escape') {\n this.resetClickSequence();\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n}\n\nexport function getIntermediatePosition(position1: Position, position2: Position): Position {\n const intermediatePosition: Position = [\n (position1[0] + position2[0]) / 2.0,\n (position1[1] + position2[1]) / 2.0\n ];\n\n return intermediatePosition;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable no-shadow */\n\nimport destination from '@turf/destination';\nimport bearing from '@turf/bearing';\nimport pointToLineDistance from '@turf/point-to-line-distance';\nimport {flattenEach} from '@turf/meta';\n// import type {MultiLineString} from '@turf/helpers';\nimport {point} from '@turf/helpers';\nimport {getCoords} from '@turf/invariant';\nimport {WebMercatorViewport} from 'viewport-mercator-project';\nimport {Viewport, Pick, EditHandleFeature, EditHandleType, StartDraggingEvent} from './types';\nimport {\n Geometry,\n Position,\n Point,\n LineString,\n Polygon,\n FeatureOf,\n FeatureWithProps,\n AnyCoordinates\n} from '../utils/geojson-types';\n\nexport type NearestPointType = FeatureWithProps<Point, {dist: number; index: number}>;\n\nexport function toDeckColor(\n color?: [number, number, number, number] | number,\n defaultColor: [number, number, number, number] = [255, 0, 0, 255]\n): [number, number, number, number] {\n if (!Array.isArray(color)) {\n return defaultColor;\n }\n return [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255];\n}\n\n//\n// a GeoJSON helper function that calls the provided function with\n// an argument that is the most deeply-nested array having elements\n// that are arrays of primitives as an argument, e.g.\n//\n// {\n// \"type\": \"MultiPolygon\",\n// \"coordinates\": [\n// [\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n// ],\n// [\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n// ]\n// ]\n// }\n//\n// the function would be called on:\n//\n// [[30, 20], [45, 40], [10, 40], [30, 20]]\n//\n// and\n//\n// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]\n//\nexport function recursivelyTraverseNestedArrays(\n array: Array<any>,\n prefix: Array<number>,\n fn: (array: Array<any>, prefix: number[]) => void\n) {\n if (!Array.isArray(array[0])) {\n return true;\n }\n for (let i = 0; i < array.length; i++) {\n if (recursivelyTraverseNestedArrays(array[i], [...prefix, i], fn)) {\n fn(array, prefix);\n break;\n }\n }\n return false;\n}\n\nexport function generatePointsParallelToLinePoints(\n p1: Position,\n p2: Position,\n coords: Position\n): Position[] {\n const lineString: LineString = {\n type: 'LineString',\n coordinates: [p1, p2]\n };\n const pt = point(coords);\n const ddistance = pointToLineDistance(pt, lineString);\n const lineBearing = bearing(p1, p2);\n\n // Check if current point is to the left or right of line\n // Line from A=(x1,y1) to B=(x2,y2) a point P=(x,y)\n // then (x\u2212x1)(y2\u2212y1)\u2212(y\u2212y1)(x2\u2212x1)\n const isPointToLeftOfLine =\n (coords[0] - p1[0]) * (p2[1] - p1[1]) - (coords[1] - p1[1]) * (p2[0] - p1[0]);\n\n // Bearing to draw perpendicular to the line string\n const orthogonalBearing = isPointToLeftOfLine < 0 ? lineBearing - 90 : lineBearing - 270;\n\n // Get coordinates for the point p3 and p4 which are perpendicular to the lineString\n // Add the distance as the current position moves away from the lineString\n const p3 = destination(p2, ddistance, orthogonalBearing);\n const p4 = destination(p1, ddistance, orthogonalBearing);\n\n return [p3.geometry.coordinates, p4.geometry.coordinates] as Position[];\n}\n\nexport function distance2d(x1: number, y1: number, x2: number, y2: number): number {\n const dx = x1 - x2;\n const dy = y1 - y2;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nexport function mix(a: number, b: number, ratio: number): number {\n return b * ratio + a * (1 - ratio);\n}\n\nexport function nearestPointOnProjectedLine(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport\n): NearestPointType {\n const wmViewport = new WebMercatorViewport(viewport);\n // Project the line to viewport, then find the nearest point\n const coordinates: Array<Array<number>> = line.geometry.coordinates as any;\n const projectedCoords = coordinates.map(([x, y, z = 0]) => wmViewport.project([x, y, z]));\n const [x, y] = wmViewport.project(inPoint.geometry.coordinates);\n // console.log('projectedCoords', JSON.stringify(projectedCoords));\n\n let minDistance = Infinity;\n let minPointInfo = {};\n\n projectedCoords.forEach(([x2, y2], index) => {\n if (index === 0) {\n return;\n }\n\n const [x1, y1] = projectedCoords[index - 1];\n\n // line from projectedCoords[index - 1] to projectedCoords[index]\n // convert to Ax + By + C = 0\n const A = y1 - y2;\n const B = x2 - x1;\n const C = x1 * y2 - x2 * y1;\n\n // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line\n const div = A * A + B * B;\n const distance = Math.abs(A * x + B * y + C) / Math.sqrt(div);\n\n // TODO: Check if inside bounds\n\n if (distance < minDistance) {\n minDistance = distance;\n minPointInfo = {\n index,\n x0: (B * (B * x - A * y) - A * C) / div,\n y0: (A * (-B * x + A * y) - B * C) / div\n };\n }\n });\n // @ts-expect-error TODO\n const {index, x0, y0} = minPointInfo;\n const [x1, y1, z1 = 0] = projectedCoords[index - 1];\n const [x2, y2, z2 = 0] = projectedCoords[index];\n\n // calculate what ratio of the line we are on to find the proper z\n const lineLength = distance2d(x1, y1, x2, y2);\n const startToPointLength = distance2d(x1, y1, x0, y0);\n const ratio = startToPointLength / lineLength;\n const z0 = mix(z1, z2, ratio);\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: wmViewport.unproject([x0, y0, z0])\n },\n properties: {\n // TODO: calculate the distance in proper units\n dist: minDistance,\n index: index - 1\n }\n };\n}\n\nexport function nearestPointOnLine( // <G extends LineString | MultiLineString>(\n lines: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport?: Viewport\n): NearestPointType {\n let mercator;\n\n if (viewport) {\n mercator = new WebMercatorViewport(viewport);\n }\n let closestPoint: any = point([Infinity, Infinity], {\n dist: Infinity\n });\n\n if (!lines.geometry?.coordinates.length || lines.geometry?.coordinates.length < 2) {\n return closestPoint;\n }\n\n // @ts-expect-error TODO\n // eslint-disable-next-line max-statements, complexity\n flattenEach(lines, (line: any) => {\n const coords: any = getCoords(line);\n // @ts-expect-error TODO\n const pointCoords: any = getCoords(inPoint);\n\n let minDist;\n let to;\n let from;\n let x;\n let y;\n let segmentIdx;\n let dist;\n\n if (coords.length > 1 && pointCoords.length) {\n let lineCoordinates;\n let pointCoordinate;\n\n // If viewport is given, then translate these coordinates to pixels to increase precision\n if (mercator) {\n lineCoordinates = coords.map((lineCoordinate) => mercator.project(lineCoordinate));\n pointCoordinate = mercator.project(pointCoords);\n } else {\n lineCoordinates = coords;\n pointCoordinate = pointCoords;\n }\n\n for (let n = 1; n < lineCoordinates.length; n++) {\n if (lineCoordinates[n][0] !== lineCoordinates[n - 1][0]) {\n const slope =\n (lineCoordinates[n][1] - lineCoordinates[n - 1][1]) /\n (lineCoordinates[n][0] - lineCoordinates[n - 1][0]);\n const inverseSlope = lineCoordinates[n][1] - slope * lineCoordinates[n][0];\n\n dist =\n Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) /\n Math.sqrt(slope * slope + 1);\n } else dist = Math.abs(pointCoordinate[0] - lineCoordinates[n][0]);\n\n // length^2 of line segment\n const rl2 =\n Math.pow(lineCoordinates[n][1] - lineCoordinates[n - 1][1], 2) +\n Math.pow(lineCoordinates[n][0] - lineCoordinates[n - 1][0], 2);\n\n // distance^2 of pt to end line segment\n const ln2 =\n Math.pow(lineCoordinates[n][1] - pointCoordinate[1], 2) +\n Math.pow(lineCoordinates[n][0] - pointCoordinate[0], 2);\n\n // distance^2 of pt to begin line segment\n const lnm12 =\n Math.pow(lineCoordinates[n - 1][1] - pointCoordinate[1], 2) +\n Math.pow(lineCoordinates[n - 1][0] - pointCoordinate[0], 2);\n\n // minimum distance^2 of pt to infinite line\n const dist2 = Math.pow(dist, 2);\n\n // calculated length^2 of line segment\n const calcrl2 = ln2 - dist2 + lnm12 - dist2;\n\n // redefine minimum distance to line segment (not infinite line) if necessary\n if (calcrl2 > rl2) {\n dist = Math.sqrt(Math.min(ln2, lnm12));\n }\n\n if (minDist === null || minDist === undefined || minDist > dist) {\n // eslint-disable-next-line max-depth\n if (calcrl2 > rl2) {\n // eslint-disable-next-line max-depth\n if (lnm12 < ln2) {\n to = 0; // nearer to previous point\n from = 1;\n } else {\n from = 0; // nearer to current point\n to = 1;\n }\n } else {\n // perpendicular from point intersects line segment\n to = Math.sqrt(lnm12 - dist2) / Math.sqrt(rl2);\n from = Math.sqrt(ln2 - dist2) / Math.sqrt(rl2);\n }\n minDist = dist;\n segmentIdx = n;\n }\n }\n\n const dx = lineCoordinates[segmentIdx - 1][0] - lineCoordinates[segmentIdx][0];\n const dy = lineCoordinates[segmentIdx - 1][1] - lineCoordinates[segmentIdx][1];\n\n x = lineCoordinates[segmentIdx - 1][0] - dx * to;\n y = lineCoordinates[segmentIdx - 1][1] - dy * to;\n }\n\n // index needs to be -1 because we have to account for the shift from initial backscan\n let snapPoint = {x, y, idx: segmentIdx - 1, to, from};\n\n if (mercator) {\n const pixelToLatLong = mercator.unproject([snapPoint.x, snapPoint.y]);\n snapPoint = {\n x: pixelToLatLong[0],\n y: pixelToLatLong[1],\n idx: segmentIdx - 1,\n to,\n from\n };\n }\n\n closestPoint = point([snapPoint.x, snapPoint.y], {\n dist: Math.abs(snapPoint.from - snapPoint.to),\n index: snapPoint.idx\n });\n });\n\n return closestPoint;\n}\n\nexport function getPickedEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.length ? handles[0] : null;\n}\n\nexport function getPickedSnapSourceEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.find((handle) => handle.properties.editHandleType === 'snap-source');\n}\n\nexport function getNonGuidePicks(picks: Pick[]): Pick[] {\n return picks && picks.filter((pick) => !pick.isGuide);\n}\n\nexport function getPickedExistingEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.find(\n ({properties}) => properties.featureIndex >= 0 && properties.editHandleType === 'existing'\n );\n}\n\nexport function getPickedIntermediateEditHandle(\n picks: Pick[] | null | undefined\n): EditHandleFeature | null | undefined {\n const handles = getPickedEditHandles(picks);\n return handles.find(\n ({properties}) => properties.featureIndex >= 0 && properties.editHandleType === 'intermediate'\n );\n}\n\nexport function getPickedEditHandles(picks: Pick[] | null | undefined): EditHandleFeature[] {\n const handles =\n (picks &&\n picks\n .filter((pick) => pick.isGuide && pick.object.properties.guideType === 'editHandle')\n .map((pick) => pick.object)) ||\n [];\n\n return handles;\n}\n\nexport function getEditHandlesForGeometry(\n geometry: Geometry,\n featureIndex: number,\n editHandleType: EditHandleType = 'existing'\n): EditHandleFeature[] {\n let handles: EditHandleFeature[] = [];\n\n switch (geometry.type) {\n case 'Point':\n // positions are not nested\n handles = [\n {\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType,\n positionIndexes: [],\n featureIndex\n },\n geometry: {\n type: 'Point',\n coordinates: geometry.coordinates\n }\n }\n ];\n break;\n case 'MultiPoint':\n case 'LineString':\n // positions are nested 1 level\n handles = handles.concat(\n getEditHandlesForCoordinates(geometry.coordinates, [], featureIndex, editHandleType)\n );\n break;\n case 'Polygon':\n case 'MultiLineString':\n // positions are nested 2 levels\n for (let a = 0; a < geometry.coordinates.length; a++) {\n handles = handles.concat(\n getEditHandlesForCoordinates(geometry.coordinates[a], [a], featureIndex, editHandleType)\n );\n if (geometry.type === 'Polygon') {\n // Don't repeat the first/last handle for Polygons\n handles = handles.slice(0, -1);\n }\n }\n\n break;\n case 'MultiPolygon':\n // positions are nested 3 levels\n for (let a = 0; a < geometry.coordinates.length; a++) {\n for (let b = 0; b < geometry.coordinates[a].length; b++) {\n handles = handles.concat(\n getEditHandlesForCoordinates(\n geometry.coordinates[a][b],\n [a, b],\n featureIndex,\n editHandleType\n )\n );\n // Don't repeat the first/last handle for Polygons\n handles = handles.slice(0, -1);\n }\n }\n\n break;\n default:\n throw Error(`Unhandled geometry type: ${(geometry as {type: string}).type}`);\n }\n\n return handles;\n}\n\nfunction getEditHandlesForCoordinates(\n coordinates: any[],\n positionIndexPrefix: number[],\n featureIndex: number,\n editHandleType: EditHandleType = 'existing'\n): EditHandleFeature[] {\n const editHandles: EditHandleFeature[] = [];\n for (let i = 0; i < coordinates.length; i++) {\n const position = coordinates[i] as Position;\n editHandles.push({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n positionIndexes: [...positionIndexPrefix, i],\n featureIndex,\n editHandleType\n },\n geometry: {\n type: 'Point',\n coordinates: position\n }\n });\n }\n return editHandles;\n}\n\n/**\n * Calculates coordinates for a feature preserving rectangular shape.\n * @param feature Feature before modification.\n * @param editHandleIndex Index of the point to modify.\n * @param coords New position for the point.\n * @returns Updated coordinates.\n */\nexport function updateRectanglePosition(\n feature: FeatureOf<Polygon>,\n editHandleIndex: number,\n coords: Position\n): Position[][] | null {\n const coordinates = feature.geometry.coordinates;\n if (!coordinates) {\n return null;\n }\n\n const points = coordinates[0].slice(0, 4);\n points[editHandleIndex % 4] = coords;\n\n const p0 = points[(editHandleIndex + 2) % 4];\n const p2 = points[editHandleIndex % 4];\n points[(editHandleIndex + 1) % 4] = [p2[0], p0[1]];\n points[(editHandleIndex + 3) % 4] = [p0[0], p2[1]];\n\n return [[...points, points[0]]];\n}\n\n/** Creates a copy of feature's coordinates.\n * Each position in coordinates is transformed by calling the provided function.\n * @param coords Coordinates of a feature.\n * @param callback A function to transform each coordinate.\n * @retuns Transformed coordinates.\n */\nexport function mapCoords(\n coords: AnyCoordinates,\n callback: (coords: Position) => Position\n): AnyCoordinates {\n if (typeof coords[0] === 'number') {\n if (!isNaN(coords[0]) && isFinite(coords[0])) {\n return callback(coords as Position);\n }\n return coords;\n }\n\n return (coords as Position[])\n .map((coord) => {\n return mapCoords(coord, callback) as Position;\n })\n .filter(Boolean);\n}\n\nexport function shouldCancelPan(event: StartDraggingEvent) {\n return event.picks.length && event.picks.find((p) => p.featureType === 'points');\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n Feature,\n FeatureCollection,\n Geometry,\n Polygon,\n MultiLineString,\n MultiPolygon,\n Position,\n PolygonCoordinates\n} from '../utils/geojson-types';\n\nexport class ImmutableFeatureCollection {\n featureCollection: FeatureCollection;\n\n constructor(featureCollection: FeatureCollection) {\n this.featureCollection = featureCollection;\n }\n\n getObject() {\n return this.featureCollection;\n }\n\n /**\n * Replaces the position deeply nested withing the given feature's geometry.\n * Works with Point, MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon.\n *\n * @param featureIndex The index of the feature to update\n * @param positionIndexes An array containing the indexes of the position to replace\n * @param updatedPosition The updated position to place in the result (i.e. [lng, lat])\n *\n * @returns A new `ImmutableFeatureCollection` with the given position replaced. Does not modify this `ImmutableFeatureCollection`.\n */\n replacePosition(\n featureIndex: number,\n positionIndexes: number[] | null | undefined,\n updatedPosition: Position\n ): ImmutableFeatureCollection {\n const geometry = this.featureCollection.features[featureIndex].geometry;\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n const updatedGeometry: any = {\n ...geometry,\n coordinates: immutablyReplacePosition(\n geometry.coordinates,\n positionIndexes,\n updatedPosition,\n isPolygonal\n )\n };\n\n return this.replaceGeometry(featureIndex, updatedGeometry);\n }\n\n /**\n * Removes a position deeply nested in a GeoJSON geometry coordinates array.\n * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon.\n *\n * @param featureIndex The index of the feature to update\n * @param positionIndexes An array containing the indexes of the postion to remove\n *\n * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`.\n *\n */\n // eslint-disable-next-line complexity\n removePosition(\n featureIndex: number,\n positionIndexes: number[] | null | undefined\n ): ImmutableFeatureCollection {\n const geometry = this.featureCollection.features[featureIndex].geometry;\n\n if (geometry.type === 'Point') {\n throw Error(\"Can't remove a position from a Point or there'd be nothing left\");\n }\n if (\n geometry.type === 'MultiPoint' && // only 1 point left\n geometry.coordinates.length < 2\n ) {\n throw Error(\"Can't remove the last point of a MultiPoint or there'd be nothing left\");\n }\n if (\n geometry.type === 'LineString' && // only 2 positions\n geometry.coordinates.length < 3\n ) {\n throw Error(\"Can't remove position. LineString must have at least two positions\");\n }\n if (\n geometry.type === 'Polygon' && // outer ring is a triangle\n geometry.coordinates[0].length < 5 &&\n Array.isArray(positionIndexes) && // trying to remove from outer ring\n positionIndexes[0] === 0\n ) {\n throw Error(\"Can't remove position. Polygon's outer ring must have at least four positions\");\n }\n if (\n geometry.type === 'MultiLineString' && // only 1 LineString left\n geometry.coordinates.length === 1 && // only 2 positions\n geometry.coordinates[0].length < 3\n ) {\n throw Error(\"Can't remove position. MultiLineString must have at least two positions\");\n }\n if (\n geometry.type === 'MultiPolygon' && // only 1 polygon left\n geometry.coordinates.length === 1 && // outer ring is a triangle\n geometry.coordinates[0][0].length < 5 &&\n Array.isArray(positionIndexes) && // trying to remove from first polygon\n positionIndexes[0] === 0 && // trying to remove from outer ring\n positionIndexes[1] === 0\n ) {\n throw Error(\n \"Can't remove position. MultiPolygon's outer ring must have at least four positions\"\n );\n }\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n const updatedGeometry: any = {\n ...geometry,\n coordinates: immutablyRemovePosition(geometry.coordinates, positionIndexes, isPolygonal)\n };\n\n // Handle cases where incomplete geometries need pruned (e.g. holes that were triangles)\n pruneGeometryIfNecessary(updatedGeometry);\n\n return this.replaceGeometry(featureIndex, updatedGeometry);\n }\n\n /**\n * Adds a position deeply nested in a GeoJSON geometry coordinates array.\n * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon.\n *\n * @param featureIndex The index of the feature to update\n * @param positionIndexes An array containing the indexes of the position that will proceed the new position\n * @param positionToAdd The new position to place in the result (i.e. [lng, lat])\n *\n * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`.\n */\n addPosition(\n featureIndex: number,\n positionIndexes: number[] | null | undefined,\n positionToAdd: Position\n ): ImmutableFeatureCollection {\n const geometry = this.featureCollection.features[featureIndex].geometry;\n\n if (geometry.type === 'Point') {\n throw new Error('Unable to add a position to a Point feature');\n }\n\n const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';\n const updatedGeometry: any = {\n ...geometry,\n coordinates: immutablyAddPosition(\n geometry.coordinates,\n positionIndexes,\n positionToAdd,\n isPolygonal\n )\n };\n\n return this.replaceGeometry(featureIndex, updatedGeometry);\n }\n\n replaceGeometry(featureIndex: number, geometry: Geometry): ImmutableFeatureCollection {\n const updatedFeature: any = {\n ...this.featureCollection.features[featureIndex],\n geometry\n };\n\n const updatedFeatureCollection = {\n ...this.featureCollection,\n features: [\n ...this.featureCollection.features.slice(0, featureIndex),\n updatedFeature,\n ...this.featureCollection.features.slice(featureIndex + 1)\n ]\n };\n\n return new ImmutableFeatureCollection(updatedFeatureCollection);\n }\n\n addFeature(feature: Feature): ImmutableFeatureCollection {\n return this.addFeatures([feature]);\n }\n\n addFeatures(features: Feature[]): ImmutableFeatureCollection {\n const updatedFeatureCollection = {\n ...this.featureCollection,\n features: [...this.featureCollection.features, ...features]\n };\n\n return new ImmutableFeatureCollection(updatedFeatureCollection);\n }\n\n deleteFeature(featureIndex: number) {\n return this.deleteFeatures([featureIndex]);\n }\n\n deleteFeatures(featureIndexes: number[]) {\n const features = [...this.featureCollection.features];\n featureIndexes.sort();\n for (let i = featureIndexes.length - 1; i >= 0; i--) {\n const featureIndex = featureIndexes[i];\n if (featureIndex >= 0 && featureIndex < features.length) {\n features.splice(featureIndex, 1);\n }\n }\n\n const updatedFeatureCollection = {\n ...this.featureCollection,\n features\n };\n\n return new ImmutableFeatureCollection(updatedFeatureCollection);\n }\n}\n\nfunction getUpdatedPosition(updatedPosition: Position, previousPosition: Position): Position {\n // This function checks if the updatedPosition is missing elevation\n // and copies it from previousPosition\n if (updatedPosition.length === 2 && previousPosition.length === 3) {\n const elevation = (previousPosition as any)[2];\n return [updatedPosition[0], updatedPosition[1], elevation];\n }\n\n return updatedPosition;\n}\n\nfunction immutablyReplacePosition(\n coordinates: any,\n positionIndexes: number[] | null | undefined,\n updatedPosition: Position,\n isPolygonal: boolean\n): any {\n if (!positionIndexes) {\n return coordinates;\n }\n if (positionIndexes.length === 0) {\n return getUpdatedPosition(updatedPosition, coordinates);\n }\n if (positionIndexes.length === 1) {\n const updated = [\n ...coordinates.slice(0, positionIndexes[0]),\n getUpdatedPosition(updatedPosition, coordinates[positionIndexes[0]]),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n\n if (\n isPolygonal &&\n (positionIndexes[0] === 0 || positionIndexes[0] === coordinates.length - 1)\n ) {\n // for polygons, the first point is repeated at the end of the array\n // so, update it on both ends of the array\n updated[0] = getUpdatedPosition(updatedPosition, coordinates[0]);\n updated[coordinates.length - 1] = getUpdatedPosition(updatedPosition, coordinates[0]);\n }\n return updated;\n }\n\n // recursively update inner array\n return [\n ...coordinates.slice(0, positionIndexes[0]),\n immutablyReplacePosition(\n coordinates[positionIndexes[0]],\n positionIndexes.slice(1, positionIndexes.length),\n updatedPosition,\n isPolygonal\n ),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n}\n\nfunction immutablyRemovePosition(\n coordinates: any,\n positionIndexes: number[] | null | undefined,\n isPolygonal: boolean\n): any {\n if (!positionIndexes) {\n return coordinates;\n }\n if (positionIndexes.length === 0) {\n throw Error('Must specify the index of the position to remove');\n }\n if (positionIndexes.length === 1) {\n const updated = [\n ...coordinates.slice(0, positionIndexes[0]),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n\n if (\n isPolygonal &&\n (positionIndexes[0] === 0 || positionIndexes[0] === coordinates.length - 1)\n ) {\n // for polygons, the first point is repeated at the end of the array\n // so, if the first/last coordinate is to be removed, coordinates[1] will be the new first/last coordinate\n if (positionIndexes[0] === 0) {\n // change the last to be the same as the first\n updated[updated.length - 1] = updated[0];\n } else if (positionIndexes[0] === coordinates.length - 1) {\n // change the first to be the same as the last\n updated[0] = updated[updated.length - 1];\n }\n }\n return updated;\n }\n\n // recursively update inner array\n return [\n ...coordinates.slice(0, positionIndexes[0]),\n immutablyRemovePosition(\n coordinates[positionIndexes[0]],\n positionIndexes.slice(1, positionIndexes.length),\n isPolygonal\n ),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n}\n\nfunction immutablyAddPosition(\n coordinates: any,\n positionIndexes: number[] | null | undefined,\n positionToAdd: Position,\n isPolygonal: boolean\n): any {\n if (!positionIndexes) {\n return coordinates;\n }\n if (positionIndexes.length === 0) {\n throw Error('Must specify the index of the position to remove');\n }\n if (positionIndexes.length === 1) {\n const updated = [\n ...coordinates.slice(0, positionIndexes[0]),\n positionToAdd,\n ...coordinates.slice(positionIndexes[0])\n ];\n return updated;\n }\n\n // recursively update inner array\n return [\n ...coordinates.slice(0, positionIndexes[0]),\n immutablyAddPosition(\n coordinates[positionIndexes[0]],\n positionIndexes.slice(1, positionIndexes.length),\n positionToAdd,\n isPolygonal\n ),\n ...coordinates.slice(positionIndexes[0] + 1)\n ];\n}\n\nfunction pruneGeometryIfNecessary(geometry: Geometry) {\n switch (geometry.type) {\n case 'Polygon':\n prunePolygonIfNecessary(geometry);\n break;\n case 'MultiLineString':\n pruneMultiLineStringIfNecessary(geometry);\n break;\n case 'MultiPolygon':\n pruneMultiPolygonIfNecessary(geometry);\n break;\n default:\n // Not downgradable\n break;\n }\n}\n\nfunction prunePolygonIfNecessary(geometry: Polygon) {\n const polygon = geometry.coordinates;\n\n // If any hole is no longer a polygon, remove the hole entirely\n for (let holeIndex = 1; holeIndex < polygon.length; holeIndex++) {\n if (removeHoleIfNecessary(polygon, holeIndex)) {\n // It was removed, so keep the index the same\n holeIndex--;\n }\n }\n}\n\nfunction pruneMultiLineStringIfNecessary(geometry: MultiLineString) {\n for (let lineStringIndex = 0; lineStringIndex < geometry.coordinates.length; lineStringIndex++) {\n const lineString = geometry.coordinates[lineStringIndex];\n if (lineString.length === 1) {\n // Only a single position left on this LineString, so remove it (can't have Point in MultiLineString)\n geometry.coordinates.splice(lineStringIndex, 1);\n // Keep the index the same\n lineStringIndex--;\n }\n }\n}\n\nfunction pruneMultiPolygonIfNecessary(geometry: MultiPolygon) {\n for (let polygonIndex = 0; polygonIndex < geometry.coordinates.length; polygonIndex++) {\n const polygon = geometry.coordinates[polygonIndex];\n const outerRing = polygon[0];\n\n // If the outer ring is no longer a polygon, remove the whole polygon\n if (outerRing.length <= 3) {\n geometry.coordinates.splice(polygonIndex, 1);\n // It was removed, so keep the index the same\n polygonIndex--;\n }\n\n for (let holeIndex = 1; holeIndex < polygon.length; holeIndex++) {\n if (removeHoleIfNecessary(polygon, holeIndex)) {\n // It was removed, so keep the index the same\n holeIndex--;\n }\n }\n }\n}\n\nfunction removeHoleIfNecessary(polygon: PolygonCoordinates, holeIndex: number) {\n const hole = polygon[holeIndex];\n if (hole.length <= 3) {\n polygon.splice(holeIndex, 1);\n return true;\n }\n return false;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class ViewMode extends GeoJsonEditMode {}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfBearing from '@turf/bearing';\nimport turfDistance from '@turf/distance';\nimport clone from '@turf/clone';\nimport type {Feature as TurfFeature, Geometry as TurfGeometry} from '@turf/helpers';\nimport {point} from '@turf/helpers';\nimport {WebMercatorViewport} from 'viewport-mercator-project';\nimport {FeatureCollection, Position, Geometry} from '../utils/geojson-types';\nimport {\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps\n} from './types';\nimport {mapCoords} from './utils';\nimport {translateFromCenter} from '../utils/translate-from-center';\nimport {GeoJsonEditMode, GeoJsonEditAction} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class TranslateMode extends GeoJsonEditMode {\n _geometryBeforeTranslate: FeatureCollection | null | undefined;\n _isTranslatable: boolean = undefined!;\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isTranslatable) {\n // Nothing to do\n return;\n }\n\n if (this._geometryBeforeTranslate) {\n // Translate the geometry\n const editAction = this.getTranslateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'translating',\n props\n );\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n\n // cancel map panning\n event.cancelPan();\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n this._isTranslatable = this.isSelectionPicked(event.pointerDownPicks || event.picks, props);\n\n this.updateCursor(props);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isTranslatable) {\n return;\n }\n\n event.cancelPan();\n this._geometryBeforeTranslate = this.getSelectedFeaturesAsFeatureCollection(props);\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._geometryBeforeTranslate) {\n // Translate the geometry\n const editAction = this.getTranslateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'translated',\n props\n );\n\n if (editAction) {\n props.onEdit(editAction);\n }\n\n this._geometryBeforeTranslate = null;\n }\n }\n\n updateCursor(props: ModeProps<FeatureCollection>) {\n if (this._isTranslatable) {\n props.onUpdateCursor('move');\n } else {\n props.onUpdateCursor(null);\n }\n }\n\n // eslint-disable-next-line max-statements\n getTranslateAction(\n startDragPoint: Position,\n currentPoint: Position,\n editType: string,\n props: ModeProps<FeatureCollection>\n ): GeoJsonEditAction | null | undefined {\n if (!this._geometryBeforeTranslate) {\n return null;\n }\n\n let updatedData = new ImmutableFeatureCollection(props.data);\n const selectedIndexes = props.selectedIndexes;\n\n const {viewport: viewportDesc, screenSpace} = props.modeConfig || {};\n\n // move features without adapting to mercator projection\n if (viewportDesc && screenSpace) {\n const viewport = viewportDesc.project ? viewportDesc : new WebMercatorViewport(viewportDesc);\n\n const from = viewport.project(startDragPoint);\n const to = viewport.project(currentPoint);\n const dx = to[0] - from[0];\n const dy = to[1] - from[1];\n\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const feature = this._geometryBeforeTranslate.features[i];\n\n let coordinates = feature.geometry.coordinates;\n if (coordinates) {\n coordinates = mapCoords(coordinates, (coord) => {\n const pixels = viewport.project(coord);\n if (pixels) {\n pixels[0] += dx;\n pixels[1] += dy;\n return viewport.unproject(pixels);\n }\n return null;\n });\n\n // @ts-expect-error turf types\n updatedData = updatedData.replaceGeometry(selectedIndex, {\n type: feature.geometry.type,\n coordinates\n });\n }\n }\n } else {\n const p1 = point(startDragPoint);\n const p2 = point(currentPoint);\n\n const distanceMoved = turfDistance(p1, p2);\n const direction = turfBearing(p1, p2);\n\n const movedFeatures = this._geometryBeforeTranslate.features.map((feature) =>\n translateFromCenter(clone(feature as TurfFeature<TurfGeometry>), distanceMoved, direction)\n );\n\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const movedFeature = movedFeatures[i];\n updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry as Geometry);\n }\n }\n\n return {\n updatedData: updatedData.getObject(),\n editType,\n editContext: {\n featureIndexes: selectedIndexes\n }\n };\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfCenter from '@turf/center';\nimport turfRhumbBearing from '@turf/rhumb-bearing';\nimport turfRhumbDistance from '@turf/rhumb-distance';\nimport turfRhumbDestination from '@turf/rhumb-destination';\nimport type {\n Position as TurfPosition,\n Feature as TurfFeature,\n Geometry as TurfGeometry\n} from '@turf/helpers';\nimport {mapCoords} from '../edit-modes/utils';\nimport type {AnyCoordinates /* , Position */} from './geojson-types';\n\n// This function takes feature's center, moves it,\n// and builds new feature around it keeping the proportions\nexport function translateFromCenter(\n feature: TurfFeature<TurfGeometry>,\n distance: number,\n direction: number\n) {\n const initialCenterPoint = turfCenter(feature as TurfFeature);\n\n const movedCenterPoint = turfRhumbDestination(initialCenterPoint, distance, direction);\n\n const movedCoordinates = mapCoords(\n feature.geometry.coordinates as AnyCoordinates,\n (coordinate) => {\n const rhumbDistance = turfRhumbDistance(\n initialCenterPoint.geometry.coordinates,\n coordinate as TurfPosition\n );\n const rhumbDirection = turfRhumbBearing(\n initialCenterPoint.geometry.coordinates,\n coordinate as TurfPosition\n );\n\n const movedPosition = turfRhumbDestination(\n movedCenterPoint.geometry.coordinates,\n rhumbDistance,\n rhumbDirection\n ).geometry.coordinates;\n return movedPosition;\n }\n );\n\n feature.geometry.coordinates = movedCoordinates;\n\n return feature;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {point, lineString as toLineString} from '@turf/helpers';\nimport {\n recursivelyTraverseNestedArrays,\n nearestPointOnProjectedLine,\n nearestPointOnLine,\n getEditHandlesForGeometry,\n getPickedEditHandles,\n getPickedEditHandle,\n getPickedExistingEditHandle,\n getPickedIntermediateEditHandle,\n updateRectanglePosition,\n NearestPointType,\n shouldCancelPan\n} from './utils';\nimport {LineString, Point, Polygon, FeatureCollection, FeatureOf} from '../utils/geojson-types';\nimport {\n ModeProps,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n Viewport,\n GuideFeatureCollection,\n EditHandleFeature,\n GuideFeature\n} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ModifyMode extends GeoJsonEditMode {\n // eslint-disable-next-line complexity\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const handles: GuideFeature[] = [];\n\n const {data, lastPointerMoveEvent} = props;\n const {features} = data;\n const picks = lastPointerMoveEvent && lastPointerMoveEvent.picks;\n const mapCoords = lastPointerMoveEvent && lastPointerMoveEvent.mapCoords;\n\n for (const index of props.selectedIndexes) {\n if (index < features.length) {\n const {geometry} = features[index];\n handles.push(...getEditHandlesForGeometry(geometry, index));\n } else {\n console.warn(`selectedFeatureIndexes out of range ${index}`); // eslint-disable-line no-console,no-undef\n }\n }\n\n // intermediate edit handle\n if (picks && picks.length && mapCoords) {\n const existingEditHandle = getPickedExistingEditHandle(picks);\n // don't show intermediate point when too close to an existing edit handle\n const featureAsPick = !existingEditHandle && picks.find((pick) => !pick.isGuide);\n\n // is the feature in the pick selected\n if (\n featureAsPick &&\n !featureAsPick.object.geometry.type.includes('Point') &&\n !(\n props.modeConfig?.lockRectangles && featureAsPick.object.properties.shape === 'Rectangle'\n ) &&\n props.selectedIndexes.includes(featureAsPick.index)\n ) {\n let intermediatePoint: NearestPointType | null | undefined = null;\n let positionIndexPrefix: number[] = [];\n const referencePoint = point(mapCoords);\n // process all lines of the (single) feature\n recursivelyTraverseNestedArrays(\n featureAsPick.object.geometry.coordinates,\n [],\n (lineString, prefix) => {\n const lineStringFeature = toLineString(lineString);\n const candidateIntermediatePoint = this.getNearestPoint(\n // @ts-expect-error turf types too wide\n lineStringFeature,\n referencePoint,\n props.modeConfig && props.modeConfig.viewport\n );\n if (\n !intermediatePoint ||\n candidateIntermediatePoint.properties.dist < intermediatePoint.properties.dist\n ) {\n intermediatePoint = candidateIntermediatePoint;\n positionIndexPrefix = prefix;\n }\n }\n );\n // tack on the lone intermediate point to the set of handles\n if (intermediatePoint) {\n const {\n geometry: {coordinates: position},\n properties: {index}\n } = intermediatePoint;\n handles.push({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'intermediate',\n featureIndex: featureAsPick.index,\n positionIndexes: [...positionIndexPrefix, index + 1]\n },\n geometry: {\n type: 'Point',\n coordinates: position\n }\n });\n }\n }\n }\n\n return {\n type: 'FeatureCollection',\n features: handles\n };\n }\n\n // turf.js does not support elevation for nearestPointOnLine\n getNearestPoint(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport | null | undefined\n ): NearestPointType {\n const {coordinates} = line.geometry;\n if (coordinates.some((coord) => coord.length > 2)) {\n if (viewport) {\n // This line has elevation, we need to use alternative algorithm\n return nearestPointOnProjectedLine(line, inPoint, viewport);\n }\n // eslint-disable-next-line no-console,no-undef\n console.log(\n 'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'\n );\n }\n return nearestPointOnLine(line, inPoint, viewport);\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const pickedExistingHandle = getPickedExistingEditHandle(event.picks);\n const pickedIntermediateHandle = getPickedIntermediateEditHandle(event.picks);\n\n if (pickedExistingHandle) {\n const {featureIndex, positionIndexes} = pickedExistingHandle.properties;\n\n let updatedData;\n try {\n updatedData = new ImmutableFeatureCollection(props.data)\n .removePosition(featureIndex, positionIndexes)\n .getObject();\n } catch (ignored) {\n // This happens if user attempts to remove the last point\n }\n\n if (updatedData) {\n props.onEdit({\n updatedData,\n editType: 'removePosition',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: pickedExistingHandle.geometry.coordinates\n }\n });\n }\n } else if (pickedIntermediateHandle) {\n const {featureIndex, positionIndexes} = pickedIntermediateHandle.properties;\n\n const feature = props.data.features[featureIndex];\n const canAddPosition = !(\n props.modeConfig?.lockRectangles && feature?.properties.shape === 'Rectangle'\n );\n\n if (canAddPosition) {\n const updatedData = new ImmutableFeatureCollection(props.data)\n .addPosition(featureIndex, positionIndexes, pickedIntermediateHandle.geometry.coordinates)\n .getObject();\n\n if (updatedData) {\n props.onEdit({\n updatedData,\n editType: 'addPosition',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: pickedIntermediateHandle.geometry.coordinates\n }\n });\n }\n }\n }\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n\n if (editHandle) {\n // Cancel map panning if pointer went down on an edit handle\n event.cancelPan();\n\n this._dragEditHandle('movePosition', props, editHandle, event);\n }\n }\n\n _dragEditHandle(\n editType: string,\n props: ModeProps<FeatureCollection>,\n editHandle: EditHandleFeature,\n event: StopDraggingEvent | DraggingEvent\n ) {\n const editHandleProperties = editHandle.properties;\n const editedFeature = props.data.features[editHandleProperties.featureIndex];\n\n let updatedData;\n if (props.modeConfig?.lockRectangles && editedFeature.properties.shape === 'Rectangle') {\n const coordinates = updateRectanglePosition(\n editedFeature as FeatureOf<Polygon>,\n editHandleProperties.positionIndexes[1],\n event.mapCoords\n ) as any; // TODO\n\n updatedData = new ImmutableFeatureCollection(props.data)\n .replaceGeometry(editHandleProperties.featureIndex, {coordinates, type: 'Polygon'})\n .getObject();\n } else {\n updatedData = new ImmutableFeatureCollection(props.data)\n .replacePosition(\n editHandleProperties.featureIndex,\n editHandleProperties.positionIndexes,\n event.mapCoords\n )\n .getObject();\n }\n\n props.onEdit({\n updatedData,\n editType,\n editContext: {\n featureIndexes: [editHandleProperties.featureIndex],\n positionIndexes: editHandleProperties.positionIndexes,\n position: event.mapCoords\n }\n });\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n const cursor = this.getCursor(event);\n props.onUpdateCursor(cursor);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (shouldCancelPan(event)) {\n event.cancelPan();\n }\n\n const selectedFeatureIndexes = props.selectedIndexes;\n\n const editHandle = getPickedIntermediateEditHandle(event.picks);\n if (selectedFeatureIndexes.length && editHandle) {\n const editHandleProperties = editHandle.properties;\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .addPosition(\n editHandleProperties.featureIndex,\n editHandleProperties.positionIndexes,\n event.mapCoords\n )\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'addPosition',\n editContext: {\n featureIndexes: [editHandleProperties.featureIndex],\n positionIndexes: editHandleProperties.positionIndexes,\n position: event.mapCoords\n }\n });\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n const selectedFeatureIndexes = props.selectedIndexes;\n const editHandle = getPickedEditHandle(event.picks);\n if (selectedFeatureIndexes.length && editHandle) {\n this._dragEditHandle('finishMovePosition', props, editHandle, event);\n }\n }\n\n getCursor(event: PointerMoveEvent): string | null | undefined {\n const picks = (event && event.picks) || [];\n\n const handlesPicked = getPickedEditHandles(picks);\n if (handlesPicked.length) {\n return 'cell';\n }\n return null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bbox from '@turf/bbox';\nimport turfCentroid from '@turf/centroid';\nimport turfBearing from '@turf/bearing';\nimport bboxPolygon from '@turf/bbox-polygon';\nimport {point, featureCollection} from '@turf/helpers';\nimport {polygonToLine} from '@turf/polygon-to-line';\nimport {coordEach} from '@turf/meta';\nimport turfDistance from '@turf/distance';\nimport turfTransformScale from '@turf/transform-scale';\nimport {getCoord, getGeom} from '@turf/invariant';\nimport {FeatureCollection, Position} from '../utils/geojson-types';\nimport {\n ModeProps,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n EditHandleFeature,\n GuideFeatureCollection\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ScaleMode extends GeoJsonEditMode {\n _geometryBeingScaled: FeatureCollection | null | undefined;\n _selectedEditHandle: EditHandleFeature | null | undefined;\n _cornerGuidePoints: Array<EditHandleFeature> = [];\n _cursor: string | null | undefined;\n _isScaling = false;\n\n _isSinglePointGeometrySelected = (geometry: FeatureCollection | null | undefined): boolean => {\n const {features} = geometry || {};\n if (Array.isArray(features) && features.length === 1) {\n // @ts-expect-error turf types diff\n const {type}: {type: string} = getGeom(features[0]);\n return type === 'Point';\n }\n return false;\n };\n\n _getOppositeScaleHandle = (selectedHandle: EditHandleFeature): EditHandleFeature | null => {\n const selectedHandleIndex =\n selectedHandle &&\n selectedHandle.properties &&\n Array.isArray(selectedHandle.properties.positionIndexes) &&\n selectedHandle.properties.positionIndexes[0];\n\n if (typeof selectedHandleIndex !== 'number') {\n return null;\n }\n const guidePointCount = this._cornerGuidePoints.length;\n const oppositeIndex = (selectedHandleIndex + guidePointCount / 2) % guidePointCount;\n return (\n this._cornerGuidePoints.find((p) => {\n if (!Array.isArray(p.properties.positionIndexes)) {\n return false;\n }\n return p.properties.positionIndexes[0] === oppositeIndex;\n }) || null\n );\n };\n\n _getUpdatedData = (props: ModeProps<FeatureCollection>, editedData: FeatureCollection) => {\n let updatedData = new ImmutableFeatureCollection(props.data);\n const selectedIndexes = props.selectedIndexes;\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const movedFeature = editedData.features[i];\n updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry);\n }\n return updatedData.getObject();\n };\n\n isEditHandleSelected = (): boolean => Boolean(this._selectedEditHandle);\n\n getScaleAction = (\n startDragPoint: Position,\n currentPoint: Position,\n editType: string,\n props: ModeProps<FeatureCollection>\n ) => {\n if (!this._selectedEditHandle) {\n return null;\n }\n\n const oppositeHandle = this._getOppositeScaleHandle(this._selectedEditHandle);\n const origin = getCoord(oppositeHandle) as Position;\n\n const scaleFactor = getScaleFactor(origin, startDragPoint, currentPoint);\n\n // @ts-expect-error turf types diff\n const scaledFeatures: FeatureCollection = turfTransformScale(\n // @ts-expect-error turf types diff\n this._geometryBeingScaled,\n scaleFactor,\n {origin}\n );\n\n return {\n updatedData: this._getUpdatedData(props, scaledFeatures),\n editType,\n editContext: {\n featureIndexes: props.selectedIndexes\n }\n };\n };\n\n updateCursor = (props: ModeProps<FeatureCollection>) => {\n if (this._selectedEditHandle) {\n if (this._cursor) {\n props.onUpdateCursor(this._cursor);\n }\n const cursorGeometry = this.getSelectedFeaturesAsFeatureCollection(props);\n\n // Get resize cursor direction from the hovered scale editHandle (e.g. nesw or nwse)\n // @ts-expect-error turf types diff\n const centroid = turfCentroid(cursorGeometry);\n const bearing = turfBearing(centroid, this._selectedEditHandle);\n const positiveBearing = bearing < 0 ? bearing + 180 : bearing;\n if (\n (positiveBearing >= 0 && positiveBearing <= 90) ||\n (positiveBearing >= 180 && positiveBearing <= 270)\n ) {\n this._cursor = 'nesw-resize';\n props.onUpdateCursor('nesw-resize');\n } else {\n this._cursor = 'nwse-resize';\n props.onUpdateCursor('nwse-resize');\n }\n } else {\n props.onUpdateCursor(null);\n this._cursor = null;\n }\n };\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isScaling) {\n const selectedEditHandle = getPickedEditHandle(event.picks);\n this._selectedEditHandle =\n selectedEditHandle && selectedEditHandle.properties.editHandleType === 'scale'\n ? selectedEditHandle\n : null;\n\n this.updateCursor(props);\n }\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n event.cancelPan();\n this._isScaling = true;\n this._geometryBeingScaled = this.getSelectedFeaturesAsFeatureCollection(props);\n }\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isScaling) {\n return;\n }\n\n props.onUpdateCursor(this._cursor);\n\n const scaleAction = this.getScaleAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'scaling',\n props\n );\n if (scaleAction) {\n props.onEdit(scaleAction);\n }\n\n event.cancelPan();\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._isScaling) {\n // Scale the geometry\n const scaleAction = this.getScaleAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'scaled',\n props\n );\n if (scaleAction) {\n props.onEdit(scaleAction);\n }\n\n props.onUpdateCursor(null);\n\n this._geometryBeingScaled = null;\n this._selectedEditHandle = null;\n this._cursor = null;\n this._isScaling = false;\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n this._cornerGuidePoints = [];\n const selectedGeometry = this.getSelectedFeaturesAsFeatureCollection(props);\n\n // Add buffer to the enveloping box if a single Point feature is selected\n if (this._isSinglePointGeometrySelected(selectedGeometry)) {\n return {type: 'FeatureCollection', features: []};\n }\n\n const boundingBox = bboxPolygon(bbox(selectedGeometry));\n boundingBox.properties.mode = 'scale';\n const cornerGuidePoints: EditHandleFeature[] = [];\n\n coordEach(boundingBox, (coord, coordIndex) => {\n if (coordIndex < 4) {\n // Get corner midpoint guides from the enveloping box\n const cornerPoint = point(coord, {\n guideType: 'editHandle',\n editHandleType: 'scale',\n positionIndexes: [coordIndex]\n });\n cornerGuidePoints.push(cornerPoint as EditHandleFeature);\n }\n });\n\n this._cornerGuidePoints = cornerGuidePoints;\n // @ts-expect-error turf types diff\n return featureCollection([polygonToLine(boundingBox), ...this._cornerGuidePoints]);\n }\n}\n\nfunction getScaleFactor(centroid: Position, startDragPoint: Position, currentPoint: Position) {\n const startDistance = turfDistance(centroid, startDragPoint);\n const endDistance = turfDistance(centroid, currentPoint);\n return endDistance / startDistance;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bbox from '@turf/bbox';\nimport turfCentroid from '@turf/centroid';\nimport turfBearing from '@turf/bearing';\nimport bboxPolygon from '@turf/bbox-polygon';\nimport turfDistance from '@turf/distance';\nimport {coordEach} from '@turf/meta';\nimport {getGeom} from '@turf/invariant';\nimport {point, featureCollection, lineString} from '@turf/helpers';\nimport turfTransformRotate from '@turf/transform-rotate';\nimport {polygonToLine} from '@turf/polygon-to-line';\nimport {\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps,\n EditHandleFeature,\n GuideFeatureCollection\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {FeatureCollection, Position} from '../utils/geojson-types';\nimport {GeoJsonEditMode, GeoJsonEditAction, getIntermediatePosition} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class RotateMode extends GeoJsonEditMode {\n _selectedEditHandle: EditHandleFeature | null | undefined;\n _geometryBeingRotated: FeatureCollection | null | undefined;\n _isRotating = false;\n\n _isSinglePointGeometrySelected = (geometry: FeatureCollection | null | undefined): boolean => {\n const {features} = geometry || {};\n if (Array.isArray(features) && features.length === 1) {\n // @ts-expect-error turf type diff\n const {type}: {type: string} = getGeom(features[0]);\n return type === 'Point';\n }\n return false;\n };\n\n getIsRotating = () => this._isRotating;\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const selectedGeometry =\n this._geometryBeingRotated || this.getSelectedFeaturesAsFeatureCollection(props);\n\n if (this._isSinglePointGeometrySelected(selectedGeometry)) {\n return {type: 'FeatureCollection', features: []};\n }\n\n if (this._isRotating) {\n // Display rotate pivot\n // @ts-expect-error turf types diff\n return featureCollection([turfCentroid(selectedGeometry)]) as GuideFeatureCollection;\n }\n\n const boundingBox = bboxPolygon(bbox(selectedGeometry));\n\n let previousCoord: Position | null = null;\n let topEdgeMidpointCoords: Position | null = null;\n let longestEdgeLength = 0;\n\n coordEach(boundingBox, (coord: any) => {\n if (previousCoord) {\n const edgeMidpoint = getIntermediatePosition(coord, previousCoord);\n if (!topEdgeMidpointCoords || edgeMidpoint[1] > topEdgeMidpointCoords[1]) {\n // Get the top edge midpoint of the enveloping box\n topEdgeMidpointCoords = edgeMidpoint;\n }\n // Get the length of the longest edge of the enveloping box\n const edgeDistance = turfDistance(coord, previousCoord);\n longestEdgeLength = Math.max(longestEdgeLength, edgeDistance);\n }\n previousCoord = coord;\n });\n\n // Scale the length of the line between the rotate handler and the enveloping box\n // relative to the length of the longest edge of the enveloping box\n const rotateHandleCoords = topEdgeMidpointCoords && [\n topEdgeMidpointCoords[0],\n topEdgeMidpointCoords[1] + longestEdgeLength / 1000\n ];\n\n const lineFromEnvelopeToRotateHandle = lineString([topEdgeMidpointCoords, rotateHandleCoords]);\n const rotateHandle = point(rotateHandleCoords, {\n guideType: 'editHandle',\n editHandleType: 'rotate'\n });\n\n const outFeatures = [polygonToLine(boundingBox), rotateHandle, lineFromEnvelopeToRotateHandle];\n\n // @ts-expect-error turf type diff\n return featureCollection(outFeatures);\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isRotating) {\n return;\n }\n\n const rotateAction = this.getRotateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'rotating',\n props\n );\n if (rotateAction) {\n props.onEdit(rotateAction);\n }\n\n event.cancelPan();\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n if (!this._isRotating) {\n const selectedEditHandle = getPickedEditHandle(event.picks);\n this._selectedEditHandle =\n selectedEditHandle && selectedEditHandle.properties.editHandleType === 'rotate'\n ? selectedEditHandle\n : null;\n }\n\n this.updateCursor(props);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n event.cancelPan();\n this._isRotating = true;\n this._geometryBeingRotated = this.getSelectedFeaturesAsFeatureCollection(props);\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._isRotating) {\n // Rotate the geometry\n const rotateAction = this.getRotateAction(\n event.pointerDownMapCoords,\n event.mapCoords,\n 'rotated',\n props\n );\n\n if (rotateAction) {\n props.onEdit(rotateAction);\n }\n\n this._geometryBeingRotated = null;\n this._selectedEditHandle = null;\n this._isRotating = false;\n }\n }\n\n updateCursor(props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n // TODO: look at doing SVG cursors to get a better \"rotate\" cursor\n props.onUpdateCursor('crosshair');\n } else {\n props.onUpdateCursor(null);\n }\n }\n\n getRotateAction(\n startDragPoint: Position,\n currentPoint: Position,\n editType: string,\n props: ModeProps<FeatureCollection>\n ): GeoJsonEditAction | null | undefined {\n if (!this._geometryBeingRotated) {\n return null;\n }\n // @ts-expect-error turf types diff\n const centroid = turfCentroid(this._geometryBeingRotated);\n // @ts-expect-error turf types diff\n const angle = getRotationAngle(centroid, startDragPoint, currentPoint);\n\n // @ts-expect-error turf types too wide\n const rotatedFeatures: FeatureCollection = turfTransformRotate(\n // @ts-expect-error turf types too wide\n this._geometryBeingRotated,\n angle,\n {\n pivot: centroid\n }\n );\n\n let updatedData = new ImmutableFeatureCollection(props.data);\n\n const selectedIndexes = props.selectedIndexes;\n for (let i = 0; i < selectedIndexes.length; i++) {\n const selectedIndex = selectedIndexes[i];\n const movedFeature = rotatedFeatures.features[i];\n updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry);\n }\n\n return {\n updatedData: updatedData.getObject(),\n editType,\n editContext: {\n featureIndexes: selectedIndexes\n }\n };\n }\n}\n\nfunction getRotationAngle(centroid: Position, startDragPoint: Position, currentPoint: Position) {\n const bearing1 = turfBearing(centroid, startDragPoint);\n const bearing2 = turfBearing(centroid, currentPoint);\n return bearing2 - bearing1;\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {StartDraggingEvent, ModeProps} from './types';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {TranslateMode} from './translate-mode';\n\nexport class DuplicateMode extends TranslateMode {\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n super.handleStartDragging(event, props);\n\n if (this._geometryBeforeTranslate) {\n props.onEdit(this.getAddManyFeaturesAction(this._geometryBeforeTranslate, props.data));\n }\n }\n\n updateCursor(props: ModeProps<FeatureCollection>) {\n if (this._isTranslatable) {\n props.onUpdateCursor('copy');\n } else {\n props.onUpdateCursor(null);\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport booleanPointInPolygon from '@turf/boolean-point-in-polygon';\nimport turfDifference from '@turf/difference';\nimport turfBuffer from '@turf/buffer';\nimport lineIntersect from '@turf/line-intersect';\nimport type {Point} from '@turf/helpers';\nimport {lineString} from '@turf/helpers';\nimport turfBearing from '@turf/bearing';\nimport turfDistance from '@turf/distance';\nimport turfDestination from '@turf/destination';\nimport turfPolygonToLine from '@turf/polygon-to-line';\nimport type {NearestPointOnLine} from '@turf/nearest-point-on-line';\nimport nearestPointOnLine from '@turf/nearest-point-on-line';\nimport {generatePointsParallelToLinePoints} from './utils';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {GeoJsonEditMode, GeoJsonEditAction} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class SplitPolygonMode extends GeoJsonEditMode {\n calculateMapCoords(clickSequence: any, mapCoords: any, props: ModeProps<FeatureCollection>) {\n const modeConfig = props.modeConfig;\n if (!modeConfig || !modeConfig.lock90Degree || !clickSequence.length) {\n return mapCoords;\n }\n if (clickSequence.length === 1) {\n // if first point is clicked, then find closest polygon point and build ~90deg vector\n const firstPoint = clickSequence[0];\n const selectedGeometry = this.getSelectedGeometry(props);\n // @ts-expect-error turf types diff\n const feature = turfPolygonToLine(selectedGeometry);\n\n const lines = feature.type === 'FeatureCollection' ? feature.features : [feature];\n let minDistance = Number.MAX_SAFE_INTEGER;\n let closestPoint: NearestPointOnLine | null = null;\n // If Multipolygon, then we should find nearest polygon line and stick split to it.\n lines.forEach((line) => {\n const snapPoint = nearestPointOnLine(line, firstPoint);\n const distanceFromOrigin = turfDistance(snapPoint, firstPoint);\n if (minDistance > distanceFromOrigin) {\n minDistance = distanceFromOrigin;\n closestPoint = snapPoint;\n }\n });\n\n if (closestPoint) {\n // closest point is used as 90degree entry to the polygon\n const lastBearing = turfBearing(firstPoint, closestPoint);\n const currentDistance = turfDistance(firstPoint, mapCoords, {units: 'meters'});\n return turfDestination(firstPoint, currentDistance, lastBearing, {\n units: 'meters'\n }).geometry.coordinates;\n }\n return mapCoords;\n }\n // Allow only 90 degree turns\n const lastPoint = clickSequence[clickSequence.length - 1];\n const [approximatePoint] = generatePointsParallelToLinePoints(\n clickSequence[clickSequence.length - 2],\n lastPoint,\n mapCoords\n );\n // align point with current ground\n const nearestPt = nearestPointOnLine(lineString([lastPoint, approximatePoint]), mapCoords)\n .geometry.coordinates;\n return nearestPt;\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length === 0 || !props.lastPointerMoveEvent) {\n // nothing to do yet\n return guides;\n }\n\n const {mapCoords} = props.lastPointerMoveEvent;\n\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords, props)]\n }\n });\n\n return guides;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const tentativeFeature = this.getTentativeGuide(props);\n\n const selectedGeometry = this.getSelectedGeometry(props);\n\n if (!selectedGeometry) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('A polygon must be selected for splitting');\n return;\n }\n\n const clickSequence = this.getClickSequence();\n if (tentativeFeature && tentativeFeature.geometry.type === 'LineString') {\n clickSequence.push(\n tentativeFeature.geometry.coordinates[tentativeFeature.geometry.coordinates.length - 1]\n );\n } else {\n this.addClickSequence(event);\n }\n\n const pt: Point = {\n type: 'Point',\n coordinates: clickSequence[clickSequence.length - 1]\n };\n\n // @ts-expect-error turf types diff\n const isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry);\n if (clickSequence.length > 1 && tentativeFeature && !isPointInPolygon) {\n this.resetClickSequence();\n // @ts-expect-error narrow type\n const isLineInterectingWithPolygon = lineIntersect(tentativeFeature, selectedGeometry);\n if (isLineInterectingWithPolygon.features.length === 0) {\n return;\n }\n\n const editAction = this.splitPolygon(tentativeFeature, props);\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n\n splitPolygon(tentativeFeature: TentativeFeature, props: ModeProps<FeatureCollection>) {\n const selectedGeometry = this.getSelectedGeometry(props);\n const featureIndex = props.selectedIndexes[0];\n const modeConfig = props.modeConfig || {};\n\n // Default gap in between the polygon\n let {gap = 0.1, units = 'centimeters'} = modeConfig;\n if (gap === 0) {\n gap = 0.1;\n units = 'centimeters';\n }\n\n const buffer = turfBuffer(tentativeFeature, gap, {units});\n // @ts-expect-error turf types diff\n const updatedGeometry = turfDifference(selectedGeometry, buffer);\n if (!updatedGeometry) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('Canceling edit. Split Polygon erased');\n return null;\n }\n\n const {type, coordinates} = updatedGeometry.geometry;\n let updatedCoordinates: any[] = []; // TODO\n if (type === 'Polygon') {\n // Update the coordinates as per Multipolygon\n updatedCoordinates = coordinates.map((c) => [c]);\n } else {\n // Handle Case when Multipolygon has holes\n updatedCoordinates = coordinates.reduce((agg, prev) => {\n prev.forEach((p) => {\n // @ts-expect-error revisit coordinates type here\n agg.push([p]);\n });\n return agg;\n }, []);\n }\n\n // Update the type to Mulitpolygon\n const updatedData = new ImmutableFeatureCollection(props.data).replaceGeometry(featureIndex, {\n type: 'MultiPolygon',\n coordinates: updatedCoordinates\n });\n\n const editAction: GeoJsonEditAction = {\n updatedData: updatedData.getObject(),\n editType: 'split',\n editContext: {\n featureIndexes: [featureIndex]\n }\n };\n\n return editAction;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bearing from '@turf/bearing';\nimport {\n generatePointsParallelToLinePoints,\n getPickedEditHandle,\n getPickedIntermediateEditHandle,\n shouldCancelPan\n} from './utils';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {ModeProps, StartDraggingEvent, StopDraggingEvent, DraggingEvent} from './types';\nimport {ModifyMode} from './modify-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ExtrudeMode extends ModifyMode {\n // this mode is busted =(\n\n isPointAdded = false;\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n\n if (editHandle) {\n const {featureIndex} = editHandle.properties;\n let {positionIndexes} = editHandle.properties;\n\n const size = this.coordinatesSize(positionIndexes, featureIndex, props.data);\n positionIndexes = this.isPointAdded\n ? this.nextPositionIndexes(positionIndexes, size)\n : positionIndexes;\n // p1 and p1 are end points for edge\n const p1 = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n props.data\n );\n const p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data);\n if (p1 && p2) {\n // p3 and p4 are end points for moving (extruding) edge\n const [p3, p4] = generatePointsParallelToLinePoints(p1, p2, event.mapCoords);\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replacePosition(featureIndex, this.prevPositionIndexes(positionIndexes, size), p4)\n .replacePosition(featureIndex, positionIndexes, p3)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'extruding',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes: this.nextPositionIndexes(positionIndexes, size),\n position: p3\n }\n });\n\n event.cancelPan();\n }\n }\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (shouldCancelPan(event)) {\n event.cancelPan();\n }\n\n const selectedFeatureIndexes = props.selectedIndexes;\n\n const editHandle = getPickedIntermediateEditHandle(event.picks);\n if (selectedFeatureIndexes.length && editHandle) {\n const {positionIndexes, featureIndex} = editHandle.properties;\n\n const size = this.coordinatesSize(positionIndexes, featureIndex, props.data);\n // p1 and p1 are end points for edge\n const p1 = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n props.data\n );\n const p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data);\n\n if (p1 && p2) {\n let updatedData = new ImmutableFeatureCollection(props.data);\n if (!this.isOrthogonal(positionIndexes, featureIndex, size, props.data)) {\n updatedData = updatedData.addPosition(featureIndex, positionIndexes, p2);\n }\n if (\n !this.isOrthogonal(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n size,\n props.data\n )\n ) {\n updatedData = updatedData.addPosition(featureIndex, positionIndexes, p1);\n this.isPointAdded = true;\n }\n\n props.onEdit({\n updatedData: updatedData.getObject(),\n editType: 'startExtruding',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: p1\n }\n });\n }\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n const selectedFeatureIndexes = props.selectedIndexes;\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n if (selectedFeatureIndexes.length && editHandle) {\n const {featureIndex} = editHandle.properties;\n let {positionIndexes} = editHandle.properties;\n\n const size = this.coordinatesSize(positionIndexes, featureIndex, props.data);\n positionIndexes = this.isPointAdded\n ? this.nextPositionIndexes(positionIndexes, size)\n : positionIndexes;\n // p1 and p1 are end points for edge\n const p1 = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n props.data\n );\n const p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data);\n\n if (p1 && p2) {\n // p3 and p4 are end points for new moved (extruded) edge\n const [p3, p4] = generatePointsParallelToLinePoints(p1, p2, event.mapCoords);\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replacePosition(featureIndex, this.prevPositionIndexes(positionIndexes, size), p4)\n .replacePosition(featureIndex, positionIndexes, p3)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'extruded',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: p3\n }\n });\n }\n }\n this.isPointAdded = false;\n }\n\n coordinatesSize(\n positionIndexes: number[] | null | undefined,\n featureIndex: number,\n {features}: FeatureCollection\n ) {\n let size = 0;\n if (Array.isArray(positionIndexes)) {\n const feature = features[featureIndex];\n const coordinates: any = feature.geometry.coordinates;\n // for Multi polygons, length will be 3\n if (positionIndexes.length === 3) {\n const [a, b] = positionIndexes;\n if (coordinates.length && coordinates[a].length) {\n size = coordinates[a][b].length;\n }\n } else {\n const [b] = positionIndexes;\n if (coordinates.length && coordinates[b].length) {\n size = coordinates[b].length;\n }\n }\n }\n return size;\n }\n\n getBearing(p1: any, p2: any) {\n const angle = bearing(p1, p2);\n if (angle < 0) {\n return Math.floor(360 + angle);\n }\n return Math.floor(angle);\n }\n\n isOrthogonal(\n positionIndexes: number[] | null | undefined,\n featureIndex: number,\n size: number,\n features: FeatureCollection\n ) {\n if (!Array.isArray(positionIndexes)) {\n return false;\n }\n if (positionIndexes[positionIndexes.length - 1] === size - 1) {\n positionIndexes[positionIndexes.length - 1] = 0;\n }\n const prevPoint = this.getPointForPositionIndexes(\n this.prevPositionIndexes(positionIndexes, size),\n featureIndex,\n features\n );\n const nextPoint = this.getPointForPositionIndexes(\n this.nextPositionIndexes(positionIndexes, size),\n featureIndex,\n features\n );\n const currentPoint = this.getPointForPositionIndexes(positionIndexes, featureIndex, features);\n const prevAngle = this.getBearing(currentPoint, prevPoint);\n const nextAngle = this.getBearing(currentPoint, nextPoint);\n return [89, 90, 91, 269, 270, 271].includes(Math.abs(prevAngle - nextAngle));\n }\n\n nextPositionIndexes(positionIndexes: number[] | null | undefined, size: number): number[] {\n if (!Array.isArray(positionIndexes)) {\n return [];\n }\n const next = [...positionIndexes];\n if (next.length) {\n next[next.length - 1] = next[next.length - 1] === size - 1 ? 0 : next[next.length - 1] + 1;\n }\n return next;\n }\n\n prevPositionIndexes(positionIndexes: number[] | null | undefined, size: number): number[] {\n if (!Array.isArray(positionIndexes)) {\n return [];\n }\n const prev = [...positionIndexes];\n if (prev.length) {\n prev[prev.length - 1] = prev[prev.length - 1] === 0 ? size - 2 : prev[prev.length - 1] - 1;\n }\n return prev;\n }\n\n getPointForPositionIndexes(\n positionIndexes: number[] | null | undefined,\n featureIndex: number,\n {features}: FeatureCollection\n ) {\n let p1;\n if (Array.isArray(positionIndexes)) {\n const feature = features[featureIndex];\n const coordinates: any = feature.geometry.coordinates;\n // for Multi polygons, length will be 3\n if (positionIndexes.length === 3) {\n const [a, b, c] = positionIndexes;\n if (coordinates.length && coordinates[a].length) {\n p1 = coordinates[a][b][c];\n }\n } else {\n const [b, c] = positionIndexes;\n if (coordinates.length && coordinates[b].length) {\n p1 = coordinates[b][c];\n }\n }\n }\n return p1;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ModeProps, PointerMoveEvent, StopDraggingEvent} from './types';\nimport {Position, FeatureCollection} from '../utils/geojson-types';\nimport {getPickedEditHandle} from './utils';\nimport {ModifyMode} from './modify-mode';\n\nfunction defaultCalculateElevationChange({\n pointerDownScreenCoords,\n screenCoords\n}: {\n pointerDownScreenCoords: Position;\n screenCoords: Position;\n}) {\n return 10 * (pointerDownScreenCoords[1] - screenCoords[1]);\n}\n\nexport class ElevationMode extends ModifyMode {\n makeElevatedEvent(\n event: PointerMoveEvent | StopDraggingEvent,\n position: Position,\n props: ModeProps<FeatureCollection>\n ): Record<string, any> {\n const {\n minElevation = 0,\n maxElevation = 20000,\n calculateElevationChange = defaultCalculateElevationChange\n } = props.modeConfig || {};\n\n if (!event.pointerDownScreenCoords) {\n return event;\n }\n\n // $FlowFixMe - really, I know it has something at index 2\n let elevation = position.length === 3 ? position[2] : 0;\n\n // calculateElevationChange is configurable because (at this time) modes are not aware of the viewport\n elevation += calculateElevationChange({\n pointerDownScreenCoords: event.pointerDownScreenCoords,\n screenCoords: event.screenCoords\n });\n elevation = Math.min(elevation, maxElevation);\n elevation = Math.max(elevation, minElevation);\n\n return Object.assign({}, event, {\n mapCoords: [position[0], position[1], elevation]\n });\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n const position = editHandle ? editHandle.geometry.coordinates : event.mapCoords;\n // @ts-expect-error return type too wide\n super.handlePointerMove(this.makeElevatedEvent(event, position, props), props);\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n const editHandle = getPickedEditHandle(event.picks);\n const position = editHandle ? editHandle.geometry.coordinates : event.mapCoords;\n // @ts-expect-error return type too wide\n super.handleStopDragging(this.makeElevatedEvent(event, position, props), props);\n }\n\n getCursor(event: PointerMoveEvent): string | null | undefined {\n let cursor = super.getCursor(event);\n if (cursor === 'cell') {\n cursor = 'ns-resize';\n }\n return cursor;\n }\n\n static calculateElevationChangeWithViewport(\n viewport: any,\n {\n pointerDownScreenCoords,\n screenCoords\n }: {\n pointerDownScreenCoords: Position;\n screenCoords: Position;\n }\n ): number {\n // Source: https://gis.stackexchange.com/a/127949/111804\n const metersPerPixel =\n (156543.03392 * Math.cos((viewport.latitude * Math.PI) / 180)) / Math.pow(2, viewport.zoom);\n\n return (metersPerPixel * (pointerDownScreenCoords[1] - screenCoords[1])) / 2;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ClickEvent, PointerMoveEvent, ModeProps, TentativeFeature} from './types';\nimport {FeatureCollection, Point} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class DrawPointMode extends GeoJsonEditMode {\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n return {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'Point',\n coordinates: lastCoords[0]\n }\n };\n }\n\n handleClick({mapCoords}: ClickEvent, props: ModeProps<FeatureCollection>): void {\n const geometry: Point = {\n type: 'Point',\n coordinates: mapCoords\n };\n\n props.onEdit(this.getAddFeatureAction(geometry, props.data));\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport distance from '@turf/distance';\nimport {memoize} from '../utils/memoize';\nimport {LineString, FeatureCollection, Position} from '../utils/geojson-types';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n GuideFeature,\n Tooltip,\n DoubleClickEvent\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class DrawLineStringMode extends GeoJsonEditMode {\n // declaration of variables for the calculation of the distance of linestring\n dist = 0;\n position: Position = null!;\n elems: Position[] = [];\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n\n let positionAdded = false;\n if (!clickedEditHandle) {\n // Don't add another point right next to an existing one\n this.addClickSequence(event);\n positionAdded = true;\n }\n const clickSequence = this.getClickSequence();\n\n // check if the pointer is on editable state calculate the distance of new point\n if (!clickedEditHandle) {\n this.calculateInfoDraw(clickSequence);\n }\n\n if (\n clickSequence.length > 1 &&\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1\n ) {\n // They clicked the last point (or double-clicked), so add the LineString\n // reset distance to new calculate\n this.dist = 0;\n this.finishDrawing(props);\n } else if (positionAdded) {\n // new tentative point\n props.onEdit({\n // data is the same\n updatedData: props.data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleDoubleClick(event: DoubleClickEvent, props: ModeProps<FeatureCollection>) {\n this.finishDrawing(props);\n }\n\n finishDrawing(props: ModeProps<FeatureCollection>) {\n const clickSequence = this.getClickSequence();\n if (clickSequence.length > 1) {\n const lineStringToAdd: LineString = {\n type: 'LineString',\n coordinates: [...clickSequence]\n };\n this.resetClickSequence();\n const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n const {key} = event;\n if (key === 'Enter') {\n this.finishDrawing(props);\n } else if (key === 'Escape') {\n this.resetClickSequence();\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n let tentativeFeature;\n if (clickSequence.length > 0) {\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, ...lastCoords]\n }\n };\n }\n\n if (tentativeFeature) {\n guides.features.push(tentativeFeature);\n }\n\n const editHandles: GuideFeature[] = clickSequence.map((clickedCoord, index) => ({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'existing',\n featureIndex: -1,\n positionIndexes: [index]\n },\n geometry: {\n type: 'Point',\n coordinates: clickedCoord\n }\n }));\n\n guides.features.push(...editHandles);\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n\n /**\n * define the default function to display the tooltip for\n * nebula geometry mode type\n * @param props properties of geometry nebula mode\n */\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return this._getTooltips({\n modeConfig: props.modeConfig,\n dist: this.dist\n });\n }\n\n // utility function\n calculateInfoDraw(clickSequence) {\n // check if the selected points are at least 2\n if (clickSequence.length > 1) {\n // setting the last point\n this.position = clickSequence[clickSequence.length - 1];\n // calculate the new distance by adding the\n // distance of the new drawn linestring\n this.dist += distance(\n clickSequence[clickSequence.length - 2],\n clickSequence[clickSequence.length - 1]\n );\n }\n }\n\n /**\n * redefine the tooltip of geometry\n * @param modeConfig\n * @param dist\n */\n _getTooltips = memoize(({modeConfig, dist}) => {\n let tooltips: Tooltip[] = [];\n const {formatTooltip} = modeConfig || {};\n let text;\n if (dist) {\n if (formatTooltip) {\n text = formatTooltip(dist);\n } else {\n // By default, round to 2 decimal places and append units\n text = `Distance: ${parseFloat(dist).toFixed(2)} kilometers`;\n }\n\n tooltips = [\n {\n position: this.position,\n text\n }\n ];\n }\n return tooltips;\n });\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// port from @deck.gl/core\nfunction isEqual(a: any, b: any) {\n if (a === b) {\n return true;\n }\n if (Array.isArray(a)) {\n // Special treatment for arrays: compare 1-level deep\n // This is to support equality of matrix/coordinate props\n const len = a.length;\n if (!b || b.length !== len) {\n return false;\n }\n\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n\n/**\n * Speed up consecutive function calls by caching the result of calls with identical input\n * https://en.wikipedia.org/wiki/Memoization\n * @param {function} compute - the function to be memoized\n */\nexport function memoize(compute: Function) {\n let cachedArgs = {};\n let cachedResult;\n\n return (args: any) => {\n for (const key in args) {\n if (!isEqual(args[key], cachedArgs[key])) {\n cachedResult = compute(args);\n cachedArgs = args;\n break;\n }\n }\n return cachedResult;\n };\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport lineIntersect from '@turf/line-intersect';\nimport {lineString as turfLineString} from '@turf/helpers';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature,\n GuideFeature,\n DoubleClickEvent\n} from './types';\nimport {Polygon, FeatureCollection} from '../utils/geojson-types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class DrawPolygonMode extends GeoJsonEditMode {\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n let tentativeFeature;\n if (clickSequence.length === 1 || clickSequence.length === 2) {\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, ...lastCoords]\n }\n };\n } else if (clickSequence.length > 2) {\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'Polygon',\n coordinates: [[...clickSequence, ...lastCoords, clickSequence[0]]]\n }\n };\n }\n\n return tentativeFeature;\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n const tentativeFeature = this.createTentativeFeature(props);\n if (tentativeFeature) {\n guides.features.push(tentativeFeature);\n }\n\n const editHandles: GuideFeature[] = clickSequence.map((clickedCoord, index) => ({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'existing',\n featureIndex: -1,\n positionIndexes: [index]\n },\n geometry: {\n type: 'Point',\n coordinates: clickedCoord\n }\n }));\n\n guides.features.push(...editHandles);\n\n return guides;\n }\n\n finishDrawing(props: ModeProps<FeatureCollection>) {\n const clickSequence = this.getClickSequence();\n if (clickSequence.length > 2) {\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: [[...clickSequence, clickSequence[0]]]\n };\n\n this.resetClickSequence();\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n // eslint-disable-next-line complexity\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n const clickSequence = this.getClickSequence();\n\n let overlappingLines = false;\n if (clickSequence.length > 2 && props.modeConfig && props.modeConfig.preventOverlappingLines) {\n const currentLine = turfLineString([\n clickSequence[clickSequence.length - 1],\n event.mapCoords\n ]);\n const otherLines = turfLineString([...clickSequence.slice(0, clickSequence.length - 1)]);\n const intersectingPoints = lineIntersect(currentLine, otherLines);\n if (intersectingPoints.features.length > 0) {\n overlappingLines = true;\n }\n }\n\n let positionAdded = false;\n if (!clickedEditHandle && !overlappingLines) {\n // Don't add another point right next to an existing one\n this.addClickSequence(event);\n positionAdded = true;\n }\n\n if (\n clickSequence.length > 2 &&\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n (clickedEditHandle.properties.positionIndexes[0] === 0 ||\n clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1)\n ) {\n // They clicked the first or last point (or double-clicked), so complete the polygon\n this.finishDrawing(props);\n } else if (positionAdded) {\n // new tentative point\n props.onEdit({\n // data is the same\n updatedData: props.data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleDoubleClick(event: DoubleClickEvent, props: ModeProps<FeatureCollection>) {\n this.finishDrawing(props);\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n if (event.key === 'Enter') {\n this.finishDrawing(props);\n } else if (event.key === 'Escape') {\n this.resetClickSequence();\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawRectangleMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n const rectangle = bboxPolygon([coord1[0], coord1[1], coord2[0], coord2[1]]);\n rectangle.properties = rectangle.properties || {};\n rectangle.properties.shape = 'Rectangle';\n\n // @ts-expect-error turf typing too wide\n return rectangle;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n ClickEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {Polygon, FeatureCollection, FeatureOf, Position} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport omit from 'lodash.omit';\n\nexport class TwoClickPolygonMode extends GeoJsonEditMode {\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n if (props.modeConfig && props.modeConfig.dragToDraw) {\n // handled in drag handlers\n return;\n }\n\n this.addClickSequence(event);\n\n this.checkAndFinishPolygon(props);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>): void {\n if (!props.modeConfig || !props.modeConfig.dragToDraw) {\n // handled in click handlers\n return;\n }\n\n this.addClickSequence(event);\n event.cancelPan();\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>): void {\n if (!props.modeConfig || !props.modeConfig.dragToDraw) {\n // handled in click handlers\n return;\n }\n this.addClickSequence(event);\n\n this.checkAndFinishPolygon(props);\n }\n\n checkAndFinishPolygon(props: ModeProps<FeatureCollection>) {\n const clickSequence = this.getClickSequence();\n const tentativeFeature = this.getTentativeGuide(props);\n\n if (\n clickSequence.length > 1 &&\n tentativeFeature &&\n tentativeFeature.geometry.type === 'Polygon'\n ) {\n const feature: FeatureOf<Polygon> = {\n type: 'Feature',\n properties: omit(tentativeFeature.properties, 'guideType'),\n geometry: {\n type: 'Polygon',\n coordinates: tentativeFeature.geometry.coordinates\n }\n };\n const editAction = this.getAddFeatureOrBooleanPolygonAction(feature, props);\n\n this.resetClickSequence();\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent, modeConfig} = props;\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length === 0 || !lastPointerMoveEvent) {\n // nothing to do yet\n return guides;\n }\n\n const corner1 = clickSequence[0];\n const corner2 = lastPointerMoveEvent.mapCoords;\n\n const polygon = this.getTwoClickPolygon(corner1, corner2, modeConfig);\n if (polygon) {\n guides.features.push({\n type: 'Feature',\n properties: {\n ...polygon.properties,\n guideType: 'tentative'\n },\n geometry: polygon.geometry\n });\n }\n\n return guides;\n }\n\n getTwoClickPolygon(\n coord1: Position,\n coord2: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n return null;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n let tentativeFeature;\n if (clickSequence.length === 1) {\n tentativeFeature = this.getTwoClickPolygon(clickSequence[0], lastCoords[0], props.modeConfig);\n }\n\n return tentativeFeature;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport turfDistance from '@turf/distance';\nimport turfAlong from '@turf/along';\nimport {point, lineString as turfLineString} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawSquareMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // get the coordinates of the other two rectangle vertices\n const coord3 = [coord2[0], coord1[1]];\n const coord4 = [coord1[0], coord2[1]];\n\n // determine the shortest distance to the origin, which will be the length of each square side\n const distance1 = turfDistance(point(coord3), point(coord1));\n const distance2 = turfDistance(point(coord4), point(coord1));\n const shortestDistance = distance1 <= distance2 ? distance1 : distance2;\n\n // determine which coordinate pair of the two is closest to the origin\n const closestPoint = distance1 <= distance2 ? coord3 : coord4;\n\n // create a linestring which will used to locate the second square vertex\n const line = turfLineString([closestPoint, coord2]);\n\n // get the coordinates of the second square vertex\n const newPoint = turfAlong(line, shortestDistance);\n const corner = newPoint.geometry.coordinates;\n\n const square = bboxPolygon([coord1[0], coord1[1], corner[0], corner[1]]);\n square.properties = square.properties || {};\n square.properties.shape = 'Square';\n\n // @ts-expect-error turf types too wide\n return square;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawRectangleFromCenterMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n const longitude =\n coord1[0] > coord2[0]\n ? coord1[0] + Math.abs(coord1[0] - coord2[0])\n : coord1[0] - Math.abs(coord1[0] - coord2[0]);\n const latitude =\n coord1[1] > coord2[1]\n ? coord1[1] + Math.abs(coord1[1] - coord2[1])\n : coord1[1] - Math.abs(coord1[1] - coord2[1]);\n\n const rectangle = bboxPolygon([longitude, latitude, coord2[0], coord2[1]]);\n rectangle.properties = rectangle.properties || {};\n rectangle.properties.shape = 'Rectangle';\n\n // @ts-expect-error turf typing too wide\n return rectangle;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport turfDistance from '@turf/distance';\nimport turfAlong from '@turf/along';\nimport {point, lineString as turfLineString} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawSquareFromCenterMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // get the coordinates of the other two rectangle vertices\n const coord3 = [coord2[0], coord1[1]];\n const coord4 = [coord1[0], coord2[1]];\n\n // determine the shortest distance to the origin, which will be the length of each square side\n const distance1 = turfDistance(point(coord3), point(coord1));\n const distance2 = turfDistance(point(coord4), point(coord1));\n const shortestDistance = distance1 <= distance2 ? distance1 : distance2;\n\n // determine which coordinate pair of the two is closest to the origin\n const closestPoint = distance1 <= distance2 ? coord3 : coord4;\n\n // create a linestring which will used to locate the second square vertex\n const line = turfLineString([closestPoint, coord2]);\n\n // get the coordinates of the second square vertex\n const newPoint = turfAlong(line, shortestDistance);\n const corner = newPoint.geometry.coordinates;\n\n // determine the longitude and latitude values of the opposite corner\n const longitude =\n coord1[0] > corner[0]\n ? coord1[0] + Math.abs(coord1[0] - corner[0])\n : coord1[0] - Math.abs(coord1[0] - corner[0]);\n const latitude =\n coord1[1] > corner[1]\n ? coord1[1] + Math.abs(coord1[1] - corner[1])\n : coord1[1] - Math.abs(coord1[1] - corner[1]);\n\n const square = bboxPolygon([longitude, latitude, corner[0], corner[1]]);\n square.properties = square.properties || {};\n square.properties.shape = 'Square';\n\n // @ts-expect-error turf typing too wide\n return square;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport circle from '@turf/circle';\nimport distance from '@turf/distance';\nimport area from '@turf/area';\nimport {memoize} from '../utils/memoize';\nimport {ModeProps, Tooltip} from './types';\nimport {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawCircleFromCenterMode extends TwoClickPolygonMode {\n radius: number | null | undefined = null;\n position: Position = null!;\n areaCircle: number | null | undefined = null;\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // Default turf value for circle is 64\n const {steps = 64} = modeConfig || {};\n const options = {steps};\n // setting with position of center of circle\n this.position = coord2;\n\n if (steps < 4) {\n console.warn('Minimum steps to draw a circle is 4 '); // eslint-disable-line no-console,no-undef\n options.steps = 4;\n }\n\n // setting value of radius as distance of center and other point\n this.radius = Math.max(distance(coord1, coord2), 0.001);\n const geometry = circle(coord1, this.radius, options);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.shape = 'Circle';\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Circle';\n geometry.properties.editProperties.radius = {value: this.radius, unit: 'kilometers'};\n geometry.properties.editProperties.center = coord1;\n // calculate area of circle with turf function\n this.areaCircle = area(geometry);\n // @ts-expect-error turf types diff\n return geometry;\n }\n\n /**\n * define the default function to display the tooltip for\n * nebula geometry mode type\n * @param props properties of geometry nebula mode\n */\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return this._getTooltips({\n modeConfig: props?.modeConfig,\n radius: this.radius,\n areaCircle: this.areaCircle\n });\n }\n\n /**\n * redefine the tooltip of geometry\n * @param modeConfig\n * @param radius\n * @param areaCircle\n */\n _getTooltips = memoize(({modeConfig, radius, areaCircle}) => {\n let tooltips: Tooltip[] = [];\n const {formatTooltip} = modeConfig || {};\n let text: string;\n if (radius && areaCircle) {\n if (formatTooltip) {\n text = formatTooltip(radius);\n } else {\n // By default, round to 2 decimal places and append units\n text = `Radius: ${parseFloat(radius).toFixed(2)} kilometers\n \\n Area: ${parseFloat(areaCircle).toFixed(2)}`;\n }\n\n tooltips = [\n {\n position: this.position,\n text\n }\n ];\n }\n\n return tooltips;\n });\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport circle from '@turf/circle';\nimport distance from '@turf/distance';\nimport area from '@turf/area';\nimport {memoize} from '../utils/memoize';\nimport {ModeProps, Tooltip} from './types';\nimport {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';\nimport {getIntermediatePosition} from './geojson-edit-mode';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawCircleByDiameterMode extends TwoClickPolygonMode {\n radius: number | null | undefined = null;\n position: Position = null!;\n areaCircle: number | null | undefined = null;\n diameter: number | null | undefined = null;\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n // Default turf value for circle is 64\n const {steps = 64} = modeConfig || {};\n const options = {steps};\n\n if (steps < 4) {\n console.warn('Minimum steps to draw a circle is 4 '); // eslint-disable-line no-console,no-undef\n options.steps = 4;\n }\n\n const centerCoordinates = getIntermediatePosition(coord1, coord2);\n // setting value of radius as distance of center and other point\n this.radius = Math.max(distance(coord1, centerCoordinates), 0.001);\n // setting value of diameter as distance of points\n this.diameter = Math.max(distance(coord1, coord2), 0.001);\n // setting position tooltip as center of circle\n this.position = centerCoordinates;\n\n const geometry = circle(centerCoordinates, this.radius, options);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.shape = 'Circle';\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Circle';\n geometry.properties.editProperties.radius = {value: this.radius, unit: 'kilometers'};\n geometry.properties.editProperties.center = centerCoordinates;\n // calculate area of circle with turf function\n this.areaCircle = area(geometry);\n // @ts-expect-error turf types diff\n return geometry;\n }\n\n /**\n * define the default function to display the tooltip for\n * nebula geometry mode type\n * @param props properties of geometry nebula mode\n */\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n return this._getTooltips({\n modeConfig: props.modeConfig,\n radius: this.radius,\n areaCircle: this.areaCircle,\n diameter: this.diameter\n });\n }\n\n /**\n * redefine the tooltip of geometry\n * @param modeConfig\n * @param radius\n * @param areaCircle\n * @param diameter\n */\n _getTooltips = memoize(({modeConfig, radius, areaCircle, diameter}) => {\n let tooltips: Tooltip[] = [];\n const {formatTooltip} = modeConfig || {};\n let text;\n if (radius && areaCircle) {\n if (formatTooltip) {\n text = formatTooltip(radius);\n } else {\n // By default, round to 2 decimal places and append units\n text = `Radius: ${parseFloat(radius).toFixed(2)} kilometers\n \\n Area: ${parseFloat(areaCircle).toFixed(2)}\n \\n Diameter: ${parseFloat(diameter).toFixed(2)} kilometers`;\n }\n\n tooltips = [\n {\n position: this.position,\n text\n }\n ];\n }\n\n return tooltips;\n });\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport bboxPolygon from '@turf/bbox-polygon';\nimport distance from '@turf/distance';\nimport ellipse from '@turf/ellipse';\nimport {point} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {getIntermediatePosition} from './geojson-edit-mode';\nimport {TwoClickPolygonMode} from './two-click-polygon-mode';\n\nexport class DrawEllipseByBoundingBoxMode extends TwoClickPolygonMode {\n getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {\n const minX = Math.min(coord1[0], coord2[0]);\n const minY = Math.min(coord1[1], coord2[1]);\n const maxX = Math.max(coord1[0], coord2[0]);\n const maxY = Math.max(coord1[1], coord2[1]);\n\n const polygonPoints = bboxPolygon([minX, minY, maxX, maxY]).geometry.coordinates[0];\n const centerCoordinates = getIntermediatePosition(coord1, coord2);\n\n const xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001);\n const ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001);\n\n const geometry = ellipse(centerCoordinates, xSemiAxis, ySemiAxis);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Ellipse';\n geometry.properties.editProperties.xSemiAxis = {value: xSemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.ySemiAxis = {value: ySemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.angle = 0;\n geometry.properties.editProperties.center = centerCoordinates;\n // @ts-expect-error fix return types\n return geometry;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport omit from 'lodash.omit';\n\nexport class ThreeClickPolygonMode extends GeoJsonEditMode {\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n this.addClickSequence(event);\n const clickSequence = this.getClickSequence();\n const tentativeFeature = this.getTentativeGuide(props);\n\n if (\n clickSequence.length > 2 &&\n tentativeFeature &&\n tentativeFeature.geometry.type === 'Polygon'\n ) {\n const editAction = this.getAddFeatureOrBooleanPolygonAction(\n tentativeFeature.geometry,\n props,\n omit(tentativeFeature.properties, 'guideType')\n );\n this.resetClickSequence();\n\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent, modeConfig} = props;\n const clickSequence = this.getClickSequence();\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length === 0) {\n // nothing to do yet\n return guides;\n }\n\n const hoveredCoord = lastPointerMoveEvent.mapCoords;\n\n if (clickSequence.length === 1) {\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [clickSequence[0], hoveredCoord]\n }\n });\n } else {\n const polygon = this.getThreeClickPolygon(\n clickSequence[0],\n clickSequence[1],\n hoveredCoord,\n modeConfig\n );\n if (polygon) {\n guides.features.push({\n type: 'Feature',\n properties: {\n ...polygon.properties,\n guideType: 'tentative'\n },\n geometry: polygon.geometry\n });\n }\n }\n\n return guides;\n }\n\n getThreeClickPolygon(\n coord1: Position,\n coord2: Position,\n coord3: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n return null;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];\n\n let tentativeFeature;\n if (clickSequence.length === 2) {\n tentativeFeature = this.getThreeClickPolygon(\n clickSequence[0],\n clickSequence[1],\n lastCoords[0],\n props.modeConfig\n );\n }\n\n return tentativeFeature;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {generatePointsParallelToLinePoints} from './utils';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {ThreeClickPolygonMode} from './three-click-polygon-mode';\n\nexport class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode {\n getThreeClickPolygon(\n coord1: Position,\n coord2: Position,\n coord3: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n const [p3, p4] = generatePointsParallelToLinePoints(coord1, coord2, coord3);\n\n return {\n type: 'Feature',\n properties: {\n shape: 'Rectangle'\n },\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n // Draw a polygon containing all the points of the LineString,\n // then the points orthogonal to the lineString,\n // then back to the starting position\n coord1,\n coord2,\n p3,\n p4,\n coord1\n ]\n ]\n }\n };\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport distance from '@turf/distance';\nimport ellipse from '@turf/ellipse';\nimport bearing from '@turf/bearing';\nimport {point} from '@turf/helpers';\nimport {Position, Polygon, FeatureOf} from '../utils/geojson-types';\nimport {getIntermediatePosition} from './geojson-edit-mode';\nimport {ThreeClickPolygonMode} from './three-click-polygon-mode';\n\nexport class DrawEllipseUsingThreePointsMode extends ThreeClickPolygonMode {\n getThreeClickPolygon(\n coord1: Position,\n coord2: Position,\n coord3: Position,\n modeConfig: any\n ): FeatureOf<Polygon> | null | undefined {\n const centerCoordinates = getIntermediatePosition(coord1, coord2);\n const xSemiAxis = Math.max(distance(centerCoordinates, point(coord3)), 0.001);\n const ySemiAxis = Math.max(distance(coord1, coord2), 0.001) / 2;\n const options = {angle: bearing(coord1, coord2)};\n // @ts-expect-error fix return types\n const geometry = ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options);\n\n geometry.properties = geometry.properties || {};\n geometry.properties.editProperties = geometry.properties.editProperties || {};\n geometry.properties.editProperties.shape = 'Ellipse';\n geometry.properties.editProperties.xSemiAxis = {value: xSemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.ySemiAxis = {value: ySemiAxis, unit: 'kilometers'};\n geometry.properties.editProperties.angle = options.angle;\n geometry.properties.editProperties.center = centerCoordinates;\n // @ts-expect-error fix return types\n return geometry;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport destination from '@turf/destination';\nimport bearing from '@turf/bearing';\nimport lineIntersect from '@turf/line-intersect';\nimport turfDistance from '@turf/distance';\nimport {point, lineString as turfLineString} from '@turf/helpers';\nimport {\n generatePointsParallelToLinePoints,\n getPickedEditHandle,\n getEditHandlesForGeometry\n} from './utils';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n TentativeFeature\n} from './types';\nimport {Polygon, LineString, Position, FeatureCollection} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class Draw90DegreePolygonMode extends GeoJsonEditMode {\n createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {\n const clickSequence = this.getClickSequence();\n\n const {mapCoords} = props.lastPointerMoveEvent;\n\n let p3;\n if (clickSequence.length <= 1) {\n p3 = mapCoords;\n } else {\n const p1 = clickSequence[clickSequence.length - 2];\n const p2 = clickSequence[clickSequence.length - 1];\n [p3] = generatePointsParallelToLinePoints(p1, p2, mapCoords);\n }\n\n let tentativeFeature;\n\n if (clickSequence.length < 3) {\n // Draw a LineString connecting all the clicked points with the hovered point\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, p3]\n }\n };\n } else {\n // Draw a Polygon connecting all the clicked points with the hovered point\n tentativeFeature = {\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'Polygon',\n coordinates: [[...clickSequence, p3, clickSequence[0]]]\n }\n };\n }\n\n return tentativeFeature;\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n const clickSequence = this.getClickSequence();\n\n if (clickSequence.length === 0 || !props.lastPointerMoveEvent) {\n return guides;\n }\n const tentativeFeature = this.createTentativeFeature(props);\n\n guides.features.push(tentativeFeature);\n\n guides.features = guides.features.concat(\n getEditHandlesForGeometry(tentativeFeature.geometry, -1)\n );\n\n // Slice off the handles that are are next to the pointer\n guides.features = guides.features.slice(0, -1);\n\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n super.handlePointerMove(event, props);\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const tentativeFeature = this.getTentativeGuide(props);\n this.addClickSequence(event);\n const clickSequence = this.getClickSequence();\n\n if (!tentativeFeature) {\n // nothing else to do\n return;\n }\n\n if (clickSequence.length === 3 && tentativeFeature.geometry.type === 'LineString') {\n const lineString: LineString = tentativeFeature.geometry;\n\n // Tweak the clicked position to be the snapped 90 degree point along the polygon\n clickSequence[clickSequence.length - 1] =\n lineString.coordinates[lineString.coordinates.length - 1];\n } else if (clickSequence.length > 3 && tentativeFeature.geometry.type === 'Polygon') {\n const polygon: Polygon = tentativeFeature.geometry;\n\n // Tweak the clicked position to be the snapped 90 degree point along the polygon\n clickSequence[clickSequence.length - 1] =\n polygon.coordinates[0][polygon.coordinates[0].length - 2];\n\n const clickedEditHandle = getPickedEditHandle(picks);\n\n if (\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n (clickedEditHandle.properties.positionIndexes[1] === 0 ||\n clickedEditHandle.properties.positionIndexes[1] === polygon.coordinates[0].length - 3)\n ) {\n // They clicked the first or last point (or double-clicked), so complete the polygon\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: this.finalizedCoordinates([...polygon.coordinates[0]])\n };\n\n this.resetClickSequence();\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n } else {\n // Trigger pointer move right away in order for it to update edit handles (to support double-click)\n const fakePointerMoveEvent: PointerMoveEvent = {\n screenCoords: [-1, -1],\n mapCoords: event.mapCoords,\n picks: [],\n pointerDownPicks: null,\n pointerDownScreenCoords: null,\n pointerDownMapCoords: null,\n cancelPan: () => {},\n sourceEvent: null\n };\n\n this.handlePointerMove(fakePointerMoveEvent, props);\n }\n }\n\n finalizedCoordinates(coords: Position[]) {\n // Remove the hovered position\n let coordinates = [[...coords.slice(0, -2), coords[0]]];\n let pt = this.getIntermediatePoint([...coords]);\n if (!pt) {\n // if intermediate point with 90 degree not available\n // try remove the last clicked point and get the intermediate point.\n const tc = [...coords];\n tc.splice(-3, 1);\n pt = this.getIntermediatePoint([...tc]);\n if (pt) {\n coordinates = [[...coords.slice(0, -3), pt, coords[0]]];\n }\n } else {\n coordinates = [[...coords.slice(0, -2), pt, coords[0]]];\n }\n return coordinates;\n }\n\n getIntermediatePoint(coordinates: Position[]): Position | null {\n let pt: Position | null = null;\n if (coordinates.length > 4) {\n const [p1, p2] = [...coordinates];\n const angle1 = bearing(p1, p2);\n const p3 = coordinates[coordinates.length - 3];\n const p4 = coordinates[coordinates.length - 4];\n const angle2 = bearing(p3, p4);\n\n const angles = {first: [] as number[], second: [] as number[]};\n // calculate 3 right angle points for first and last points in lineString\n [1, 2, 3].forEach((factor) => {\n const newAngle1 = angle1 + factor * 90;\n // convert angles to 0 to -180 for anti-clock and 0 to 180 for clock wise\n angles.first.push(newAngle1 > 180 ? newAngle1 - 360 : newAngle1);\n const newAngle2 = angle2 + factor * 90;\n angles.second.push(newAngle2 > 180 ? newAngle2 - 360 : newAngle2);\n });\n\n const distance = turfDistance(point(p1), point(p3));\n // Draw imaginary right angle lines for both first and last points in lineString\n // If there is intersection point for any 2 lines, will be the 90 degree point.\n [0, 1, 2].forEach((indexFirst) => {\n const line1 = turfLineString([\n p1,\n destination(p1, distance, angles.first[indexFirst]).geometry.coordinates\n ]);\n [0, 1, 2].forEach((indexSecond) => {\n const line2 = turfLineString([\n p3,\n destination(p3, distance, angles.second[indexSecond]).geometry.coordinates\n ]);\n const fc = lineIntersect(line1, line2);\n if (fc && fc.features.length) {\n // found the intersect point\n pt = fc.features[0].geometry.coordinates;\n }\n });\n });\n }\n return pt;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport throttle from 'lodash.throttle';\nimport {ClickEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps} from './types';\nimport {Polygon, FeatureCollection} from '../utils/geojson-types';\nimport {getPickedEditHandle} from './utils';\nimport {DrawPolygonMode} from './draw-polygon-mode';\n\ntype DraggingHandler = (event: DraggingEvent, props: ModeProps<FeatureCollection>) => void;\n\nexport class DrawPolygonByDraggingMode extends DrawPolygonMode {\n handleDraggingThrottled: DraggingHandler | null | undefined = null;\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n // No-op\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n event.cancelPan();\n if (props.modeConfig && props.modeConfig.throttleMs) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.handleDraggingThrottled = throttle(this.handleDraggingAux, props.modeConfig.throttleMs);\n } else {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.handleDraggingThrottled = this.handleDraggingAux;\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n this.addClickSequence(event);\n const clickSequence = this.getClickSequence();\n // @ts-expect-error cancel() not typed\n if (this.handleDraggingThrottled && this.handleDraggingThrottled.cancel) {\n // @ts-expect-error cancel() not typed\n this.handleDraggingThrottled.cancel();\n }\n\n if (clickSequence.length > 2) {\n // Complete the polygon.\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: [[...clickSequence, clickSequence[0]]]\n };\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n this.resetClickSequence();\n }\n\n handleDraggingAux(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n\n if (!clickedEditHandle) {\n // Don't add another point right next to an existing one.\n this.addClickSequence(event);\n props.onEdit({\n updatedData: props.data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this.handleDraggingThrottled) {\n this.handleDraggingThrottled(event, props);\n }\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n if (event.key === 'Enter') {\n const clickSequence = this.getClickSequence();\n if (clickSequence.length > 2) {\n const polygonToAdd: Polygon = {\n type: 'Polygon',\n coordinates: [[...clickSequence, clickSequence[0]]]\n };\n this.resetClickSequence();\n\n const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);\n if (editAction) {\n props.onEdit(editAction);\n }\n }\n } else if (event.key === 'Escape') {\n this.resetClickSequence();\n if (this.handleDraggingThrottled) {\n this.handleDraggingThrottled = null;\n }\n props.onEdit({\n // Because the new drawing feature is dropped, so the data will keep as the same.\n updatedData: props.data,\n editType: 'cancelFeature',\n editContext: {}\n });\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Position, Feature, FeatureCollection} from '../utils/geojson-types';\nimport {\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n ModeProps,\n Pick,\n GuideFeatureCollection,\n EditHandleFeature\n} from './types';\nimport {\n getPickedSnapSourceEditHandle,\n getPickedEditHandles,\n getEditHandlesForGeometry\n} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\ntype MovementTypeEvent = PointerMoveEvent | StartDraggingEvent | StopDraggingEvent | DraggingEvent;\n\nexport class SnappableMode extends GeoJsonEditMode {\n _handler: GeoJsonEditMode;\n\n constructor(handler: GeoJsonEditMode) {\n super();\n this._handler = handler;\n }\n\n _getSnappedMouseEvent<T extends MovementTypeEvent>(\n event: T,\n snapSource: EditHandleFeature,\n snapTarget: EditHandleFeature\n ): T {\n return Object.assign(event, {\n mapCoords: snapTarget.geometry.coordinates,\n pointerDownMapCoords: snapSource && snapSource.geometry.coordinates\n });\n }\n\n _getPickedSnapTarget(picks: Pick[]): EditHandleFeature | null | undefined {\n return getPickedEditHandles(picks).find(\n (handle) => handle.properties.editHandleType === 'snap-target'\n );\n }\n\n _getPickedSnapSource(\n pointerDownPicks: Pick[] | null | undefined\n ): EditHandleFeature | null | undefined {\n return getPickedSnapSourceEditHandle(pointerDownPicks);\n }\n\n _getUpdatedSnapSourceHandle(\n snapSourceHandle: EditHandleFeature,\n data: FeatureCollection\n ): EditHandleFeature {\n const {featureIndex, positionIndexes} = snapSourceHandle.properties;\n if (!Array.isArray(positionIndexes)) {\n return snapSourceHandle;\n }\n const snapSourceFeature = data.features[featureIndex];\n\n // $FlowFixMe\n const snapSourceCoordinates = positionIndexes.reduce(\n (a: any[], b: number) => a[b],\n snapSourceFeature.geometry.coordinates\n ) as Position;\n\n return {\n ...snapSourceHandle,\n geometry: {\n type: 'Point',\n coordinates: snapSourceCoordinates\n }\n };\n }\n\n // If additionalSnapTargets is present in modeConfig and is populated, this\n // method will return those features along with the features\n // that live in the current layer. Otherwise, this method will simply return the\n // features from the current layer\n _getSnapTargets(props: ModeProps<FeatureCollection>): Feature[] {\n let {additionalSnapTargets} = props.modeConfig || {};\n additionalSnapTargets = additionalSnapTargets || [];\n\n const features = [...props.data.features, ...additionalSnapTargets];\n return features;\n }\n\n _getSnapTargetHandles(props: ModeProps<FeatureCollection>): EditHandleFeature[] {\n const handles: EditHandleFeature[] = [];\n const features = this._getSnapTargets(props);\n\n for (let i = 0; i < features.length; i++) {\n // Filter out the currently selected feature(s)\n const isCurrentIndexFeatureNotSelected = !props.selectedIndexes.includes(i);\n\n if (isCurrentIndexFeatureNotSelected) {\n const {geometry} = features[i];\n handles.push(...getEditHandlesForGeometry(geometry, i, 'snap-target'));\n }\n }\n return handles;\n }\n\n // If no snap handle has been picked, only display the edit handles of the\n // selected feature. If a snap handle has been picked, display said snap handle\n // along with all snappable points on all non-selected features.\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {modeConfig, lastPointerMoveEvent} = props;\n const {enableSnapping} = modeConfig || {};\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: [...this._handler.getGuides(props).features]\n };\n\n if (!enableSnapping) {\n return guides;\n }\n\n const snapSourceHandle: EditHandleFeature | null | undefined =\n lastPointerMoveEvent && this._getPickedSnapSource(lastPointerMoveEvent.pointerDownPicks);\n\n // They started dragging a handle\n // So render the picked handle (in its updated location) and all possible snap targets\n if (snapSourceHandle) {\n guides.features.push(\n ...this._getSnapTargetHandles(props),\n this._getUpdatedSnapSourceHandle(snapSourceHandle, props.data)\n );\n\n return guides;\n }\n\n // Render the possible snap source handles\n const {features} = props.data;\n for (const index of props.selectedIndexes) {\n if (index < features.length) {\n const {geometry} = features[index];\n guides.features.push(...getEditHandlesForGeometry(geometry, index, 'snap-source'));\n }\n }\n\n return guides;\n }\n\n _getSnapAwareEvent<T extends MovementTypeEvent>(\n event: T,\n props: ModeProps<FeatureCollection>\n ): T {\n const snapSource = this._getPickedSnapSource(props.lastPointerMoveEvent.pointerDownPicks);\n const snapTarget = this._getPickedSnapTarget(event.picks);\n\n return snapSource && snapTarget\n ? this._getSnappedMouseEvent(event, snapSource, snapTarget)\n : event;\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handleStartDragging(event, props);\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handleStopDragging(this._getSnapAwareEvent(event, props), props);\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handleDragging(this._getSnapAwareEvent(event, props), props);\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n this._handler.handlePointerMove(this._getSnapAwareEvent(event, props), props);\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {featureCollection} from '@turf/helpers';\nimport {PointerMoveEvent, ModeProps, StartDraggingEvent} from './types';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {TranslateMode} from './translate-mode';\nimport {ScaleMode} from './scale-mode';\nimport {RotateMode} from './rotate-mode';\n\nimport {CompositeMode} from './composite-mode';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class TransformMode extends CompositeMode {\n constructor() {\n super([new TranslateMode(), new ScaleMode(), new RotateMode()]);\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n let updatedCursor: string | null = null;\n super.handlePointerMove(event, {\n ...props,\n onUpdateCursor: (cursor) => {\n updatedCursor = cursor || updatedCursor;\n }\n });\n props.onUpdateCursor(updatedCursor);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n let scaleMode: ScaleMode | null = null;\n let translateMode: TranslateMode | null = null;\n const filteredModes: GeoJsonEditMode[] = [];\n\n if (event.picks.length) {\n event.cancelPan();\n }\n\n // If the user selects a scaling edit handle that overlaps with part of the selected feature,\n // it is possible for both scale and translate actions to be triggered. This logic prevents\n // this simultaneous action trigger from happening by putting a higher priority on scaling\n // since the user needs to be more precise to hover over a scaling edit handle.\n this._modes.forEach((mode) => {\n if (mode instanceof TranslateMode) {\n translateMode = mode;\n } else {\n if (mode instanceof ScaleMode) {\n scaleMode = mode;\n }\n filteredModes.push(mode);\n }\n });\n\n if (scaleMode instanceof ScaleMode && !scaleMode.isEditHandleSelected()) {\n filteredModes.push(translateMode);\n }\n\n filteredModes.filter(Boolean).forEach((mode) => mode.handleStartDragging(event, props));\n }\n\n getGuides(props: ModeProps<FeatureCollection>) {\n let compositeGuides = super.getGuides(props);\n const rotateMode = (this._modes || []).find((mode) => mode instanceof RotateMode);\n\n if (rotateMode instanceof RotateMode) {\n const nonEnvelopeGuides = compositeGuides.features.filter((guide) => {\n const {editHandleType, mode} = (guide.properties as any) || {};\n // Both scale and rotate modes have the same enveloping box as a guide - only need one\n const guidesToFilterOut = [mode];\n // Do not render scaling edit handles if rotating\n if (rotateMode.getIsRotating()) {\n guidesToFilterOut.push(editHandleType);\n }\n return !guidesToFilterOut.includes('scale');\n });\n\n // @ts-expect-error turf types\n compositeGuides = featureCollection(nonEnvelopeGuides);\n }\n return compositeGuides;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {\n ModeProps,\n ClickEvent,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n GuideFeatureCollection,\n GuideFeature\n} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class CompositeMode extends GeoJsonEditMode {\n _modes: Array<GeoJsonEditMode>;\n\n constructor(modes: Array<GeoJsonEditMode>) {\n super();\n this._modes = modes;\n }\n\n _coalesce<T>(\n callback: (arg0: GeoJsonEditMode) => T,\n resultEval: ((arg0: T) => boolean | null | undefined) | null = null\n ): T {\n let result: T | null = null;\n\n for (let i = 0; i < this._modes.length; i++) {\n // eslint-disable-next-line callback-return\n result = callback(this._modes[i]);\n if (resultEval ? resultEval(result) : result) {\n break;\n }\n }\n\n return result;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {\n this._coalesce((handler) => handler.handleClick(event, props));\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handlePointerMove(event, props));\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handleStartDragging(event, props));\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handleStopDragging(event, props));\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n return this._coalesce((handler) => handler.handleDragging(event, props));\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n // TODO: Combine the guides *BUT* make sure if none of the results have\n // changed to return the same object so that \"guides !== this.state.guides\"\n // in editable-geojson-layer works.\n\n const allGuides: GuideFeature[] = [];\n for (const mode of this._modes) {\n allGuides.push(...mode.getGuides(props).features);\n }\n\n return {\n type: 'FeatureCollection',\n features: allGuides\n };\n }\n}\n", "import {FeatureCollection} from '../utils/geojson-types';\n\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ClickEvent, ModeProps} from './types';\nexport class DeleteMode extends GeoJsonEditMode {\n handleClick(_event: ClickEvent, props: ModeProps<FeatureCollection>): void {\n const selectedFeatureIndexes = props.lastPointerMoveEvent.picks.map((pick) => pick.index);\n if (selectedFeatureIndexes.length > 0) {\n const indexToDelete = selectedFeatureIndexes[0];\n\n const features = props.data.features.filter((_, index) => index !== indexToDelete);\n const updatedData = {\n ...props.data,\n features\n };\n\n const editAction = {\n updatedData,\n editType: 'deleteFeature',\n editContext: {\n featureIndexes: selectedFeatureIndexes\n }\n };\n\n props.onEdit(editAction);\n }\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.\n * Required in order to maintain the same appearance after upgrading to deck.gl v8.5.\n * https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md\n */\nexport const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;\n\n/**\n * Unit literal to shader unit number conversion.\n */\nexport const UNIT = {\n common: 0,\n meters: 1,\n pixels: 2\n};\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {CompositeLayerProps} from '@deck.gl/core';\nimport {CompositeLayer} from '@deck.gl/core';\nimport {\n DraggingEvent,\n ClickEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n PointerMoveEvent,\n DoubleClickEvent\n} from '../edit-modes/types';\nimport {Position} from '../utils/geojson-types';\n\nconst EVENT_TYPES = ['click', 'pointermove', 'panstart', 'panmove', 'panend', 'keyup', 'dblclick'];\n\n// TODO(v9): remove generic layer\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type EditableLayerProps<DataType = any> = CompositeLayerProps & {\n pickingRadius?: number;\n pickingDepth?: number;\n onCancelPan?: () => void;\n};\n\nexport abstract class EditableLayer<\n DataT = any,\n ExtraPropsT = Record<string, unknown>\n> extends CompositeLayer<ExtraPropsT & Required<EditableLayerProps<DataT>>> {\n static layerName = 'EditableLayer';\n\n state: {_editableLayerState: any} = undefined!;\n\n // Overridable interaction event handlers\n onLayerClick(event: ClickEvent): void {\n // default implementation - do nothing\n }\n onLayerDoubleClick(event: DoubleClickEvent): void {\n // default implementation - do nothing\n }\n\n onStartDragging(event: StartDraggingEvent): void {\n // default implementation - do nothing\n }\n\n onStopDragging(event: StopDraggingEvent): void {\n // default implementation - do nothing\n }\n\n onDragging(event: DraggingEvent): void {\n // default implementation - do nothing\n }\n\n onPointerMove(event: PointerMoveEvent): void {\n // default implementation - do nothing\n }\n\n onLayerKeyUp(event: KeyboardEvent): void {\n // default implementation - do nothing;\n }\n // TODO: implement onCancelDragging (e.g. drag off screen)\n\n initializeState() {\n this.setState({\n _editableLayerState: {\n // Picked objects at the time the pointer went down\n pointerDownPicks: null,\n // Screen coordinates where the pointer went down\n pointerDownScreenCoords: null,\n // Ground coordinates where the pointer went down\n pointerDownMapCoords: null,\n\n // Keep track of the mjolnir.js event handler so it can be deregistered\n eventHandler: this._forwardEventToCurrentLayer.bind(this)\n }\n });\n\n this._addEventHandlers();\n }\n\n finalizeState() {\n this._removeEventHandlers();\n }\n\n _addEventHandlers() {\n // @ts-expect-error accessing protected props\n const {eventManager} = this.context.deck;\n const {eventHandler} = this.state._editableLayerState;\n\n for (const eventType of EVENT_TYPES) {\n eventManager.on(eventType as any, eventHandler, {\n // give nebula a higher priority so that it can stop propagation to deck.gl's map panning handlers\n priority: 100\n });\n }\n }\n\n _removeEventHandlers() {\n // @ts-expect-error accessing protected props\n const {eventManager} = this.context.deck;\n const {eventHandler} = this.state._editableLayerState;\n\n for (const eventType of EVENT_TYPES) {\n eventManager.off(eventType as any, eventHandler);\n }\n }\n\n // A new layer instance is created on every render, so forward the event to the current layer\n // This means that the first layer instance will stick around to be the event listener, but will forward the event\n // to the latest layer instance.\n _forwardEventToCurrentLayer(event: any) {\n const currentLayer = this.getCurrentLayer();\n\n // Use a naming convention to find the event handling function for this event type\n const func = currentLayer[`_on${event.type}`].bind(currentLayer);\n if (!func) {\n console.warn(`no handler for mjolnir.js event ${event.type}`); // eslint-disable-line\n return;\n }\n func(event);\n }\n\n _onclick({srcEvent}: any) {\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const picks = this.getPicks(screenCoords);\n\n this.onLayerClick({\n mapCoords,\n screenCoords,\n picks,\n sourceEvent: srcEvent\n });\n }\n\n _ondblclick({srcEvent}: any) {\n this.onLayerDoubleClick(srcEvent);\n }\n\n _onkeyup({srcEvent}: {srcEvent: KeyboardEvent}) {\n this.onLayerKeyUp(srcEvent);\n }\n\n _onpanstart(event: any) {\n const screenCoords = this.getScreenCoords(event.srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n const picks = this.getPicks(screenCoords);\n\n this.setState({\n _editableLayerState: {\n ...this.state._editableLayerState,\n pointerDownScreenCoords: screenCoords,\n pointerDownMapCoords: mapCoords,\n pointerDownPicks: picks\n }\n });\n\n this.onStartDragging({\n picks,\n screenCoords,\n mapCoords,\n pointerDownScreenCoords: screenCoords,\n pointerDownMapCoords: mapCoords,\n cancelPan: () => {\n if (this.props.onCancelPan) {\n this.props.onCancelPan();\n }\n\n event.stopImmediatePropagation();\n },\n sourceEvent: event.srcEvent\n });\n }\n\n _onpanmove(event: any) {\n const {srcEvent} = event;\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const {pointerDownPicks, pointerDownScreenCoords, pointerDownMapCoords} =\n this.state._editableLayerState;\n\n const picks = this.getPicks(screenCoords);\n\n this.onDragging({\n screenCoords,\n mapCoords,\n picks,\n pointerDownPicks,\n pointerDownScreenCoords,\n pointerDownMapCoords,\n sourceEvent: srcEvent,\n cancelPan: event.stopImmediatePropagation\n // another (hacky) approach for cancelling map panning\n // const controller = this.context.deck.viewManager.controllers[\n // Object.keys(this.context.deck.viewManager.controllers)[0]\n // ];\n // controller._state.isDragging = false;\n });\n }\n\n _onpanend({srcEvent}: any) {\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const {pointerDownPicks, pointerDownScreenCoords, pointerDownMapCoords} =\n this.state._editableLayerState;\n\n const picks = this.getPicks(screenCoords);\n\n this.onStopDragging({\n picks,\n screenCoords,\n mapCoords,\n pointerDownPicks,\n pointerDownScreenCoords,\n pointerDownMapCoords,\n sourceEvent: srcEvent\n });\n\n this.setState({\n _editableLayerState: {\n ...this.state._editableLayerState,\n pointerDownScreenCoords: null,\n pointerDownMapCoords: null,\n pointerDownPicks: null\n }\n });\n }\n\n _onpointermove(event: any) {\n const {srcEvent} = event;\n const screenCoords = this.getScreenCoords(srcEvent) as [number, number];\n const mapCoords = this.getMapCoords(screenCoords);\n\n const {pointerDownPicks, pointerDownScreenCoords, pointerDownMapCoords} =\n this.state._editableLayerState;\n\n const picks = this.getPicks(screenCoords);\n\n this.onPointerMove({\n screenCoords,\n mapCoords,\n picks,\n pointerDownPicks,\n pointerDownScreenCoords,\n pointerDownMapCoords,\n sourceEvent: srcEvent,\n cancelPan: event.stopImmediatePropagation\n });\n }\n\n getPicks(screenCoords: [number, number]) {\n return this.context.deck.pickMultipleObjects({\n x: screenCoords[0],\n y: screenCoords[1],\n layerIds: [this.props.id],\n radius: this.props.pickingRadius,\n depth: this.props.pickingDepth\n });\n }\n\n getScreenCoords(pointerEvent: any): Position {\n return [\n pointerEvent.clientX -\n (this.context.gl.canvas as HTMLCanvasElement).getBoundingClientRect().left,\n pointerEvent.clientY -\n (this.context.gl.canvas as HTMLCanvasElement).getBoundingClientRect().top\n ];\n }\n\n getMapCoords(screenCoords: Position): Position {\n return this.context.viewport.unproject([screenCoords[0], screenCoords[1]]) as Position;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {PathLayerProps} from '@deck.gl/layers';\nimport {PathLayer} from '@deck.gl/layers';\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\nimport {insertBefore} from '../utils/utils';\n\nconst uniformBlock = `\\\nuniform pickingLineWidthUniforms {\n float extraPixels;\n} pickingLineWidth;\n`;\n\nexport type PickingLineWidthProps = {\n extraPixels: number;\n};\n\nexport const pickingUniforms = {\n name: 'pickingLineWidth',\n vs: uniformBlock,\n fs: uniformBlock,\n uniformTypes: {\n extraPixels: 'f32'\n }\n} as const satisfies ShaderModule<PickingLineWidthProps>;\n\ninterface EditablePathLayerProps extends PathLayerProps<any> {\n pickingLineWidthExtraPixels?: number;\n}\n\nconst defaultProps = {\n ...PathLayer.defaultProps,\n pickingLineWidthExtraPixels: {type: 'number', min: 0, value: Number.MAX_SAFE_INTEGER}\n};\n\nexport class EditablePathLayer extends PathLayer<any, EditablePathLayerProps> {\n getShaders() {\n const shaders = super.getShaders();\n\n shaders.vs = insertBefore(\n shaders.vs,\n 'vec3 width;',\n `\n if(bool(picking.isActive)){\n widthPixels.xy += pickingLineWidth.extraPixels;\n }\n `\n );\n\n return {\n ...shaders,\n modules: [...shaders.modules, pickingUniforms]\n };\n }\n\n draw(props) {\n const {pickingLineWidthExtraPixels} = this.props;\n const pickingProps: PickingLineWidthProps = {extraPixels: pickingLineWidthExtraPixels};\n const model = this.state.model;\n model.shaderInputs.setProps({pickingLineWidth: pickingProps});\n super.draw(props);\n }\n}\n\nEditablePathLayer.defaultProps = defaultProps;\nEditablePathLayer.layerName = 'EditablePathLayer';\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {DefaultProps} from '@deck.gl/core';\nimport {H3ClusterLayer} from '@deck.gl/geo-layers';\n// TODO: Fix H3 support.\n// import { polyfill, geoToH3 } from 'h3-js';\nimport {PROJECTED_PIXEL_SIZE_MULTIPLIER} from '../constants';\nimport {EditableGeoJsonLayer} from './editable-geojson-layer';\nimport {EditableLayer, EditableLayerProps} from './editable-layer';\nimport {ViewMode} from '../edit-modes/view-mode';\n\nconst DEFAULT_EDIT_MODE = ViewMode;\nconst DEFAULT_H3_RESOLUTION = 9;\nconst EMPTY_FEATURE_COLLECTION = {\n type: 'FeatureCollection',\n features: []\n};\n\nexport type EditableH3ClusterLayerProps<DataT> = EditableLayerProps & {\n data: DataT;\n resolution?: number;\n mode?: any;\n modeConfig?: any;\n selectedIndexes?: number[];\n getEditedCluster?: (updatedHexagons: any[], existingCluster: any) => any;\n getHexagons?: (d) => number[];\n onEdit?: (updatedData?, editType?: string, featureIndexes?: number[], editContext?) => void;\n filled?: boolean;\n stroked?: boolean;\n lineWidthScale?: number;\n lineWidthMinPixels?: number;\n lineWidthMaxPixels?: number;\n lineWidthUnits?: string;\n};\n\nconst defaultProps: DefaultProps<EditableH3ClusterLayerProps<any>> = {\n mode: DEFAULT_EDIT_MODE,\n\n ...EditableGeoJsonLayer.defaultProps,\n\n // h3 layer\n data: [],\n selectedIndexes: [],\n filled: false,\n stroked: true,\n lineWidthScale: PROJECTED_PIXEL_SIZE_MULTIPLIER,\n lineWidthMinPixels: 1,\n lineWidthMaxPixels: Number.MAX_SAFE_INTEGER,\n lineWidthUnits: 'pixels',\n getHexagons: (d) => d.hexIds,\n getEditedCluster: (updatedHexagons, existingCluster) => {\n if (existingCluster) {\n return {\n ...existingCluster,\n hexIds: updatedHexagons\n };\n }\n return {\n hexIds: updatedHexagons\n };\n },\n resolution: DEFAULT_H3_RESOLUTION\n};\n\nexport class EditableH3ClusterLayer extends EditableLayer<any, EditableH3ClusterLayerProps<any>> {\n static layerName = 'EditableH3ClusterLayer';\n static defaultProps = defaultProps;\n\n state: EditableLayer['state'] & {\n cursor?: 'grabbing' | 'grab' | null;\n tentativeHexagonIDs: string[];\n } = undefined!;\n\n initializeState() {\n super.initializeState();\n\n this.setState({\n tentativeHexagonIDs: []\n });\n }\n\n // convert array of (lng, lat) coords to cluster of hexes\n getDerivedHexagonIDs(coords) {\n throw new Error('not implemented'); // TODO\n // return polyfill(coords, this.props.resolution, true);\n }\n\n // convert pair of (lng, lat) coords into single hex\n getDerivedHexagonID(coords) {\n throw new Error('not implemented'); // TODO\n // return geoToH3(coords[1], coords[0], this.props.resolution);\n }\n\n renderLayers() {\n const layers: any = [\n new EditableGeoJsonLayer(\n this.getSubLayerProps({\n id: 'editable-geojson',\n\n mode: this.props.mode,\n data: EMPTY_FEATURE_COLLECTION,\n selectedFeatureIndexes: [],\n\n onEdit: (editAction) => {\n const {editType, editContext} = editAction;\n\n switch (editType) {\n case 'updateTentativeFeature':\n // tentative feature updates, updated on every pointer move\n if (editContext.feature.geometry.type === 'Polygon') {\n const coords = editContext.feature.geometry.coordinates;\n const hexIDs = this.getDerivedHexagonIDs(coords);\n\n this.setState({tentativeHexagonIDs: hexIDs});\n } else if (editContext.feature.geometry.type === 'Point') {\n const coords = editContext.feature.geometry.coordinates;\n const hexID = this.getDerivedHexagonID(coords);\n\n this.setState({tentativeHexagonIDs: [hexID]});\n }\n break;\n case 'addFeature':\n const updatedData = [...this.props.data];\n const {modeConfig} = this.props;\n\n if (!modeConfig || !modeConfig.booleanOperation) {\n // add new h3 cluster\n updatedData.push(\n this.props.getEditedCluster(this.state.tentativeHexagonIDs, null)\n );\n } else if (this.props.selectedIndexes.length !== 1) {\n // eslint-disable-next-line no-console,no-undef\n console.warn('booleanOperation only supported for single cluster selection');\n } else {\n // they're affecting a selected cluster\n let finalHexagonIDs: (string | number)[];\n const committedHexagonIDs = new Set<string | number>(this.getSelectedHexIDs());\n const tentativeHexagonIDs = new Set<string | number>(\n this.state.tentativeHexagonIDs\n );\n\n switch (modeConfig.booleanOperation) {\n case 'union':\n default:\n finalHexagonIDs = [\n ...new Set([...committedHexagonIDs, ...tentativeHexagonIDs])\n ];\n break;\n case 'intersection':\n finalHexagonIDs = [...committedHexagonIDs].filter((hexID: string | number) =>\n tentativeHexagonIDs.has(hexID)\n );\n break;\n case 'difference':\n finalHexagonIDs = [...committedHexagonIDs].filter(\n (hexID: string | number) => !tentativeHexagonIDs.has(hexID)\n );\n break;\n }\n\n const selectedIndex = this.props.selectedIndexes[0];\n const existingCluster = this.props.data[selectedIndex];\n updatedData[selectedIndex] = this.props.getEditedCluster(\n finalHexagonIDs,\n existingCluster\n );\n }\n\n this.setState({\n tentativeHexagonIDs: []\n });\n\n this.props.onEdit({updatedData});\n\n break;\n default:\n break;\n }\n }\n })\n ),\n\n new H3ClusterLayer(\n this.getSubLayerProps({\n id: 'hexagons',\n data: this.props.data,\n getHexagons: this.props.getHexagons\n })\n ),\n new H3ClusterLayer(\n this.getSubLayerProps({\n id: 'tentative-hexagons',\n data: [\n {\n hexIds: this.state.tentativeHexagonIDs\n }\n ],\n getHexagons: (d) => d.hexIds\n })\n )\n ];\n return layers;\n }\n\n // because data is an array of hexagon data, we take the cumulative of all selected indexes,\n // using props.getHexagons to support multiple data types\n getSelectedHexIDs() {\n let cumulativeHexIDs: number[] = [];\n this.props.selectedIndexes.forEach((index) => {\n const selectedCluster = this.props.data[index];\n const hexIDs = this.props.getHexagons(selectedCluster);\n cumulativeHexIDs = cumulativeHexIDs.concat(hexIDs);\n });\n return cumulativeHexIDs;\n }\n\n getCursor({isDragging}: {isDragging: boolean}): 'grabbing' | 'grab' {\n let {cursor} = this.state || {};\n if (!cursor) {\n // default cursor\n cursor = isDragging ? 'grabbing' : 'grab';\n }\n return cursor;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport type {CompositeLayerProps, DefaultProps} from '@deck.gl/core';\nimport {CompositeLayer} from '@deck.gl/core';\nimport {PolygonLayer} from '@deck.gl/layers';\nimport {polygon} from '@turf/helpers';\nimport turfBuffer from '@turf/buffer';\nimport turfDifference from '@turf/difference';\n\nimport {EditableGeoJsonLayer} from './editable-geojson-layer';\nimport {DrawRectangleMode} from '../edit-modes/draw-rectangle-mode';\nimport {DrawPolygonMode} from '../edit-modes/draw-polygon-mode';\nimport {ViewMode} from '../edit-modes/view-mode';\n\nexport const SELECTION_TYPE = {\n NONE: null,\n RECTANGLE: 'rectangle',\n POLYGON: 'polygon'\n};\n\nconst MODE_MAP = {\n [SELECTION_TYPE.RECTANGLE]: DrawRectangleMode,\n [SELECTION_TYPE.POLYGON]: DrawPolygonMode\n};\n\nconst MODE_CONFIG_MAP = {\n [SELECTION_TYPE.RECTANGLE]: {dragToDraw: true}\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ninterface SelectionLayerProps<DataT> extends CompositeLayerProps {\n layerIds: any[];\n onSelect: (info: any) => any;\n selectionType: string | null;\n}\n\nconst defaultProps: DefaultProps<SelectionLayerProps<any>> = {\n selectionType: SELECTION_TYPE.RECTANGLE,\n layerIds: [],\n onSelect: () => {}\n};\n\nconst EMPTY_DATA = {\n type: 'FeatureCollection',\n features: []\n};\n\nconst EXPANSION_KM = 50;\nconst LAYER_ID_GEOJSON = 'selection-geojson';\nconst LAYER_ID_BLOCKER = 'selection-blocker';\n\nconst PASS_THROUGH_PROPS = [\n 'lineWidthScale',\n 'lineWidthMinPixels',\n 'lineWidthMaxPixels',\n 'lineWidthUnits',\n 'lineJointRounded',\n 'lineCapRounded',\n 'lineMiterLimit',\n 'pointRadiusScale',\n 'pointRadiusMinPixels',\n 'pointRadiusMaxPixels',\n 'lineDashJustified',\n 'getLineColor',\n 'getFillColor',\n 'getRadius',\n 'getLineWidth',\n 'getLineDashArray',\n 'getTentativeLineDashArray',\n 'getTentativeLineColor',\n 'getTentativeFillColor',\n 'getTentativeLineWidth'\n];\nexport class SelectionLayer<DataT, ExtraPropsT> extends CompositeLayer<\n ExtraPropsT & Required<SelectionLayerProps<DataT>>\n> {\n static layerName = 'SelectionLayer';\n static defaultProps = defaultProps;\n\n state: {\n pendingPolygonSelection: {\n bigPolygon: ReturnType<typeof turfDifference>;\n };\n } = undefined!;\n\n _selectRectangleObjects(coordinates: any) {\n const {layerIds, onSelect} = this.props;\n const [x1, y1] = this.context.viewport.project(coordinates[0][0]);\n const [x2, y2] = this.context.viewport.project(coordinates[0][2]);\n const pickingInfos = this.context.deck.pickObjects({\n x: Math.min(x1, x2),\n y: Math.min(y1, y2),\n width: Math.abs(x2 - x1),\n height: Math.abs(y2 - y1),\n layerIds\n });\n\n onSelect({pickingInfos});\n }\n\n _selectPolygonObjects(coordinates: any) {\n const {layerIds, onSelect} = this.props;\n const mousePoints = coordinates[0].map((c) => this.context.viewport.project(c));\n\n const allX = mousePoints.map((mousePoint) => mousePoint[0]);\n const allY = mousePoints.map((mousePoint) => mousePoint[1]);\n const x = Math.min(...allX);\n const y = Math.min(...allY);\n const maxX = Math.max(...allX);\n const maxY = Math.max(...allY);\n\n // Use a polygon to hide the outside, because pickObjects()\n // does not support polygons\n const landPointsPoly = polygon(coordinates);\n const bigBuffer = turfBuffer(landPointsPoly, EXPANSION_KM);\n let bigPolygon;\n try {\n // turfDifference throws an exception if the polygon\n // intersects with itself (TODO: check if true in all versions)\n bigPolygon = turfDifference(bigBuffer, landPointsPoly);\n } catch (e) {\n // invalid selection polygon\n console.log('turfDifference() error', e); // eslint-disable-line\n return;\n }\n\n this.setState({\n pendingPolygonSelection: {\n bigPolygon\n }\n });\n\n const blockerId = `${this.props.id}-${LAYER_ID_BLOCKER}`;\n\n // HACK, find a better way\n setTimeout(() => {\n const pickingInfos = this.context.deck.pickObjects({\n x,\n y,\n width: maxX - x,\n height: maxY - y,\n layerIds: [blockerId, ...layerIds]\n });\n\n onSelect({\n pickingInfos: pickingInfos.filter((item) => item.layer.id !== this.props.id)\n });\n }, 250);\n }\n\n renderLayers() {\n const {pendingPolygonSelection} = this.state;\n\n const mode = MODE_MAP[this.props.selectionType] || ViewMode;\n const modeConfig = MODE_CONFIG_MAP[this.props.selectionType];\n\n const inheritedProps = {};\n PASS_THROUGH_PROPS.forEach((p) => {\n if (this.props[p] !== undefined) inheritedProps[p] = this.props[p];\n });\n\n const layers: any[] = [\n new EditableGeoJsonLayer(\n this.getSubLayerProps({\n id: LAYER_ID_GEOJSON,\n pickable: true,\n mode,\n modeConfig,\n selectedFeatureIndexes: [],\n data: EMPTY_DATA,\n onEdit: ({updatedData, editType}) => {\n if (editType === 'addFeature') {\n const {coordinates} = updatedData.features[0].geometry;\n\n if (this.props.selectionType === SELECTION_TYPE.RECTANGLE) {\n this._selectRectangleObjects(coordinates);\n } else if (this.props.selectionType === SELECTION_TYPE.POLYGON) {\n this._selectPolygonObjects(coordinates);\n }\n }\n },\n ...inheritedProps\n })\n )\n ];\n\n if (pendingPolygonSelection) {\n const {bigPolygon} = pendingPolygonSelection as any;\n layers.push(\n new PolygonLayer(\n this.getSubLayerProps({\n id: LAYER_ID_BLOCKER,\n pickable: true,\n stroked: false,\n opacity: 1.0,\n data: [bigPolygon],\n getLineColor: (obj) => [0, 0, 0, 1],\n getFillColor: (obj) => [0, 0, 0, 1],\n getPolygon: (o) => o.geometry.coordinates\n })\n )\n );\n }\n\n return layers;\n }\n\n shouldUpdateState({changeFlags: {stateChanged, propsOrDataChanged}}: Record<string, any>) {\n return stateChanged || propsOrDataChanged;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-env browser */\n\nimport {CompositeLayer} from '@deck.gl/core';\nimport {ScatterplotLayer, LineLayer} from '@deck.gl/layers';\n\nconst defaultProps = {};\n\nexport class ElevatedEditHandleLayer extends CompositeLayer<any> {\n static layerName = 'ElevatedEditHandleLayer';\n static defaultProps = defaultProps;\n renderLayers() {\n const handles = new ScatterplotLayer(\n Object.assign({}, this.props, {\n id: `${this.props.id}-ScatterplotLayer`,\n data: this.props.data\n })\n );\n\n const lines = new LineLayer(\n Object.assign({}, this.props, {\n id: `${this.props.id}-LineLayer`,\n data: this.props.data,\n pickable: false,\n getSourcePosition: ({position}) => [position[0], position[1], 0],\n getTargetPosition: ({position}) => [position[0], position[1], position[2] || 0],\n getColor: [150, 150, 150, 200],\n getStrokeWidth: 3\n })\n );\n\n return [handles, lines];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport nearestPointOnLine from '@turf/nearest-point-on-line';\nimport {point, lineString as toLineString} from '@turf/helpers';\nimport circle from '@turf/circle';\nimport distance from '@turf/distance';\nimport turfCenter from '@turf/center';\nimport {\n recursivelyTraverseNestedArrays,\n nearestPointOnProjectedLine,\n getPickedEditHandles,\n getPickedEditHandle,\n NearestPointType\n} from './utils';\nimport {LineString, Point, FeatureCollection, FeatureOf} from '../utils/geojson-types';\nimport {Viewport} from '../utils/types';\nimport {\n ModeProps,\n PointerMoveEvent,\n StartDraggingEvent,\n StopDraggingEvent,\n DraggingEvent,\n EditHandleFeature,\n GuideFeatureCollection,\n GuideFeature\n} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ResizeCircleMode extends GeoJsonEditMode {\n _selectedEditHandle: EditHandleFeature | null | undefined;\n _isResizing = false;\n\n // eslint-disable-next-line complexity\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const handles: GuideFeature[] = [];\n const selectedFeatureIndexes = props.selectedIndexes;\n\n const {lastPointerMoveEvent} = props;\n const picks = lastPointerMoveEvent && lastPointerMoveEvent.picks;\n const mapCoords = lastPointerMoveEvent && lastPointerMoveEvent.mapCoords;\n\n // intermediate edit handle\n if (\n picks &&\n picks.length &&\n mapCoords &&\n selectedFeatureIndexes.length === 1 &&\n !this._isResizing\n ) {\n const featureAsPick = picks.find((pick) => !pick.isGuide);\n\n // is the feature in the pick selected\n if (\n featureAsPick &&\n featureAsPick.object.properties.shape &&\n featureAsPick.object.properties.shape.includes('Circle') &&\n props.selectedIndexes.includes(featureAsPick.index)\n ) {\n let intermediatePoint: NearestPointType | null = null;\n let positionIndexPrefix: number[] = [];\n const referencePoint = point(mapCoords);\n // process all lines of the (single) feature\n recursivelyTraverseNestedArrays(\n featureAsPick.object.geometry.coordinates,\n [],\n (lineString, prefix) => {\n const lineStringFeature = toLineString(lineString);\n const candidateIntermediatePoint = this.getNearestPoint(\n // @ts-expect-error turf types too wide\n lineStringFeature,\n referencePoint,\n props.modeConfig && props.modeConfig.viewport\n );\n if (\n !intermediatePoint ||\n candidateIntermediatePoint.properties.dist < intermediatePoint.properties.dist\n ) {\n intermediatePoint = candidateIntermediatePoint;\n positionIndexPrefix = prefix;\n }\n }\n );\n // tack on the lone intermediate point to the set of handles\n if (intermediatePoint) {\n const {\n geometry: {coordinates: position},\n properties: {index}\n } = intermediatePoint;\n handles.push({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'intermediate',\n featureIndex: featureAsPick.index,\n positionIndexes: [...positionIndexPrefix, index + 1]\n },\n geometry: {\n type: 'Point',\n coordinates: position\n }\n });\n }\n }\n }\n\n return {\n type: 'FeatureCollection',\n features: handles\n };\n }\n\n // turf.js does not support elevation for nearestPointOnLine\n getNearestPoint(\n line: FeatureOf<LineString>,\n inPoint: FeatureOf<Point>,\n viewport: Viewport | null | undefined\n ): NearestPointType {\n const {coordinates} = line.geometry;\n if (coordinates.some((coord) => coord.length > 2)) {\n if (viewport) {\n // This line has elevation, we need to use alternative algorithm\n return nearestPointOnProjectedLine(line, inPoint, viewport);\n }\n // eslint-disable-next-line no-console,no-undef\n console.log(\n 'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'\n );\n }\n // @ts-expect-error turf types diff\n return nearestPointOnLine(line, inPoint);\n }\n\n handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>): void {\n const editHandle = getPickedEditHandle(event.pointerDownPicks);\n\n if (editHandle) {\n // Cancel map panning if pointer went down on an edit handle\n event.cancelPan();\n\n const editHandleProperties = editHandle.properties;\n\n const feature = this.getSelectedFeature(props);\n // @ts-expect-error turf types diff\n const center = turfCenter(feature).geometry.coordinates;\n const numberOfSteps = Object.entries(feature.geometry.coordinates[0]).length - 1;\n const radius = Math.max(distance(center, event.mapCoords), 0.001);\n\n const {steps = numberOfSteps} = {};\n const options = {steps};\n const updatedFeature = circle(center, radius, options);\n const geometry = updatedFeature.geometry;\n\n const updatedData = new ImmutableFeatureCollection(props.data)\n .replaceGeometry(editHandleProperties.featureIndex, geometry)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'unionGeometry',\n editContext: {\n featureIndexes: [editHandleProperties.featureIndex]\n }\n });\n }\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n if (!this._isResizing) {\n const selectedEditHandle = getPickedEditHandle(event.picks);\n this._selectedEditHandle =\n selectedEditHandle && selectedEditHandle.properties.editHandleType === 'intermediate'\n ? selectedEditHandle\n : null;\n }\n\n const cursor = this.getCursor(event);\n props.onUpdateCursor(cursor);\n }\n\n handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._selectedEditHandle) {\n event.cancelPan();\n this._isResizing = true;\n }\n }\n\n handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {\n if (this._isResizing) {\n this._selectedEditHandle = null;\n this._isResizing = false;\n }\n }\n\n getCursor(event: PointerMoveEvent): string | null | undefined {\n const picks = (event && event.picks) || [];\n\n const handlesPicked = getPickedEditHandles(picks);\n if (handlesPicked.length) {\n return 'cell';\n }\n return null;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Position, LineString, FeatureCollection} from '../utils/geojson-types';\nimport {ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection} from './types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\nimport {ImmutableFeatureCollection} from './immutable-feature-collection';\n\nexport class ExtendLineStringMode extends GeoJsonEditMode {\n getSingleSelectedLineString(props: ModeProps<FeatureCollection>): LineString | null | undefined {\n const selectedGeometry = this.getSelectedGeometry(props);\n\n if (selectedGeometry && selectedGeometry.type === 'LineString') {\n return selectedGeometry;\n }\n return null;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {selectedIndexes} = props;\n const selectedLineString = this.getSingleSelectedLineString(props);\n\n if (!selectedLineString) {\n console.warn(`ExtendLineStringMode only supported for single LineString selection`); // eslint-disable-line\n return;\n }\n\n // Extend the LineString\n let positionIndexes = [selectedLineString.coordinates.length];\n\n const modeConfig = props.modeConfig;\n if (modeConfig && modeConfig.drawAtFront) {\n positionIndexes = [0];\n }\n const featureIndex = selectedIndexes[0];\n const updatedData = new ImmutableFeatureCollection(props.data)\n .addPosition(featureIndex, positionIndexes, event.mapCoords)\n .getObject();\n\n props.onEdit({\n updatedData,\n editType: 'addPosition',\n editContext: {\n featureIndexes: [featureIndex],\n positionIndexes,\n position: event.mapCoords\n }\n });\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n const selectedLineString = this.getSingleSelectedLineString(props);\n if (!selectedLineString) {\n return guides;\n }\n\n const mapCoords = props.lastPointerMoveEvent && props.lastPointerMoveEvent.mapCoords;\n\n if (!mapCoords) {\n return guides;\n }\n\n // Draw an extension line starting from one end of the selected LineString to the cursor\n let startPosition: Position | null | undefined = null;\n const {modeConfig} = props;\n if (modeConfig && modeConfig.drawAtFront) {\n startPosition = selectedLineString.coordinates[0];\n } else {\n startPosition = selectedLineString.coordinates[selectedLineString.coordinates.length - 1];\n }\n\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [startPosition, mapCoords]\n }\n });\n\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfDistance from '@turf/distance';\nimport turfMidpoint from '@turf/midpoint';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {\n ClickEvent,\n PointerMoveEvent,\n ModeProps,\n GuideFeatureCollection,\n Tooltip,\n GuideFeature\n} from './types';\nimport {getPickedEditHandle} from './utils';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nexport class MeasureDistanceMode extends GeoJsonEditMode {\n _isMeasuringSessionFinished = false;\n _currentTooltips: Tooltip[] = [];\n _currentDistance = 0;\n\n _calculateDistanceForTooltip = ({positionA, positionB, modeConfig}) => {\n const {turfOptions, measurementCallback} = modeConfig || {};\n const distance = turfDistance(positionA, positionB, turfOptions);\n\n if (measurementCallback) {\n measurementCallback(distance);\n }\n\n return distance;\n };\n\n _formatTooltip(distance, modeConfig?) {\n const {formatTooltip, turfOptions} = modeConfig || {};\n const units = (turfOptions && turfOptions.units) || 'kilometers';\n\n let text;\n if (formatTooltip) {\n text = formatTooltip(distance);\n } else {\n // By default, round to 2 decimal places and append units\n text = `${parseFloat(distance).toFixed(2)} ${units}`;\n }\n\n return text;\n }\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const {modeConfig, data, onEdit} = props;\n const {centerTooltipsOnLine = false} = modeConfig || {};\n\n // restart measuring session\n if (this._isMeasuringSessionFinished) {\n this._isMeasuringSessionFinished = false;\n this.resetClickSequence();\n this._currentTooltips = [];\n this._currentDistance = 0;\n }\n\n const {picks} = event;\n const clickedEditHandle = getPickedEditHandle(picks);\n\n let positionAdded = false;\n if (!clickedEditHandle) {\n // Don't add another point right next to an existing one\n this.addClickSequence(event);\n positionAdded = true;\n }\n const clickSequence = this.getClickSequence();\n\n if (\n clickSequence.length > 1 &&\n clickedEditHandle &&\n Array.isArray(clickedEditHandle.properties.positionIndexes) &&\n clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1\n ) {\n // They clicked the last point (or double-clicked), so add the LineString\n this._isMeasuringSessionFinished = true;\n } else if (positionAdded) {\n if (clickSequence.length > 1) {\n this._currentDistance += this._calculateDistanceForTooltip({\n positionA: clickSequence[clickSequence.length - 2],\n positionB: clickSequence[clickSequence.length - 1],\n modeConfig\n });\n\n const tooltipPosition = centerTooltipsOnLine\n ? turfMidpoint(\n clickSequence[clickSequence.length - 2],\n clickSequence[clickSequence.length - 1]\n ).geometry.coordinates\n : event.mapCoords;\n\n this._currentTooltips.push({\n position: tooltipPosition,\n text: this._formatTooltip(this._currentDistance, modeConfig)\n });\n }\n\n // new tentative point\n onEdit({\n // data is the same\n updatedData: data,\n editType: 'addTentativePosition',\n editContext: {\n position: event.mapCoords\n }\n });\n }\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {\n if (this._isMeasuringSessionFinished) return;\n\n event.stopPropagation();\n const {key} = event;\n\n const clickSequenceLength = this.getClickSequence().length;\n\n switch (key) {\n case 'Escape':\n this._isMeasuringSessionFinished = true;\n if (clickSequenceLength === 1) {\n this.resetClickSequence();\n this._currentTooltips = [];\n }\n // force update drawings\n props.onUpdateCursor('cell');\n break;\n case 'Enter':\n this.handleClick(props.lastPointerMoveEvent, props);\n this._isMeasuringSessionFinished = true;\n break;\n default:\n break;\n }\n }\n\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const {lastPointerMoveEvent} = props;\n const clickSequence = this.getClickSequence();\n\n const lastCoords =\n lastPointerMoveEvent && !this._isMeasuringSessionFinished\n ? [lastPointerMoveEvent.mapCoords]\n : [];\n\n const guides: GuideFeatureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (clickSequence.length > 0) {\n guides.features.push({\n type: 'Feature',\n properties: {\n guideType: 'tentative'\n },\n geometry: {\n type: 'LineString',\n coordinates: [...clickSequence, ...lastCoords]\n }\n });\n }\n\n const editHandles: GuideFeature[] = clickSequence.map((clickedCoord, index) => ({\n type: 'Feature',\n properties: {\n guideType: 'editHandle',\n editHandleType: 'existing',\n featureIndex: -1,\n positionIndexes: [index]\n },\n geometry: {\n type: 'Point',\n coordinates: clickedCoord\n }\n }));\n\n guides.features.push(...editHandles);\n\n return guides;\n }\n\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {\n props.onUpdateCursor('cell');\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n const {lastPointerMoveEvent, modeConfig} = props;\n const {centerTooltipsOnLine = false} = modeConfig || {};\n const positions = this.getClickSequence();\n\n if (positions.length > 0 && lastPointerMoveEvent && !this._isMeasuringSessionFinished) {\n const distance = this._calculateDistanceForTooltip({\n positionA: positions[positions.length - 1],\n positionB: lastPointerMoveEvent.mapCoords,\n modeConfig: props.modeConfig\n });\n\n const tooltipPosition = centerTooltipsOnLine\n ? turfMidpoint(positions[positions.length - 1], lastPointerMoveEvent.mapCoords).geometry\n .coordinates\n : lastPointerMoveEvent.mapCoords;\n\n return [\n ...this._currentTooltips,\n {\n position: tooltipPosition,\n text: this._formatTooltip(this._currentDistance + distance, modeConfig)\n }\n ];\n }\n\n return this._currentTooltips;\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport turfArea from '@turf/area';\nimport turfCentroid from '@turf/centroid';\nimport {ClickEvent, Tooltip, ModeProps} from './types';\nimport {FeatureCollection} from '../utils/geojson-types';\nimport {DrawPolygonMode} from './draw-polygon-mode';\n\nconst DEFAULT_TOOLTIPS = [];\n\nexport class MeasureAreaMode extends DrawPolygonMode {\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {\n const propsWithoutEdit = {\n ...props,\n onEdit: () => {}\n };\n\n super.handleClick(event, propsWithoutEdit);\n }\n\n handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>): void {\n const propsWithoutEdit = {\n ...props,\n onEdit: () => {}\n };\n\n super.handleKeyUp(event, propsWithoutEdit);\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n const tentativeGuide = this.getTentativeGuide(props);\n\n if (tentativeGuide && tentativeGuide.geometry.type === 'Polygon') {\n const {modeConfig} = props;\n const {formatTooltip, measurementCallback} = modeConfig || {};\n const units = 'sq. m';\n\n const centroid = turfCentroid(tentativeGuide);\n const area = turfArea(tentativeGuide);\n\n let text: string;\n if (formatTooltip) {\n text = formatTooltip(area);\n } else {\n // By default, round to 2 decimal places and append units\n // @ts-expect-error are isn't string\n text = `${parseFloat(area).toFixed(2)} ${units}`;\n }\n\n if (measurementCallback) {\n measurementCallback(area);\n }\n\n return [\n {\n position: centroid.geometry.coordinates,\n text\n }\n ];\n }\n return DEFAULT_TOOLTIPS;\n }\n}\n", "import turfBearing from '@turf/bearing';\nimport turfCenter from '@turf/center';\nimport {memoize} from '../utils/memoize';\n\nimport {ClickEvent, PointerMoveEvent, Tooltip, ModeProps, GuideFeatureCollection} from './types';\nimport {FeatureCollection, Position} from '../utils/geojson-types';\nimport {GeoJsonEditMode} from './geojson-edit-mode';\n\nconst DEFAULT_TOOLTIPS: Tooltip[] = [];\n\nexport class MeasureAngleMode extends GeoJsonEditMode {\n _getTooltips = memoize(\n ({\n modeConfig,\n vertex,\n point1,\n point2\n }: {\n modeConfig: any;\n vertex: any;\n point1: Position;\n point2: Position;\n }): Tooltip[] => {\n let tooltips = DEFAULT_TOOLTIPS;\n\n if (vertex && point1 && point2) {\n const {formatTooltip, measurementCallback} = modeConfig || {};\n const units = 'deg';\n\n const angle1 = turfBearing(vertex, point1);\n const angle2 = turfBearing(vertex, point2);\n let angle = Math.abs(angle1 - angle2);\n if (angle > 180) {\n angle = 360 - angle;\n }\n\n let text: string;\n if (formatTooltip) {\n text = formatTooltip(angle);\n } else {\n // By default, round to 2 decimal places and append units\n // @ts-expect-error angle isn't string\n text = `${parseFloat(angle).toFixed(2)} ${units}`;\n }\n\n if (measurementCallback) {\n measurementCallback(angle);\n }\n\n const position = turfCenter({\n type: 'FeatureCollection',\n features: [point1, point2].map((p) => ({\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: p\n },\n properties: {}\n }))\n }).geometry.coordinates;\n\n tooltips = [{position, text}];\n }\n\n return tooltips;\n }\n );\n\n handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {\n if (this.getClickSequence().length >= 3) {\n this.resetClickSequence();\n }\n\n this.addClickSequence(event);\n }\n\n // Called when the pointer moved, regardless of whether the pointer is down, up, and whether something was picked\n handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {\n props.onUpdateCursor('cell');\n }\n\n getPoints(props: ModeProps<FeatureCollection>): Position[] {\n const clickSequence = this.getClickSequence();\n\n const points = [...clickSequence];\n\n if (clickSequence.length < 3 && props.lastPointerMoveEvent) {\n points.push(props.lastPointerMoveEvent.mapCoords);\n }\n\n return points;\n }\n\n // Return features that can be used as a guide for editing the data\n getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {\n const guides: GuideFeatureCollection = {type: 'FeatureCollection', features: []};\n const {features} = guides;\n\n const points = this.getPoints(props);\n\n if (points.length > 2) {\n features.push({\n type: 'Feature',\n properties: {guideType: 'tentative'},\n geometry: {\n type: 'LineString',\n coordinates: [points[1], points[0], points[2]]\n }\n });\n } else if (points.length > 1) {\n features.push({\n type: 'Feature',\n properties: {guideType: 'tentative'},\n geometry: {\n type: 'LineString',\n coordinates: [points[1], points[0]]\n }\n });\n }\n\n return guides;\n }\n\n getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {\n const points = this.getPoints(props);\n\n return this._getTooltips({\n modeConfig: props.modeConfig,\n vertex: points[0],\n point1: points[1],\n point2: points[2]\n }) as Tooltip[];\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACKO,IAAM,cAAc;EACzB,MAAM;EACN,SAAS;EACT,UAAU;EACV,MAAM;;AAGD,IAAM,iBAAiB;AACvB,IAAM,aAAa;AAEnB,IAAM,gBAAgB;EAC3B,YAAY,CAAC,GAAG,GAAG,GAAG,CAAC;EACvB,YAAY;EACZ,YAAY,YAAY;EACxB,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC;EACtB,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC;EACtB,iBAAiB;EACjB,qBAAqB;EACrB,SAAS;EACT,QA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,SAAS,KAAK,MAAM,sBAAsB;AAC1D,aAAO,KAAK,MAAM,qBAAqB,SAAS;IAClD;AAEA,WAAO;EACT;;EAGA,UAAU,OAAmC;AAC3C,UAAM,SAAiC,EAAC,MAAM,qBAAqB,UAAU,CAAA,EAAE;AAC/E,UAAM,EAAC,SAAQ,IAAI;AAEnB,UAAM,SAAS,KAAK,UAAU,KAAK;AAEnC,QAAI,OAAO,SAAS,GAAG;AACrB,eAAS,KAAK;QACZ,MAAM;QACN,YAAY,EAAC,WAAW,YAAW;QACnC,UAAU;UACR,MAAM;UACN,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;;OAEhD;IACH,WAAW,OAAO,SAAS,GAAG;AAC5B,eAAS,KAAK;QACZ,MAAM;QACN,YAAY,EAAC,WAAW,YAAW;QACnC,UAAU;UACR,MAAM;UACN,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;;OAErC;IACH;AAEA,WAAO;EACT;EAEA,YAAY,OAAmC;AAC7C,UAAM,SAAS,KAAK,UAAU,KAAK;AAEnC,WAAO,KAAK,aAAa;MACvB,YAAY,MAAM;MAClB,QAAQ,OAAO,CAAC;MAChB,QAAQ,OAAO,CAAC;MAChB,QAAQ,OAAO,CAAC;KACjB;EACH;;",
6
+ "names": ["turfDistance", "turfBuffer", "turfBboxPolygon", "turfBbox", "turfDifference", "import_helpers", "mapCoords", "lineString", "pointToLineDistance", "bearing", "destination", "x", "y", "x2", "y2", "index", "x1", "y1", "distance", "import_layers", "import_layers", "import_core", "import_layers", "import_layers", "import_constants", "import_core", "import_core", "defaultProps", "point", "import_eventemitter3", "import_core", "import_layers", "import_difference", "import_destination", "import_bearing", "import_point_to_line_distance", "import_helpers", "import_viewport_mercator_project", "recursivelyTraverseNestedArrays", "generatePointsParallelToLinePoints", "lineString", "pointToLineDistance", "bearing", "destination", "distance2d", "mix", "nearestPointOnProjectedLine", "x", "y", "x2", "y2", "index", "x1", "y1", "distance", "featureCollection", "polygon", "lineString", "mapCoords", "rewind", "turfUnion", "turfDifference", "turfIntersect", "import_bearing", "import_distance", "import_helpers", "import_viewport_mercator_project", "distance", "turfCenter", "turfRhumbDestination", "turfRhumbDistance", "turfRhumbBearing", "turfDistance", "turfBearing", "clone", "import_helpers", "mapCoords", "recursivelyTraverseNestedArrays", "lineString", "toLineString", "nearestPointOnProjectedLine", "import_bbox", "import_bearing", "import_bbox_polygon", "import_helpers", "import_meta", "import_distance", "import_invariant", "turfTransformScale", "turfCentroid", "bearing", "turfBearing", "bboxPolygon", "bbox", "turfDistance", "import_bbox", "import_centroid", "import_bearing", "import_bbox_polygon", "import_distance", "import_meta", "import_invariant", "import_helpers", "import_polygon_to_line", "turfCentroid", "bboxPolygon", "bbox", "turfDistance", "turfTransformRotate", "turfBearing", "bearing2", "import_difference", "import_buffer", "import_helpers", "import_bearing", "import_distance", "import_destination", "import_polygon_to_line", "mapCoords", "turfPolygonToLine", "nearestPointOnLine", "turfDistance", "turfBearing", "turfDestination", "generatePointsParallelToLinePoints", "booleanPointInPolygon", "lineIntersect", "turfBuffer", "turfDifference", "import_bearing", "generatePointsParallelToLinePoints", "bearing", "mapCoords", "import_distance", "distance", "import_line_intersect", "import_helpers", "turfLineString", "lineIntersect", "import_bbox_polygon", "omit", "polygon", "bboxPolygon", "import_bbox_polygon", "import_distance", "import_helpers", "turfDistance", "distance2", "turfLineString", "turfAlong", "bboxPolygon", "import_bbox_polygon", "bboxPolygon", "import_bbox_polygon", "import_distance", "import_along", "import_helpers", "turfDistance", "distance2", "turfLineString", "turfAlong", "bboxPolygon", "import_distance", "distance", "circle", "area", "import_circle", "import_distance", "import_area", "distance", "circle", "area", "import_bbox_polygon", "import_distance", "import_helpers", "bboxPolygon", "distance", "ellipse", "import_lodash", "omit", "polygon", "generatePointsParallelToLinePoints", "import_distance", "import_ellipse", "import_bearing", "import_helpers", "distance", "bearing", "ellipse", "import_destination", "import_bearing", "import_line_intersect", "import_distance", "import_helpers", "mapCoords", "generatePointsParallelToLinePoints", "lineString", "polygon", "bearing", "distance", "turfDistance", "turfLineString", "destination", "lineIntersect", "import_lodash", "throttle", "import_helpers", "PROJECTED_PIXEL_SIZE_MULTIPLIER", "import_core", "mapCoords", "import_layers", "defaultProps", "PROJECTED_PIXEL_SIZE_MULTIPLIER", "defaultProps", "DEFAULT_EDIT_MODE", "defaultProps", "PROJECTED_PIXEL_SIZE_MULTIPLIER", "import_core", "import_layers", "import_helpers", "import_buffer", "import_difference", "SELECTION_TYPE", "defaultProps", "EXPANSION_KM", "turfBuffer", "turfDifference", "import_core", "import_layers", "defaultProps", "import_nearest_point_on_line", "import_helpers", "import_circle", "import_distance", "import_center", "mapCoords", "recursivelyTraverseNestedArrays", "lineString", "toLineString", "nearestPointOnProjectedLine", "nearestPointOnLine", "turfCenter", "distance", "circle", "mapCoords", "import_distance", "distance", "turfDistance", "turfMidpoint", "import_area", "import_centroid", "DEFAULT_TOOLTIPS", "turfCentroid", "area", "turfArea", "import_bearing", "import_center", "DEFAULT_TOOLTIPS", "point2", "turfBearing", "turfCenter"]
7
7
  }