@sakuzu/maplibre-gl-draw 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1016 -2
- package/README.ja.md +39 -19
- package/README.md +41 -21
- package/dist/api/datasets.d.ts +258 -0
- package/dist/api/document.d.ts +66 -0
- package/dist/api/draw.d.ts +135 -0
- package/dist/api/draw.js +18 -0
- package/dist/api/drawing.d.ts +87 -0
- package/dist/api/errors.d.ts +35 -0
- package/dist/api/errors.js +35 -0
- package/dist/api/events.d.ts +306 -0
- package/dist/api/extension/context.d.ts +247 -0
- package/dist/api/extension/feature-type.d.ts +129 -0
- package/dist/api/extension/mode.d.ts +123 -0
- package/dist/api/extension/plugin.d.ts +51 -0
- package/dist/api/extension/plugin.js +3 -0
- package/dist/api/extension/provider.d.ts +119 -0
- package/dist/api/extension/provider.js +3 -0
- package/dist/api/extension/render.d.ts +176 -0
- package/dist/api/extension/render.js +3 -0
- package/dist/api/extension/store.d.ts +190 -0
- package/dist/api/extension/store.js +3 -0
- package/dist/api/extensions.d.ts +306 -0
- package/dist/api/extensions.js +3 -0
- package/dist/api/features.d.ts +188 -0
- package/dist/api/features.js +3 -0
- package/dist/api/groups.d.ts +111 -0
- package/dist/api/groups.js +3 -0
- package/dist/api/hidden.d.ts +45 -0
- package/dist/api/hidden.js +3 -0
- package/dist/api/impl/adapters.js +463 -0
- package/dist/api/impl/contexts.js +466 -0
- package/dist/api/impl/create-draw.js +124 -0
- package/dist/api/impl/datasets.js +404 -0
- package/dist/api/impl/destroy-guard.js +74 -0
- package/dist/api/impl/document.js +280 -0
- package/dist/api/impl/drawing.js +180 -0
- package/dist/api/impl/engine-context.d.ts +7 -0
- package/dist/api/{context.js → impl/engine-context.js} +49 -38
- package/dist/{maplibre-gl-draw.js → api/impl/engine.js} +145 -177
- package/dist/api/impl/events.js +422 -0
- package/dist/api/impl/extension-host.js +361 -0
- package/dist/api/impl/extensions.js +229 -0
- package/dist/api/impl/features.js +445 -0
- package/dist/api/impl/geometry/apply.d.ts +32 -0
- package/dist/api/{geometry → impl/geometry}/apply.js +10 -27
- package/dist/api/{geometry → impl/geometry}/buffer.d.ts +4 -3
- package/dist/api/{geometry → impl/geometry}/buffer.js +12 -23
- package/dist/api/{geometry → impl/geometry}/split.d.ts +4 -3
- package/dist/api/{geometry → impl/geometry}/split.js +10 -21
- package/dist/api/{geometry → impl/geometry}/targets.d.ts +2 -20
- package/dist/api/{geometry → impl/geometry}/targets.js +8 -35
- package/dist/api/impl/geometry/types.js +3 -0
- package/dist/api/impl/groups.d.ts +3 -0
- package/dist/api/impl/groups.js +268 -0
- package/dist/api/impl/hidden.js +60 -0
- package/dist/api/impl/import-export/constants.d.ts +22 -0
- package/dist/api/impl/import-export/constants.js +24 -0
- package/dist/api/{import-export → impl/import-export}/embedded-file.js +2 -2
- package/dist/api/{import-export → impl/import-export}/format-detection.d.ts +1 -1
- package/dist/api/{import-export → impl/import-export}/format-detection.js +2 -1
- package/dist/api/impl/import-export/geojson-export.d.ts +19 -0
- package/dist/api/{import-export → impl/import-export}/geojson-export.js +71 -104
- package/dist/api/{import-export → impl/import-export}/geojson-import.d.ts +11 -7
- package/dist/api/{import-export → impl/import-export}/geojson-import.js +139 -97
- package/dist/api/{import-export → impl/import-export}/geometry-validation.d.ts +14 -0
- package/dist/api/{import-export → impl/import-export}/geometry-validation.js +45 -0
- package/dist/api/impl/import-export/image-import.d.ts +16 -0
- package/dist/api/impl/import-export/image-import.js +73 -0
- package/dist/api/impl/import-export/legacy-image-style.d.ts +16 -0
- package/dist/api/impl/import-export/legacy-image-style.js +49 -0
- package/dist/api/impl/import-export/native-format.d.ts +14 -0
- package/dist/api/{import-export → impl/import-export}/native-format.js +32 -22
- package/dist/api/impl/import-export/native-upgrade.d.ts +8 -0
- package/dist/api/impl/import-export/native-upgrade.js +139 -0
- package/dist/api/{import-export → impl/import-export}/native-validation.d.ts +1 -1
- package/dist/api/{import-export → impl/import-export}/native-validation.js +15 -14
- package/dist/api/impl/import-export/style-validation.d.ts +24 -0
- package/dist/api/impl/import-export/style-validation.js +86 -0
- package/dist/api/impl/import-export/types.d.ts +52 -0
- package/dist/api/impl/import-export/types.js +3 -0
- package/dist/api/impl/input.js +180 -0
- package/dist/api/impl/layers.js +307 -0
- package/dist/api/impl/metadata.d.ts +1 -0
- package/dist/api/impl/metadata.js +22 -0
- package/dist/api/impl/options.d.ts +1 -0
- package/dist/api/impl/options.js +822 -0
- package/dist/api/impl/placement.d.ts +1 -0
- package/dist/api/impl/placement.js +138 -0
- package/dist/api/impl/render-context.d.ts +13 -0
- package/dist/api/impl/render-context.js +272 -0
- package/dist/api/impl/rows.d.ts +1 -0
- package/dist/api/impl/rows.js +46 -0
- package/dist/api/impl/selection.d.ts +1 -0
- package/dist/api/impl/selection.js +186 -0
- package/dist/api/impl/shared.d.ts +64 -0
- package/dist/api/impl/shared.js +178 -0
- package/dist/api/impl/validate-extension.d.ts +1 -0
- package/dist/api/impl/validate-extension.js +159 -0
- package/dist/api/layers.d.ts +130 -0
- package/dist/api/layers.js +3 -0
- package/dist/api/metadata.d.ts +18 -0
- package/dist/api/metadata.js +3 -0
- package/dist/api/model.d.ts +487 -0
- package/dist/api/model.js +47 -0
- package/dist/api/options.d.ts +466 -0
- package/dist/api/options.js +3 -0
- package/dist/api/selection.d.ts +94 -0
- package/dist/api/selection.js +3 -0
- package/dist/api/state.d.ts +155 -0
- package/dist/api/state.js +12 -0
- package/dist/{display → dataset}/chunk.d.ts +1 -1
- package/dist/{display → dataset}/chunk.js +4 -3
- package/dist/{display → dataset}/dataset.js +18 -21
- package/dist/dataset/interaction.d.ts +1 -0
- package/dist/{display → dataset}/interaction.js +18 -6
- package/dist/dataset/manager.d.ts +1 -0
- package/dist/dataset/provider.d.ts +1 -0
- package/dist/{display → dataset}/retained.d.ts +1 -1
- package/dist/{display → dataset}/retained.js +8 -7
- package/dist/dataset/source.d.ts +1 -0
- package/dist/{display → dataset}/source.js +17 -4
- package/dist/dataset/spatial.d.ts +1 -0
- package/dist/{display → dataset}/spatial.js +1 -1
- package/dist/dataset/style.d.ts +1 -0
- package/dist/{display → dataset}/style.js +1 -1
- package/dist/dataset/table-source.d.ts +1 -0
- package/dist/{display/columnar/source.js → dataset/table-source.js} +53 -25
- package/dist/{display → dataset}/thinning.d.ts +0 -10
- package/dist/{display → dataset}/thinning.js +3 -2
- package/dist/dataset/triangulation.d.ts +1 -0
- package/dist/{display → dataset}/triangulation.js +0 -0
- package/dist/{display → dataset}/types.d.ts +82 -121
- package/dist/dataset/types.js +61 -0
- package/dist/dispatcher/hit-test/box-strategies.js +13 -13
- package/dist/dispatcher/hit-test/box-strategy.d.ts +2 -15
- package/dist/dispatcher/hit-test/globe-shape.js +5 -4
- package/dist/dispatcher/hit-test/service.d.ts +17 -0
- package/dist/dispatcher/hit-test/service.js +80 -16
- package/dist/dispatcher/hit-test/strategies/base.d.ts +13 -19
- package/dist/dispatcher/hit-test/strategies/circle.js +3 -2
- package/dist/dispatcher/hit-test/strategies/image.js +6 -18
- package/dist/dispatcher/hit-test/strategies/line.d.ts +0 -6
- package/dist/dispatcher/hit-test/strategies/line.js +9 -2
- package/dist/dispatcher/hit-test/strategies/multi.d.ts +0 -8
- package/dist/dispatcher/hit-test/strategies/multi.js +17 -8
- package/dist/dispatcher/hit-test/strategies/point.d.ts +9 -7
- package/dist/dispatcher/hit-test/strategies/point.js +8 -4
- package/dist/dispatcher/hit-test/strategies/polygon.d.ts +0 -7
- package/dist/dispatcher/hit-test/strategies/polygon.js +11 -3
- package/dist/dispatcher/hit-test/topmost.d.ts +1 -1
- package/dist/dispatcher/input-router.js +152 -69
- package/dist/dispatcher/normalizer.js +6 -2
- package/dist/dispatcher/types.d.ts +6 -1
- package/dist/extension/feature-handler.d.ts +1 -182
- package/dist/extension/index.d.ts +4 -7
- package/dist/extension/renderers.d.ts +1 -208
- package/dist/geometry/angle.d.ts +0 -8
- package/dist/geometry/angle.js +0 -8
- package/dist/geometry/bbox.d.ts +4 -12
- package/dist/geometry/bbox.js +4 -12
- package/dist/geometry/boolean.d.ts +0 -51
- package/dist/geometry/boolean.js +0 -51
- package/dist/geometry/buffer.d.ts +0 -26
- package/dist/geometry/buffer.js +0 -26
- package/dist/geometry/circle.d.ts +0 -9
- package/dist/geometry/circle.js +0 -9
- package/dist/geometry/coords.d.ts +0 -16
- package/dist/geometry/coords.js +0 -16
- package/dist/geometry/distance.d.ts +0 -24
- package/dist/geometry/distance.js +0 -24
- package/dist/geometry/errors.d.ts +21 -36
- package/dist/geometry/errors.js +49 -29
- package/dist/geometry/geojson.d.ts +81 -0
- package/dist/geometry/geojson.js +164 -0
- package/dist/geometry/index.d.ts +38 -23
- package/dist/geometry/index.js +43 -31
- package/dist/geometry/measure.d.ts +0 -27
- package/dist/geometry/measure.js +0 -27
- package/dist/geometry/predicates.d.ts +0 -9
- package/dist/geometry/predicates.js +0 -9
- package/dist/geometry/public-bounds.d.ts +26 -0
- package/dist/geometry/public-bounds.js +30 -0
- package/dist/geometry/public-combine.d.ts +78 -0
- package/dist/geometry/public-combine.js +82 -0
- package/dist/geometry/public-create.d.ts +54 -0
- package/dist/geometry/public-create.js +70 -0
- package/dist/geometry/public-measure.d.ts +170 -0
- package/dist/geometry/public-measure.js +283 -0
- package/dist/geometry/public-predicates.d.ts +54 -0
- package/dist/geometry/public-predicates.js +144 -0
- package/dist/geometry/public-repair.d.ts +75 -0
- package/dist/geometry/public-repair.js +77 -0
- package/dist/geometry/simplify.d.ts +0 -7
- package/dist/geometry/simplify.js +0 -7
- package/dist/geometry/split.d.ts +0 -20
- package/dist/geometry/split.js +0 -20
- package/dist/geometry/units.d.ts +20 -12
- package/dist/geometry/units.js +20 -12
- package/dist/index.d.ts +52 -66
- package/dist/index.js +6 -18
- package/dist/messages.d.ts +7 -7
- package/dist/modes/draw/circle.js +83 -207
- package/dist/modes/draw/commit-layer.d.ts +5 -16
- package/dist/modes/draw/commit-layer.js +2 -13
- package/dist/modes/draw/freehand.js +108 -246
- package/dist/modes/draw/image.js +4 -2
- package/dist/modes/draw/index.d.ts +5 -5
- package/dist/modes/draw/index.js +5 -5
- package/dist/modes/draw/line.js +18 -354
- package/dist/modes/draw/point.js +29 -78
- package/dist/modes/draw/polygon.js +23 -368
- package/dist/modes/draw/trace-support.d.ts +43 -36
- package/dist/modes/draw/trace-support.js +95 -98
- package/dist/modes/draw/vertex-drawing.d.ts +1 -0
- package/dist/modes/draw/vertex-drawing.js +176 -0
- package/dist/modes/handler.d.ts +1 -285
- package/dist/modes/manager.d.ts +2 -2
- package/dist/modes/manager.js +3 -0
- package/dist/modes/select/box-selection.d.ts +3 -3
- package/dist/modes/select/box-selection.js +2 -1
- package/dist/modes/select/click-handler.d.ts +5 -5
- package/dist/modes/select/click-handler.js +22 -20
- package/dist/modes/select/cursor-handler.d.ts +2 -2
- package/dist/modes/select/drag/intermediate-writes.js +1 -1
- package/dist/modes/select/drag/move.js +3 -3
- package/dist/modes/select/drag/operation.d.ts +3 -3
- package/dist/modes/select/drag/radius.js +5 -4
- package/dist/modes/select/drag/transform.d.ts +2 -2
- package/dist/modes/select/drag/transform.js +11 -5
- package/dist/modes/select/drag/vertex.d.ts +2 -2
- package/dist/modes/select/drag/vertex.js +13 -8
- package/dist/modes/select/drag-handler.js +44 -25
- package/dist/modes/select/mode.js +17 -17
- package/dist/modes/select/shortcut-handler.d.ts +8 -8
- package/dist/modes/select/shortcut-handler.js +9 -7
- package/dist/operations/layer-operations.js +29 -168
- package/dist/operations/resize.d.ts +2 -2
- package/dist/operations/resize.js +5 -5
- package/dist/operations/rotate.js +5 -5
- package/dist/operations/selection-operations.d.ts +16 -1
- package/dist/operations/selection-operations.js +28 -13
- package/dist/operations/shared-vertex.js +4 -2
- package/dist/operations/trace-graph.d.ts +0 -18
- package/dist/operations/trace-graph.js +0 -18
- package/dist/operations/vertex.js +36 -35
- package/dist/shared/color.d.ts +1 -0
- package/dist/shared/color.js +245 -0
- package/dist/shared/config/constants.d.ts +1 -54
- package/dist/shared/config/constants.js +1 -58
- package/dist/shared/config/feature-style.d.ts +16 -13
- package/dist/shared/config/feature-style.js +9 -0
- package/dist/shared/config/rendering.d.ts +3 -3
- package/dist/shared/config/selection-highlight.d.ts +0 -15
- package/dist/shared/config/selection-highlight.js +4 -7
- package/dist/shared/config/selection.d.ts +2 -32
- package/dist/shared/config/selection.js +0 -18
- package/dist/shared/config/topology.d.ts +2 -2
- package/dist/shared/config/trace.d.ts +4 -4
- package/dist/shared/math/angle.d.ts +1 -1
- package/dist/shared/math/angle.js +1 -1
- package/dist/shared/math/circle.d.ts +1 -1
- package/dist/shared/math/circle.js +1 -1
- package/dist/shared/math/distance.d.ts +2 -1
- package/dist/shared/math/distance.js +3 -2
- package/dist/shared/math/index.d.ts +1 -1
- package/dist/shared/math/index.js +1 -1
- package/dist/shared/math/transform.d.ts +23 -0
- package/dist/shared/math/transform.js +47 -28
- package/dist/shared/properties.d.ts +18 -0
- package/dist/shared/properties.js +129 -0
- package/dist/shared/types/events.d.ts +15 -7
- package/dist/shared/types/model.d.ts +109 -159
- package/dist/shared/types/style.d.ts +1 -1
- package/dist/shared/utils/color.d.ts +2 -36
- package/dist/shared/utils/color.js +13 -70
- package/dist/shared/utils/coordinates.d.ts +30 -4
- package/dist/shared/utils/coordinates.js +56 -10
- package/dist/shared/utils/event-emitter.d.ts +1 -262
- package/dist/shared/utils/event-emitter.js +4 -3
- package/dist/shared/utils/feature-bbox.js +8 -7
- package/dist/shared/utils/feature-segments.js +5 -4
- package/dist/shared/utils/image.d.ts +0 -4
- package/dist/shared/utils/image.js +0 -6
- package/dist/shared/utils/name-generator.d.ts +14 -20
- package/dist/shared/utils/name-generator.js +20 -3
- package/dist/shared/utils/pixel-ratio.d.ts +9 -3
- package/dist/shared/utils/pixel-ratio.js +13 -4
- package/dist/shared/utils/property.d.ts +7 -50
- package/dist/shared/utils/property.js +22 -87
- package/dist/snapping/custom-targets.js +21 -4
- package/dist/snapping/indicator.js +20 -11
- package/dist/snapping/providers/display.d.ts +6 -1
- package/dist/snapping/providers/display.js +2 -1
- package/dist/snapping/providers/guide.d.ts +3 -43
- package/dist/snapping/providers/guide.js +1 -44
- package/dist/snapping/providers/intersection.js +1 -1
- package/dist/snapping/providers/store.js +3 -3
- package/dist/snapping/service.js +18 -7
- package/dist/snapping/types.d.ts +9 -35
- package/dist/store/draw-store.js +233 -142
- package/dist/store/local-visibility.d.ts +11 -6
- package/dist/store/local-visibility.js +38 -7
- package/dist/store/lock.d.ts +0 -6
- package/dist/store/lock.js +0 -6
- package/dist/store/memory/change-bus.d.ts +3 -3
- package/dist/store/memory/change-bus.js +12 -0
- package/dist/store/memory/file-store.d.ts +2 -2
- package/dist/store/memory/ui-state.d.ts +1 -51
- package/dist/store/memory/ui-state.js +122 -134
- package/dist/store/memory.d.ts +1 -8
- package/dist/store/memory.js +249 -45
- package/dist/store/ordering.d.ts +9 -0
- package/dist/store/ordering.js +17 -0
- package/dist/store/spatial/spatial-index.d.ts +1 -1
- package/dist/store/spatial/spatial-index.js +1 -1
- package/dist/store/spatial/store-spatial-index.d.ts +3 -1
- package/dist/store/spatial/store-spatial-index.js +9 -3
- package/dist/store/store.d.ts +66 -107
- package/dist/store/types.d.ts +1 -1
- package/dist/store/writable-layer.d.ts +1 -1
- package/dist/store/writable-layer.js +2 -2
- package/dist/table/builder.d.ts +83 -0
- package/dist/table/builder.js +381 -0
- package/dist/table/index.d.ts +37 -0
- package/dist/table/index.js +5 -0
- package/dist/table/packed-rtree.d.ts +1 -0
- package/dist/{display → table}/packed-rtree.js +1 -1
- package/dist/table/partition.d.ts +1 -0
- package/dist/{display → table}/partition.js +3 -3
- package/dist/table/prepare.d.ts +44 -0
- package/dist/table/prepare.js +136 -0
- package/dist/table/table.d.ts +1 -0
- package/dist/{display/columnar → table}/table.js +29 -25
- package/dist/{display/columnar → table}/types.d.ts +68 -72
- package/dist/table/types.js +3 -0
- package/dist/view/coordinator.js +4 -3
- package/dist/view/feature-companion.d.ts +13 -7
- package/dist/view/feature-companion.js +11 -3
- package/dist/view/globe-subdivision.js +3 -3
- package/dist/view/layer/attach.d.ts +1 -1
- package/dist/view/layer/attach.js +1 -1
- package/dist/view/layer/custom-layer.js +40 -11
- package/dist/view/layer/display-list.js +2 -1
- package/dist/view/layer/drape-planner.d.ts +2 -2
- package/dist/view/layer/frame-render.d.ts +3 -3
- package/dist/view/layer/frame-render.js +7 -2
- package/dist/view/layer/frame-state.d.ts +6 -6
- package/dist/view/layer/index.d.ts +2 -2
- package/dist/view/layer/index.js +1 -1
- package/dist/view/layer/render.d.ts +4 -4
- package/dist/view/layer/render.js +3 -8
- package/dist/view/layer/renderers.d.ts +2 -2
- package/dist/view/layer/renderers.js +1 -1
- package/dist/view/layer/slot-manager.d.ts +2 -2
- package/dist/view/layer/slot-manager.js +4 -4
- package/dist/view/layer/slots.d.ts +2 -2
- package/dist/view/layer/slots.js +1 -1
- package/dist/view/layer/store-retained-bbox.js +3 -2
- package/dist/view/layer/store-retained-classify.d.ts +5 -7
- package/dist/view/layer/store-retained-classify.js +19 -7
- package/dist/view/layer/store-retained-collect.js +8 -7
- package/dist/view/layer/store-retained-coord-patch.d.ts +0 -8
- package/dist/view/layer/store-retained-coord-patch.js +13 -4
- package/dist/view/layer/store-retained-immediate.d.ts +3 -3
- package/dist/view/layer/store-retained-immediate.js +3 -8
- package/dist/view/layer/store-retained-invalidation.d.ts +2 -2
- package/dist/view/layer/store-retained.d.ts +2 -2
- package/dist/view/layer/store-retained.js +1 -1
- package/dist/view/renderers/batch-manager.js +8 -7
- package/dist/view/renderers/drawer.js +21 -15
- package/dist/view/renderers/image.js +13 -39
- package/dist/view/renderers/line/line-types.d.ts +3 -3
- package/dist/view/renderers/line/sdf-line.js +3 -1
- package/dist/view/renderers/point/billboard-depth.js +1 -1
- package/dist/view/renderers/point/point-instance.js +1 -1
- package/dist/view/renderers/point/point-shape.js +2 -2
- package/dist/view/renderers/point/point-style.js +48 -4
- package/dist/view/renderers/polygon/batch.js +1 -2
- package/dist/view/renderers/polygon/fill.js +3 -1
- package/dist/view/renderers/polygon/sdf-polygon.js +2 -3
- package/dist/view/renderers/polygon/triangulator.d.ts +1 -1
- package/dist/view/renderers/stroke.js +3 -1
- package/dist/view/shaders/helpers.d.ts +2 -42
- package/dist/view/shaders/helpers.js +0 -6
- package/dist/view/shaders/projection.d.ts +15 -7
- package/dist/view/shaders/projection.js +23 -6
- package/dist/view/shaders/quad.d.ts +16 -12
- package/dist/view/shaders/quad.js +34 -13
- package/dist/view/style-rule.d.ts +5 -42
- package/dist/view/style-rule.js +20 -44
- package/dist/view/terrain/binding.d.ts +1 -0
- package/dist/view/terrain/binding.js +29 -0
- package/dist/view/terrain/context.d.ts +3 -4
- package/dist/view/terrain/context.js +4 -5
- package/dist/view/terrain/drape/geometry.js +1 -1
- package/dist/view/terrain/drape/pass.d.ts +1 -1
- package/dist/view/terrain/drape/pass.js +8 -7
- package/dist/view/terrain/polygon.d.ts +9 -5
- package/dist/view/terrain/polygon.js +16 -2
- package/dist/view/terrain/state.d.ts +1 -1
- package/dist/view/terrain/state.js +1 -1
- package/dist/view/terrain/tessellation.d.ts +2 -2
- package/dist/view/terrain/tessellation.js +1 -1
- package/dist/view/ui/auxiliary-handles.d.ts +6 -29
- package/dist/view/ui/bounds.js +8 -12
- package/dist/view/ui/handle-test.js +2 -2
- package/dist/view/ui/handle-thinning.js +17 -17
- package/dist/view/ui/handles.js +21 -13
- package/dist/view/ui/helper.d.ts +1 -1
- package/dist/view/ui/helper.js +1 -1
- package/dist/view/ui/index.d.ts +1 -1
- package/dist/view/ui/selection-scope.js +4 -2
- package/dist/view/ui/selection-ui/bounding-box.js +6 -6
- package/dist/view/ui/selection-ui/extension-registry.d.ts +31 -20
- package/dist/view/ui/selection-ui/extension-registry.js +70 -7
- package/dist/view/ui/selection-ui/index.d.ts +2 -2
- package/dist/view/ui/selection-ui/index.js +1 -1
- package/dist/view/ui/selection-ui/renderer.js +15 -38
- package/dist/view/ui/selection-ui/types.d.ts +17 -2
- package/dist/view/ui/selection-ui-drawer.d.ts +8 -0
- package/dist/view/ui/selection-ui-drawer.js +63 -2
- package/dist/view/ui/tentative.js +1 -1
- package/dist/webgl/index.d.ts +65 -0
- package/dist/webgl/index.js +62 -0
- package/package.json +20 -9
- package/dist/api/api.d.ts +0 -1259
- package/dist/api/api.js +0 -86
- package/dist/api/context.d.ts +0 -173
- package/dist/api/display-api.js +0 -23
- package/dist/api/event-api.d.ts +0 -13
- package/dist/api/event-api.js +0 -17
- package/dist/api/extension-api.d.ts +0 -46
- package/dist/api/extension-api.js +0 -85
- package/dist/api/feature-api.d.ts +0 -11
- package/dist/api/feature-api.js +0 -101
- package/dist/api/geometry/apply.d.ts +0 -51
- package/dist/api/geometry/boolean.d.ts +0 -28
- package/dist/api/geometry/boolean.js +0 -65
- package/dist/api/geometry/types.d.ts +0 -31
- package/dist/api/geometry-operations.d.ts +0 -162
- package/dist/api/geometry-operations.js +0 -94
- package/dist/api/group-api.d.ts +0 -10
- package/dist/api/group-api.js +0 -78
- package/dist/api/import-export/constants.d.ts +0 -29
- package/dist/api/import-export/constants.js +0 -40
- package/dist/api/import-export/file-name.d.ts +0 -10
- package/dist/api/import-export/file-name.js +0 -20
- package/dist/api/import-export/geojson-export.d.ts +0 -19
- package/dist/api/import-export/image-import.d.ts +0 -12
- package/dist/api/import-export/image-import.js +0 -53
- package/dist/api/import-export/index.d.ts +0 -9
- package/dist/api/import-export/index.js +0 -107
- package/dist/api/import-export/native-format.d.ts +0 -15
- package/dist/api/import-export/style-validation.d.ts +0 -27
- package/dist/api/import-export/style-validation.js +0 -49
- package/dist/api/import-export/types.d.ts +0 -26
- package/dist/api/index.d.ts +0 -15
- package/dist/api/index.js +0 -3
- package/dist/api/input-api.d.ts +0 -158
- package/dist/api/input-api.js +0 -144
- package/dist/api/instance-api.d.ts +0 -38
- package/dist/api/instance-api.js +0 -136
- package/dist/api/layer-api.d.ts +0 -12
- package/dist/api/layer-api.js +0 -62
- package/dist/api/selection-api.d.ts +0 -7
- package/dist/api/selection-api.js +0 -78
- package/dist/api/snapping-api.d.ts +0 -125
- package/dist/api/snapping-api.js +0 -50
- package/dist/api/topology-api.d.ts +0 -30
- package/dist/api/topology-api.js +0 -16
- package/dist/api/tracing-api.d.ts +0 -31
- package/dist/api/tracing-api.js +0 -16
- package/dist/dispatcher/hit-test/index.d.ts +0 -14
- package/dist/dispatcher/hit-test/index.js +0 -9
- package/dist/dispatcher/index.d.ts +0 -15
- package/dist/dispatcher/index.js +0 -3
- package/dist/display/columnar/index.d.ts +0 -12
- package/dist/display/columnar/index.js +0 -13
- package/dist/display/columnar/prepare.d.ts +0 -42
- package/dist/display/columnar/prepare.js +0 -116
- package/dist/display/index.d.ts +0 -13
- package/dist/display/types.js +0 -43
- package/dist/maplibre-gl-draw.d.ts +0 -47
- package/dist/modes/cursor.js +0 -72
- package/dist/modes/index.d.ts +0 -7
- package/dist/operations/index.d.ts +0 -9
- package/dist/operations/index.js +0 -3
- package/dist/plugins/index.d.ts +0 -10
- package/dist/plugins/mutation-hooks.d.ts +0 -28
- package/dist/plugins/mutation-hooks.js +0 -84
- package/dist/plugins/plugin-context.js +0 -367
- package/dist/plugins/plugin-manager.d.ts +0 -103
- package/dist/plugins/plugin-manager.js +0 -316
- package/dist/plugins/plugin.d.ts +0 -529
- package/dist/shared/config/index.d.ts +0 -17
- package/dist/shared/config/index.js +0 -8
- package/dist/shared/utils/index.d.ts +0 -15
- package/dist/shared/utils/index.js +0 -24
- package/dist/snapping/index.d.ts +0 -14
- package/dist/snapping/index.js +0 -4
- package/dist/store/change-merger.js +0 -102
- package/dist/store/event-bridge.js +0 -161
- package/dist/store/index.d.ts +0 -12
- package/dist/store/index.js +0 -4
- package/dist/view/index.d.ts +0 -47
- package/dist/view/index.js +0 -20
- /package/dist/api/{geometry/types.js → datasets.js} +0 -0
- /package/dist/api/{import-export/types.js → document.js} +0 -0
- /package/dist/{display/columnar/types.js → api/drawing.js} +0 -0
- /package/dist/{display/index.js → api/events.js} +0 -0
- /package/dist/{modes/index.js → api/extension/context.js} +0 -0
- /package/dist/{plugins/index.js → api/extension/feature-type.js} +0 -0
- /package/dist/{plugins/plugin.js → api/extension/mode.js} +0 -0
- /package/dist/api/{display-api.d.ts → impl/adapters.d.ts} +0 -0
- /package/dist/{display/columnar/source.d.ts → api/impl/contexts.d.ts} +0 -0
- /package/dist/{display/columnar/table.d.ts → api/impl/create-draw.d.ts} +0 -0
- /package/dist/{display/interaction.d.ts → api/impl/datasets.d.ts} +0 -0
- /package/dist/{display/manager.d.ts → api/impl/destroy-guard.d.ts} +0 -0
- /package/dist/{display/packed-rtree.d.ts → api/impl/document.d.ts} +0 -0
- /package/dist/{display/partition.d.ts → api/impl/drawing.d.ts} +0 -0
- /package/dist/{display/provider.d.ts → api/impl/engine.d.ts} +0 -0
- /package/dist/{display/source.d.ts → api/impl/events.d.ts} +0 -0
- /package/dist/{display/spatial.d.ts → api/impl/extension-host.d.ts} +0 -0
- /package/dist/{display/style.d.ts → api/impl/extensions.d.ts} +0 -0
- /package/dist/{display/triangulation.d.ts → api/impl/features.d.ts} +0 -0
- /package/dist/{modes/cursor.d.ts → api/impl/geometry/types.d.ts} +0 -0
- /package/dist/{plugins/plugin-context.d.ts → api/impl/hidden.d.ts} +0 -0
- /package/dist/api/{import-export → impl/import-export}/embedded-file.d.ts +0 -0
- /package/dist/api/{import-export → impl/import-export}/own-property.d.ts +0 -0
- /package/dist/api/{import-export → impl/import-export}/own-property.js +0 -0
- /package/dist/{store/change-merger.d.ts → api/impl/input.d.ts} +0 -0
- /package/dist/{store/event-bridge.d.ts → api/impl/layers.d.ts} +0 -0
- /package/dist/{display → dataset}/chunk-set.d.ts +0 -0
- /package/dist/{display → dataset}/chunk-set.js +0 -0
- /package/dist/{display → dataset}/dataset.d.ts +0 -0
- /package/dist/{display → dataset}/manager.js +0 -0
- /package/dist/{display → dataset}/provider.js +0 -0
- /package/dist/{display → dataset}/selection.d.ts +0 -0
- /package/dist/{display → dataset}/selection.js +0 -0
|
@@ -10,147 +10,12 @@ function deleteGroupIfEmpty(store, groupId) {
|
|
|
10
10
|
store.deleteGroup(groupId);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Moves a feature or a group to another layer
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export function moveToLayer(store, itemId, targetLayerId) {
|
|
19
|
-
const feature = store.getFeature(itemId);
|
|
20
|
-
const group = store.getGroup(itemId);
|
|
21
|
-
if (feature) {
|
|
22
|
-
moveFeatureToLayer(store, feature, itemId, targetLayerId);
|
|
23
|
-
}
|
|
24
|
-
else if (group) {
|
|
25
|
-
moveGroupToLayer(store, group, itemId, targetLayerId);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function moveFeatureToLayer(store, feature, itemId, targetLayerId) {
|
|
29
|
-
const targetLayer = store.getLayer(targetLayerId);
|
|
30
|
-
if (!targetLayer)
|
|
31
|
-
return;
|
|
32
|
-
// Do nothing when it is already in the same layer
|
|
33
|
-
if (feature.layerId === targetLayerId && !feature.groupId)
|
|
34
|
-
return;
|
|
35
|
-
const previousGroupId = feature.groupId;
|
|
36
|
-
store.transact(() => {
|
|
37
|
-
// When it belongs to a group, remove it from the group
|
|
38
|
-
if (feature.groupId) {
|
|
39
|
-
const currentGroup = store.getGroup(feature.groupId);
|
|
40
|
-
if (currentGroup) {
|
|
41
|
-
store.updateGroup(feature.groupId, {
|
|
42
|
-
featureIds: currentGroup.featureIds.filter((id) => id !== itemId),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// When it is a standalone feature, remove it from the original layer
|
|
48
|
-
const sourceLayer = store.getLayer(feature.layerId);
|
|
49
|
-
if (sourceLayer) {
|
|
50
|
-
const sourceOrder = sourceLayer.order.filter((id) => id !== itemId);
|
|
51
|
-
store.updateLayer(sourceLayer.id, { order: sourceOrder });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// Add it to the new layer
|
|
55
|
-
store.updateLayer(targetLayerId, { order: [...targetLayer.order, itemId] });
|
|
56
|
-
// Update the layerId of the feature and clear its groupId
|
|
57
|
-
store.updateFeature(itemId, { layerId: targetLayerId, groupId: undefined });
|
|
58
|
-
// Delete the source group when it has become empty
|
|
59
|
-
if (previousGroupId) {
|
|
60
|
-
deleteGroupIfEmpty(store, previousGroupId);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function moveGroupToLayer(store, group, itemId, targetLayerId) {
|
|
65
|
-
// Find the layer the group belongs to
|
|
66
|
-
let sourceLayerId = null;
|
|
67
|
-
for (const layer of store.getAllLayers()) {
|
|
68
|
-
if (layer.order.includes(itemId)) {
|
|
69
|
-
sourceLayerId = layer.id;
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (sourceLayerId && sourceLayerId !== targetLayerId) {
|
|
74
|
-
const sourceLayer = store.getLayer(sourceLayerId);
|
|
75
|
-
const targetLayer = store.getLayer(targetLayerId);
|
|
76
|
-
if (sourceLayer && targetLayer) {
|
|
77
|
-
store.transact(() => {
|
|
78
|
-
// Remove it from the original layer
|
|
79
|
-
const sourceOrder = sourceLayer.order.filter((id) => id !== itemId);
|
|
80
|
-
store.updateLayer(sourceLayerId, { order: sourceOrder });
|
|
81
|
-
// Add it to the new layer
|
|
82
|
-
store.updateLayer(targetLayerId, { order: [...targetLayer.order, itemId] });
|
|
83
|
-
// Update the layerId of the features inside the group
|
|
84
|
-
for (const featureId of group.featureIds) {
|
|
85
|
-
store.updateFeature(featureId, { layerId: targetLayerId });
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Adds a feature to a group
|
|
93
|
-
*
|
|
94
|
-
* @internal
|
|
95
|
-
*/
|
|
96
|
-
export function addFeatureToGroup(store, featureId, groupId, index) {
|
|
97
|
-
const feature = store.getFeature(featureId);
|
|
98
|
-
const group = store.getGroup(groupId);
|
|
99
|
-
if (!feature || !group)
|
|
100
|
-
return;
|
|
101
|
-
// Do nothing when it is already included in this group
|
|
102
|
-
if (group.featureIds.includes(featureId))
|
|
103
|
-
return;
|
|
104
|
-
// Find the layer the group belongs to
|
|
105
|
-
let targetLayerId = null;
|
|
106
|
-
for (const layer of store.getAllLayers()) {
|
|
107
|
-
if (layer.order.includes(groupId)) {
|
|
108
|
-
targetLayerId = layer.id;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
store.transact(() => {
|
|
113
|
-
// When the feature already belongs to another group, remove it from that group
|
|
114
|
-
if (feature.groupId && feature.groupId !== groupId) {
|
|
115
|
-
const oldGroupId = feature.groupId;
|
|
116
|
-
const oldGroup = store.getGroup(oldGroupId);
|
|
117
|
-
if (oldGroup) {
|
|
118
|
-
store.updateGroup(oldGroupId, {
|
|
119
|
-
featureIds: oldGroup.featureIds.filter((id) => id !== featureId),
|
|
120
|
-
});
|
|
121
|
-
// Delete the source group when it has become empty
|
|
122
|
-
deleteGroupIfEmpty(store, oldGroupId);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Remove the feature from the order of the layer (when it is included in order on its own)
|
|
126
|
-
const layer = store.getLayer(feature.layerId);
|
|
127
|
-
if (layer?.order.includes(featureId)) {
|
|
128
|
-
const newOrder = layer.order.filter((id) => id !== featureId);
|
|
129
|
-
store.updateLayer(layer.id, { order: newOrder });
|
|
130
|
-
}
|
|
131
|
-
// Add the feature to the group (when an index is given, insert it at that position)
|
|
132
|
-
const newFeatureIds = [...group.featureIds];
|
|
133
|
-
if (index !== undefined && index >= 0 && index <= newFeatureIds.length) {
|
|
134
|
-
newFeatureIds.splice(index, 0, featureId);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
newFeatureIds.push(featureId);
|
|
138
|
-
}
|
|
139
|
-
store.updateGroup(groupId, { featureIds: newFeatureIds });
|
|
140
|
-
// Set the groupId and the layerId (when needed) on the feature
|
|
141
|
-
const updates = { groupId };
|
|
142
|
-
if (targetLayerId && feature.layerId !== targetLayerId) {
|
|
143
|
-
updates.layerId = targetLayerId;
|
|
144
|
-
}
|
|
145
|
-
store.updateFeature(featureId, updates);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
13
|
/**
|
|
149
14
|
* Removes a feature from a group
|
|
150
15
|
*
|
|
151
16
|
* @internal
|
|
152
17
|
*/
|
|
153
|
-
export function
|
|
18
|
+
export function takeOutOfGroup(store, featureId) {
|
|
154
19
|
const feature = store.getFeature(featureId);
|
|
155
20
|
if (!feature?.groupId)
|
|
156
21
|
return;
|
|
@@ -159,8 +24,8 @@ export function removeFeatureFromGroup(store, featureId) {
|
|
|
159
24
|
return;
|
|
160
25
|
// Find the layer the group belongs to
|
|
161
26
|
let layerId = null;
|
|
162
|
-
for (const layer of store.
|
|
163
|
-
if (layer.
|
|
27
|
+
for (const layer of store.listLayers()) {
|
|
28
|
+
if (layer.items.includes(group.id)) {
|
|
164
29
|
layerId = layer.id;
|
|
165
30
|
break;
|
|
166
31
|
}
|
|
@@ -175,10 +40,10 @@ export function removeFeatureFromGroup(store, featureId) {
|
|
|
175
40
|
if (layerId) {
|
|
176
41
|
const layer = store.getLayer(layerId);
|
|
177
42
|
if (layer) {
|
|
178
|
-
const groupIndex = layer.
|
|
179
|
-
const newOrder = [...layer.
|
|
43
|
+
const groupIndex = layer.items.indexOf(group.id);
|
|
44
|
+
const newOrder = [...layer.items];
|
|
180
45
|
newOrder.splice(groupIndex + 1, 0, featureId);
|
|
181
|
-
store.updateLayer(layerId, {
|
|
46
|
+
store.updateLayer(layerId, { items: newOrder });
|
|
182
47
|
}
|
|
183
48
|
}
|
|
184
49
|
// Delete the group when it has become empty (after the feature has been moved out
|
|
@@ -222,6 +87,7 @@ export function groupSelection(store, generateFeatureId, autoNameGenerator) {
|
|
|
222
87
|
const groupName = autoNameGenerator.generateGroupName();
|
|
223
88
|
const group = {
|
|
224
89
|
id: groupId,
|
|
90
|
+
layerId,
|
|
225
91
|
name: groupName,
|
|
226
92
|
featureIds: [...selectedIds],
|
|
227
93
|
locked: false,
|
|
@@ -233,15 +99,15 @@ export function groupSelection(store, generateFeatureId, autoNameGenerator) {
|
|
|
233
99
|
if (layer) {
|
|
234
100
|
// Find the frontmost one (the largest index) among the selected features
|
|
235
101
|
let frontmostSelectedId = null;
|
|
236
|
-
for (let i = layer.
|
|
237
|
-
if (selectedIds.includes(layer.
|
|
238
|
-
frontmostSelectedId = layer.
|
|
102
|
+
for (let i = layer.items.length - 1; i >= 0; i--) {
|
|
103
|
+
if (selectedIds.includes(layer.items[i])) {
|
|
104
|
+
frontmostSelectedId = layer.items[i];
|
|
239
105
|
break;
|
|
240
106
|
}
|
|
241
107
|
}
|
|
242
108
|
// Build the new order (insert the group at the position of the frontmost selected feature)
|
|
243
109
|
const newOrder = [];
|
|
244
|
-
for (const id of layer.
|
|
110
|
+
for (const id of layer.items) {
|
|
245
111
|
if (selectedIds.includes(id)) {
|
|
246
112
|
// Insert the group at the position of the frontmost selected feature
|
|
247
113
|
if (id === frontmostSelectedId) {
|
|
@@ -259,7 +125,7 @@ export function groupSelection(store, generateFeatureId, autoNameGenerator) {
|
|
|
259
125
|
if (frontmostSelectedId === null) {
|
|
260
126
|
newOrder.push(groupId);
|
|
261
127
|
}
|
|
262
|
-
store.updateLayer(layerId, {
|
|
128
|
+
store.updateLayer(layerId, { items: newOrder });
|
|
263
129
|
}
|
|
264
130
|
// Create the group
|
|
265
131
|
store.createGroup(group);
|
|
@@ -277,8 +143,8 @@ function dissolveGroup(store, groupId) {
|
|
|
277
143
|
return;
|
|
278
144
|
// Identify the layer the group belongs to
|
|
279
145
|
let targetLayerId = null;
|
|
280
|
-
for (const layer of store.
|
|
281
|
-
if (layer.
|
|
146
|
+
for (const layer of store.listLayers()) {
|
|
147
|
+
if (layer.items.includes(groupId)) {
|
|
282
148
|
targetLayerId = layer.id;
|
|
283
149
|
break;
|
|
284
150
|
}
|
|
@@ -289,25 +155,14 @@ function dissolveGroup(store, groupId) {
|
|
|
289
155
|
// position
|
|
290
156
|
const layer = store.getLayer(targetLayerId);
|
|
291
157
|
if (layer) {
|
|
292
|
-
const groupIndex = layer.
|
|
293
|
-
const newOrder = [...layer.
|
|
158
|
+
const groupIndex = layer.items.indexOf(groupId);
|
|
159
|
+
const newOrder = [...layer.items];
|
|
294
160
|
newOrder.splice(groupIndex, 1, ...group.featureIds);
|
|
295
|
-
store.updateLayer(targetLayerId, {
|
|
161
|
+
store.updateLayer(targetLayerId, { items: newOrder });
|
|
296
162
|
}
|
|
297
163
|
// Delete the group
|
|
298
164
|
store.deleteGroup(groupId);
|
|
299
165
|
}
|
|
300
|
-
/**
|
|
301
|
-
* Dissolves the given group (it does not depend on the selection).
|
|
302
|
-
* For "ungroup that group" in a panel menu and the like.
|
|
303
|
-
*
|
|
304
|
-
* @internal
|
|
305
|
-
*/
|
|
306
|
-
export function ungroupGroup(store, groupId) {
|
|
307
|
-
store.transact(() => {
|
|
308
|
-
dissolveGroup(store, groupId);
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
166
|
/**
|
|
312
167
|
* Takes the selection out of the group structure (following Felt).
|
|
313
168
|
*
|
|
@@ -315,36 +170,42 @@ export function ungroupGroup(store, groupId) {
|
|
|
315
170
|
* original position)
|
|
316
171
|
* - When a member feature of a group is selected -> only that feature is taken out of the
|
|
317
172
|
* group (the group is kept; the member is placed right after the group by
|
|
318
|
-
*
|
|
173
|
+
* takeOutOfGroup, and the group is deleted automatically when it becomes empty).
|
|
319
174
|
* The group is not dissolved as a whole
|
|
320
175
|
* - Otherwise (a feature that is not a member / no selection) -> nothing is done
|
|
321
176
|
*
|
|
322
177
|
* Even with several targets it is gathered into one transaction, making it one undo unit.
|
|
323
178
|
*
|
|
179
|
+
* @returns Whether a group was dissolved or a feature taken out of its group
|
|
324
180
|
* @internal
|
|
325
181
|
*/
|
|
326
182
|
export function ungroupSelection(store) {
|
|
327
183
|
const selection = store.getSelection();
|
|
328
184
|
if (selection.ids.length === 0)
|
|
329
|
-
return;
|
|
185
|
+
return false;
|
|
330
186
|
// A group selection -> dissolve
|
|
331
187
|
if (selection.type === 'group') {
|
|
188
|
+
const groupIds = selection.ids.filter((id) => store.getGroup(id) !== undefined);
|
|
189
|
+
if (groupIds.length === 0)
|
|
190
|
+
return false;
|
|
332
191
|
store.transact(() => {
|
|
333
|
-
for (const groupId of
|
|
192
|
+
for (const groupId of groupIds) {
|
|
334
193
|
dissolveGroup(store, groupId);
|
|
335
194
|
}
|
|
336
195
|
});
|
|
337
|
-
return;
|
|
196
|
+
return true;
|
|
338
197
|
}
|
|
339
198
|
// A feature selection -> take only the selected members out of the group (do not dissolve)
|
|
340
199
|
if (selection.type === 'feature') {
|
|
341
200
|
const memberIds = selection.ids.filter((id) => store.getFeature(id)?.groupId !== undefined);
|
|
342
201
|
if (memberIds.length === 0)
|
|
343
|
-
return;
|
|
202
|
+
return false;
|
|
344
203
|
store.transact(() => {
|
|
345
204
|
for (const id of memberIds) {
|
|
346
|
-
|
|
205
|
+
takeOutOfGroup(store, id);
|
|
347
206
|
}
|
|
348
207
|
});
|
|
208
|
+
return true;
|
|
349
209
|
}
|
|
210
|
+
return false;
|
|
350
211
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* so a handle follows the pointer on the map at any latitude. The extension points of the
|
|
6
6
|
* draw instance are passed in as an argument ({@link ResizeExtensions}).
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { TypeResizeResult } from '../extension/index.js';
|
|
9
9
|
import type { HandleType } from '../shared/config/constants.js';
|
|
10
10
|
import type { BoundingBoxCoords } from '../shared/types/selection-box.js';
|
|
11
11
|
import type { Feature, FeatureCoordinates } from '../store/types.js';
|
|
@@ -15,7 +15,7 @@ import type { Feature, FeatureCoordinates } from '../store/types.js';
|
|
|
15
15
|
export type ResizeCalculator = (handle: HandleType, state: ResizeState, currentLngLat: {
|
|
16
16
|
lng: number;
|
|
17
17
|
lat: number;
|
|
18
|
-
}, feature: Feature) =>
|
|
18
|
+
}, feature: Feature) => TypeResizeResult | null;
|
|
19
19
|
/**
|
|
20
20
|
* The extension points the resize reads from the draw instance
|
|
21
21
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
3
|
import { fromPlane, toPlane } from '../shared/math/mercator-plane.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getDrawProperty, hasDrawProperty } from '../shared/properties.js';
|
|
5
|
+
import { coordinatesOf, mapCoordinatesDeep } from '../shared/utils/coordinates.js';
|
|
5
6
|
import { getCircleRadius, getImageProperties } from '../shared/utils/property.js';
|
|
6
7
|
/**
|
|
7
8
|
* Decides whether a feature has a scale property
|
|
@@ -24,7 +25,7 @@ function hasScaleProperty(feature, extensions) {
|
|
|
24
25
|
// Generic check (decided by the presence of a scale property)
|
|
25
26
|
return (feature.properties !== null &&
|
|
26
27
|
typeof feature.properties === 'object' &&
|
|
27
|
-
'scale'
|
|
28
|
+
hasDrawProperty(feature.properties, 'scale'));
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Gets the value of the scale property of a feature
|
|
@@ -34,8 +35,7 @@ function getFeatureScale(feature) {
|
|
|
34
35
|
const props = getImageProperties(feature);
|
|
35
36
|
return props.scale ?? 1;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
return typeof props.scale === 'number' ? props.scale : 1;
|
|
38
|
+
return getDrawProperty(feature, 'scale') ?? 1;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Gets the anchor (the fixed point) from the handle position
|
|
@@ -219,7 +219,7 @@ export function startResize(handle, startLngLat, bbox, features, extensions, min
|
|
|
219
219
|
const initialWidth = new Map();
|
|
220
220
|
const initialHeight = new Map();
|
|
221
221
|
for (const feature of features) {
|
|
222
|
-
initialCoordinates.set(feature.id, JSON.parse(JSON.stringify(feature
|
|
222
|
+
initialCoordinates.set(feature.id, JSON.parse(JSON.stringify(coordinatesOf(feature))));
|
|
223
223
|
// For a feature that has a scale property, store the initial scale
|
|
224
224
|
if (hasScaleProperty(feature, extensions)) {
|
|
225
225
|
initialScales.set(feature.id, getFeatureScale(feature));
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* ({@link RotateExtensions}).
|
|
10
10
|
*/
|
|
11
11
|
import { fromPlane, toPlane } from '../shared/math/mercator-plane.js';
|
|
12
|
-
import {
|
|
12
|
+
import { getDrawProperty, hasDrawProperty } from '../shared/properties.js';
|
|
13
|
+
import { coordinatesOf, mapCoordinatesDeep } from '../shared/utils/coordinates.js';
|
|
13
14
|
import { getImageProperties } from '../shared/utils/property.js';
|
|
14
15
|
/**
|
|
15
16
|
* Decides whether a feature has a rotation property
|
|
@@ -30,7 +31,7 @@ function hasRotationProperty(feature, extensions) {
|
|
|
30
31
|
// Also covers features that have a rotation property in properties
|
|
31
32
|
return (feature.properties !== null &&
|
|
32
33
|
typeof feature.properties === 'object' &&
|
|
33
|
-
'rotation'
|
|
34
|
+
hasDrawProperty(feature.properties, 'rotation'));
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Gets the value of the rotation property of a feature
|
|
@@ -40,8 +41,7 @@ function getFeatureRotation(feature) {
|
|
|
40
41
|
const props = getImageProperties(feature);
|
|
41
42
|
return props.rotation ?? 0;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
return typeof props.rotation === 'number' ? props.rotation : 0;
|
|
44
|
+
return getDrawProperty(feature, 'rotation') ?? 0;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Computes the angle of a point around the center (radians, counterclockwise from east, in
|
|
@@ -141,7 +141,7 @@ export function startRotation(startLngLat, bbox, features, extensions) {
|
|
|
141
141
|
const initialCoordinates = new Map();
|
|
142
142
|
const initialRotations = new Map();
|
|
143
143
|
for (const feature of features) {
|
|
144
|
-
initialCoordinates.set(feature.id, JSON.parse(JSON.stringify(feature
|
|
144
|
+
initialCoordinates.set(feature.id, JSON.parse(JSON.stringify(coordinatesOf(feature))));
|
|
145
145
|
// For a feature that has a rotation property, store the initial rotation angle
|
|
146
146
|
if (hasRotationProperty(feature, extensions)) {
|
|
147
147
|
initialRotations.set(feature.id, getFeatureRotation(feature));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Store } from '../store/store.js';
|
|
2
|
+
import type { VertexSelection } from '../store/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Deletes what is selected, as one change. The Delete key of the select mode and
|
|
4
|
-
* `draw.
|
|
5
|
+
* `draw.selection.delete()` both run this.
|
|
5
6
|
*
|
|
6
7
|
* - vertices selected: deletes those vertices
|
|
7
8
|
* - feature: deletes the selected features
|
|
@@ -18,3 +19,17 @@ import type { Store } from '../store/store.js';
|
|
|
18
19
|
* on, when nothing is selected, or when everything selected is locked
|
|
19
20
|
*/
|
|
20
21
|
export declare function deleteSelection(store: Store): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Deletes the selected features, groups or layers as one change, leaving the vertex selection
|
|
24
|
+
* aside (see {@link deleteSelection} for what each selection deletes)
|
|
25
|
+
*
|
|
26
|
+
* @returns true when something was deleted; false while read-only or the interaction lock is
|
|
27
|
+
* on, when nothing is selected, or when everything selected is locked
|
|
28
|
+
*/
|
|
29
|
+
export declare function deleteSelectedItems(store: Store): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Deletes the selected vertices of one feature as one change
|
|
32
|
+
*
|
|
33
|
+
* @returns The number of vertices deleted
|
|
34
|
+
*/
|
|
35
|
+
export declare function deleteSelectedVertices(store: Store, selection: VertexSelection): number;
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* Selection operations
|
|
5
5
|
*
|
|
6
6
|
* Deletes what is selected. The Delete key of the select mode (modes/) and
|
|
7
|
-
* `draw.
|
|
7
|
+
* `draw.selection.delete()` (api/) both call this, so the two paths delete the same things.
|
|
8
8
|
*/
|
|
9
|
+
import { coordinatesOf, geometryFromCoordinates } from '../shared/utils/coordinates.js';
|
|
9
10
|
import { isFeatureLocked, isGroupLocked } from '../store/lock.js';
|
|
10
11
|
import { deleteVertex as deleteVertexOp, sortVertexRefsForDeletion } from './vertex.js';
|
|
11
12
|
/**
|
|
12
13
|
* Deletes what is selected, as one change. The Delete key of the select mode and
|
|
13
|
-
* `draw.
|
|
14
|
+
* `draw.selection.delete()` both run this.
|
|
14
15
|
*
|
|
15
16
|
* - vertices selected: deletes those vertices
|
|
16
17
|
* - feature: deletes the selected features
|
|
@@ -32,10 +33,22 @@ export function deleteSelection(store) {
|
|
|
32
33
|
if (store.isReadOnly() || store.isInteractionLocked())
|
|
33
34
|
return false;
|
|
34
35
|
// Delete the vertices when vertices are selected
|
|
35
|
-
const selectedVertices = store.
|
|
36
|
-
if (selectedVertices && selectedVertices.
|
|
36
|
+
const selectedVertices = store.getVertexSelection();
|
|
37
|
+
if (selectedVertices && selectedVertices.vertices.length > 0) {
|
|
37
38
|
return deleteSelectedVertices(store, selectedVertices) > 0;
|
|
38
39
|
}
|
|
40
|
+
return deleteSelectedItems(store);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Deletes the selected features, groups or layers as one change, leaving the vertex selection
|
|
44
|
+
* aside (see {@link deleteSelection} for what each selection deletes)
|
|
45
|
+
*
|
|
46
|
+
* @returns true when something was deleted; false while read-only or the interaction lock is
|
|
47
|
+
* on, when nothing is selected, or when everything selected is locked
|
|
48
|
+
*/
|
|
49
|
+
export function deleteSelectedItems(store) {
|
|
50
|
+
if (store.isReadOnly() || store.isInteractionLocked())
|
|
51
|
+
return false;
|
|
39
52
|
const selection = store.getSelection();
|
|
40
53
|
if (selection.ids.length === 0)
|
|
41
54
|
return false;
|
|
@@ -57,7 +70,7 @@ export function deleteSelection(store) {
|
|
|
57
70
|
}
|
|
58
71
|
if (selection.type === 'group') {
|
|
59
72
|
// Locked groups (themselves / the layer they belong to) are not deleted
|
|
60
|
-
const findLayerOfGroup = (groupId) => store.
|
|
73
|
+
const findLayerOfGroup = (groupId) => store.listLayers().find((l) => l.items.includes(groupId));
|
|
61
74
|
const groupIds = selection.ids.filter((groupId) => {
|
|
62
75
|
const group = store.getGroup(groupId);
|
|
63
76
|
return group !== undefined && !isGroupLocked(group, findLayerOfGroup);
|
|
@@ -94,7 +107,7 @@ export function deleteSelection(store) {
|
|
|
94
107
|
const layer = store.getLayer(layerId);
|
|
95
108
|
return layer !== undefined && !layer.locked && !holdsLockedItem(store, layerId);
|
|
96
109
|
});
|
|
97
|
-
const deletable = layerIds.slice(0, Math.max(0, store.
|
|
110
|
+
const deletable = layerIds.slice(0, Math.max(0, store.listLayers().length - 1));
|
|
98
111
|
if (deletable.length === 0)
|
|
99
112
|
return false;
|
|
100
113
|
store.transact(() => {
|
|
@@ -114,19 +127,19 @@ function holdsLockedItem(store, layerId) {
|
|
|
114
127
|
const layer = store.getLayer(layerId);
|
|
115
128
|
if (!layer)
|
|
116
129
|
return false;
|
|
117
|
-
for (const itemId of layer.
|
|
130
|
+
for (const itemId of layer.items) {
|
|
118
131
|
const group = store.getGroup(itemId);
|
|
119
132
|
if (group?.locked)
|
|
120
133
|
return true;
|
|
121
134
|
}
|
|
122
|
-
return store.
|
|
135
|
+
return store.listFeatures().some((f) => f.layerId === layerId && isFeatureLocked(f, store));
|
|
123
136
|
}
|
|
124
137
|
/**
|
|
125
138
|
* Deletes the selected vertices of one feature as one change
|
|
126
139
|
*
|
|
127
140
|
* @returns The number of vertices deleted
|
|
128
141
|
*/
|
|
129
|
-
function deleteSelectedVertices(store, selection) {
|
|
142
|
+
export function deleteSelectedVertices(store, selection) {
|
|
130
143
|
const feature = store.getFeature(selection.featureId);
|
|
131
144
|
if (!feature)
|
|
132
145
|
return 0;
|
|
@@ -136,14 +149,14 @@ function deleteSelectedVertices(store, selection) {
|
|
|
136
149
|
// Within the same part and the same ring, deletion goes in descending index order
|
|
137
150
|
// (avoiding the shift caused by what was already removed. For MultiPoint the part itself
|
|
138
151
|
// disappears, so parts are in descending order too)
|
|
139
|
-
const sortedRefs = sortVertexRefsForDeletion(selection.
|
|
152
|
+
const sortedRefs = sortVertexRefsForDeletion(selection.vertices);
|
|
140
153
|
// deleteVertex does not mutate its input and returns a new coordinate structure
|
|
141
154
|
// (copy-on-write), so no upfront copy is needed. Successive deletions only need the return
|
|
142
155
|
// value fed into the next input
|
|
143
|
-
let coords = feature
|
|
156
|
+
let coords = coordinatesOf(feature);
|
|
144
157
|
let deletedCount = 0;
|
|
145
158
|
for (const ref of sortedRefs) {
|
|
146
|
-
const result = deleteVertexOp({ ...feature,
|
|
159
|
+
const result = deleteVertexOp({ ...feature, geometry: geometryFromCoordinates(feature.type, coords) }, ref);
|
|
147
160
|
if (result !== null) {
|
|
148
161
|
coords = result;
|
|
149
162
|
deletedCount++;
|
|
@@ -151,7 +164,9 @@ function deleteSelectedVertices(store, selection) {
|
|
|
151
164
|
}
|
|
152
165
|
if (deletedCount > 0) {
|
|
153
166
|
store.transact(() => {
|
|
154
|
-
store.updateFeature(selection.featureId, {
|
|
167
|
+
store.updateFeature(selection.featureId, {
|
|
168
|
+
geometry: geometryFromCoordinates(feature.type, coords),
|
|
169
|
+
});
|
|
155
170
|
store.setSelectedVertices(null);
|
|
156
171
|
});
|
|
157
172
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* without vertex movement, such as Circle / Image / Freehand, are excluded from the
|
|
19
19
|
* candidates.
|
|
20
20
|
*/
|
|
21
|
+
import { coordinatesOf } from '../shared/utils/coordinates.js';
|
|
21
22
|
import { hasVertexRef } from '../shared/utils/vertex-ref.js';
|
|
22
23
|
import { isLocallyHidden } from '../store/local-visibility.js';
|
|
23
24
|
import { isFeatureLocked } from '../store/lock.js';
|
|
@@ -44,7 +45,8 @@ const VERTEX_MOVABLE_TYPES = new Set([
|
|
|
44
45
|
* point would lose track of "which of the first and the last one matched".
|
|
45
46
|
*/
|
|
46
47
|
function forEachVertex(feature, visit) {
|
|
47
|
-
const { type
|
|
48
|
+
const { type } = feature;
|
|
49
|
+
const coordinates = coordinatesOf(feature);
|
|
48
50
|
if (type === 'Point') {
|
|
49
51
|
visit(coordinates, { ring: 0, index: 0 });
|
|
50
52
|
return;
|
|
@@ -142,7 +144,7 @@ export function resolveVertexCoordinates(feature, refs) {
|
|
|
142
144
|
*
|
|
143
145
|
* Features under an effective lock (their own, their group's or their layer's) and
|
|
144
146
|
* hidden features are excluded. The cascade of the shared visible flag is aligned
|
|
145
|
-
* with the test in
|
|
147
|
+
* with the test in listFeaturesInOrder, and local hiding with the one in
|
|
146
148
|
* getDisplayFeatures.
|
|
147
149
|
*/
|
|
148
150
|
function isFollowCandidate(feature, store) {
|
|
@@ -59,24 +59,6 @@ export interface TraceGraphEndpoint {
|
|
|
59
59
|
* @param features The features to build from (pass only the visible ones)
|
|
60
60
|
* @param bbox The extent in degrees; only the edges that touch it are taken in
|
|
61
61
|
* @returns The graph. It has no nodes when no edge falls in `bbox`
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```ts
|
|
65
|
-
* import { buildTraceGraph, findTracePath } from '@sakuzu/maplibre-gl-draw';
|
|
66
|
-
*
|
|
67
|
-
* const graph = buildTraceGraph(draw.getAllFeatures(), {
|
|
68
|
-
* minX: 139.7,
|
|
69
|
-
* minY: 35.6,
|
|
70
|
-
* maxX: 139.8,
|
|
71
|
-
* maxY: 35.7,
|
|
72
|
-
* });
|
|
73
|
-
* // The boundary vertices between two vertices of the same parcel
|
|
74
|
-
* const between = findTracePath(
|
|
75
|
-
* graph,
|
|
76
|
-
* { coordinate: [139.71, 35.61], node: [139.71, 35.61] },
|
|
77
|
-
* { coordinate: [139.75, 35.65], node: [139.75, 35.65] },
|
|
78
|
-
* );
|
|
79
|
-
* ```
|
|
80
62
|
*/
|
|
81
63
|
export declare function buildTraceGraph(features: readonly Feature[], bbox: BoundingBox): TraceGraph;
|
|
82
64
|
/**
|
|
@@ -52,24 +52,6 @@ function nodeKey(coordinate) {
|
|
|
52
52
|
* @param features The features to build from (pass only the visible ones)
|
|
53
53
|
* @param bbox The extent in degrees; only the edges that touch it are taken in
|
|
54
54
|
* @returns The graph. It has no nodes when no edge falls in `bbox`
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* import { buildTraceGraph, findTracePath } from '@sakuzu/maplibre-gl-draw';
|
|
59
|
-
*
|
|
60
|
-
* const graph = buildTraceGraph(draw.getAllFeatures(), {
|
|
61
|
-
* minX: 139.7,
|
|
62
|
-
* minY: 35.6,
|
|
63
|
-
* maxX: 139.8,
|
|
64
|
-
* maxY: 35.7,
|
|
65
|
-
* });
|
|
66
|
-
* // The boundary vertices between two vertices of the same parcel
|
|
67
|
-
* const between = findTracePath(
|
|
68
|
-
* graph,
|
|
69
|
-
* { coordinate: [139.71, 35.61], node: [139.71, 35.61] },
|
|
70
|
-
* { coordinate: [139.75, 35.65], node: [139.75, 35.65] },
|
|
71
|
-
* );
|
|
72
|
-
* ```
|
|
73
55
|
*/
|
|
74
56
|
export function buildTraceGraph(features, bbox) {
|
|
75
57
|
const nodes = new Map();
|