@sakuzu/maplibre-gl-draw 1.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 +43 -0
- package/LICENSE +661 -0
- package/README.ja.md +248 -0
- package/README.md +255 -0
- package/THIRD_PARTY_NOTICES.md +275 -0
- package/dist/api/api.d.ts +1259 -0
- package/dist/api/api.js +86 -0
- package/dist/api/context.d.ts +173 -0
- package/dist/api/context.js +193 -0
- package/dist/api/display-api.d.ts +1 -0
- package/dist/api/display-api.js +23 -0
- package/dist/api/event-api.d.ts +13 -0
- package/dist/api/event-api.js +17 -0
- package/dist/api/extension-api.d.ts +46 -0
- package/dist/api/extension-api.js +85 -0
- package/dist/api/feature-api.d.ts +11 -0
- package/dist/api/feature-api.js +101 -0
- package/dist/api/geometry/apply.d.ts +51 -0
- package/dist/api/geometry/apply.js +114 -0
- package/dist/api/geometry/boolean.d.ts +28 -0
- package/dist/api/geometry/boolean.js +65 -0
- package/dist/api/geometry/buffer.d.ts +11 -0
- package/dist/api/geometry/buffer.js +105 -0
- package/dist/api/geometry/split.d.ts +16 -0
- package/dist/api/geometry/split.js +75 -0
- package/dist/api/geometry/targets.d.ts +76 -0
- package/dist/api/geometry/targets.js +158 -0
- package/dist/api/geometry/types.d.ts +31 -0
- package/dist/api/geometry/types.js +3 -0
- package/dist/api/geometry-operations.d.ts +162 -0
- package/dist/api/geometry-operations.js +94 -0
- package/dist/api/group-api.d.ts +10 -0
- package/dist/api/group-api.js +78 -0
- package/dist/api/import-export/constants.d.ts +29 -0
- package/dist/api/import-export/constants.js +40 -0
- package/dist/api/import-export/embedded-file.d.ts +13 -0
- package/dist/api/import-export/embedded-file.js +31 -0
- package/dist/api/import-export/file-name.d.ts +10 -0
- package/dist/api/import-export/file-name.js +20 -0
- package/dist/api/import-export/format-detection.d.ts +12 -0
- package/dist/api/import-export/format-detection.js +29 -0
- package/dist/api/import-export/geojson-export.d.ts +19 -0
- package/dist/api/import-export/geojson-export.js +262 -0
- package/dist/api/import-export/geojson-import.d.ts +34 -0
- package/dist/api/import-export/geojson-import.js +538 -0
- package/dist/api/import-export/geometry-validation.d.ts +20 -0
- package/dist/api/import-export/geometry-validation.js +107 -0
- package/dist/api/import-export/image-import.d.ts +12 -0
- package/dist/api/import-export/image-import.js +53 -0
- package/dist/api/import-export/index.d.ts +9 -0
- package/dist/api/import-export/index.js +107 -0
- package/dist/api/import-export/native-format.d.ts +15 -0
- package/dist/api/import-export/native-format.js +126 -0
- package/dist/api/import-export/native-validation.d.ts +28 -0
- package/dist/api/import-export/native-validation.js +212 -0
- package/dist/api/import-export/own-property.d.ts +10 -0
- package/dist/api/import-export/own-property.js +19 -0
- package/dist/api/import-export/style-validation.d.ts +27 -0
- package/dist/api/import-export/style-validation.js +49 -0
- package/dist/api/import-export/types.d.ts +26 -0
- package/dist/api/import-export/types.js +3 -0
- package/dist/api/index.d.ts +15 -0
- package/dist/api/index.js +3 -0
- package/dist/api/input-api.d.ts +158 -0
- package/dist/api/input-api.js +144 -0
- package/dist/api/instance-api.d.ts +38 -0
- package/dist/api/instance-api.js +136 -0
- package/dist/api/layer-api.d.ts +12 -0
- package/dist/api/layer-api.js +62 -0
- package/dist/api/selection-api.d.ts +7 -0
- package/dist/api/selection-api.js +78 -0
- package/dist/api/snapping-api.d.ts +125 -0
- package/dist/api/snapping-api.js +50 -0
- package/dist/api/topology-api.d.ts +30 -0
- package/dist/api/topology-api.js +16 -0
- package/dist/api/tracing-api.d.ts +31 -0
- package/dist/api/tracing-api.js +16 -0
- package/dist/dispatcher/hit-test/box-strategies.d.ts +19 -0
- package/dist/dispatcher/hit-test/box-strategies.js +275 -0
- package/dist/dispatcher/hit-test/box-strategy.d.ts +59 -0
- package/dist/dispatcher/hit-test/box-strategy.js +37 -0
- package/dist/dispatcher/hit-test/globe-shape.d.ts +46 -0
- package/dist/dispatcher/hit-test/globe-shape.js +70 -0
- package/dist/dispatcher/hit-test/index.d.ts +14 -0
- package/dist/dispatcher/hit-test/index.js +9 -0
- package/dist/dispatcher/hit-test/local-frame.d.ts +77 -0
- package/dist/dispatcher/hit-test/local-frame.js +112 -0
- package/dist/dispatcher/hit-test/segment-grid.d.ts +32 -0
- package/dist/dispatcher/hit-test/segment-grid.js +79 -0
- package/dist/dispatcher/hit-test/service.d.ts +120 -0
- package/dist/dispatcher/hit-test/service.js +333 -0
- package/dist/dispatcher/hit-test/strategies/base.d.ts +136 -0
- package/dist/dispatcher/hit-test/strategies/base.js +66 -0
- package/dist/dispatcher/hit-test/strategies/circle.d.ts +10 -0
- package/dist/dispatcher/hit-test/strategies/circle.js +56 -0
- package/dist/dispatcher/hit-test/strategies/image.d.ts +22 -0
- package/dist/dispatcher/hit-test/strategies/image.js +115 -0
- package/dist/dispatcher/hit-test/strategies/index.d.ts +11 -0
- package/dist/dispatcher/hit-test/strategies/index.js +10 -0
- package/dist/dispatcher/hit-test/strategies/line.d.ts +17 -0
- package/dist/dispatcher/hit-test/strategies/line.js +30 -0
- package/dist/dispatcher/hit-test/strategies/multi.d.ts +44 -0
- package/dist/dispatcher/hit-test/strategies/multi.js +141 -0
- package/dist/dispatcher/hit-test/strategies/point.d.ts +20 -0
- package/dist/dispatcher/hit-test/strategies/point.js +29 -0
- package/dist/dispatcher/hit-test/strategies/polygon.d.ts +52 -0
- package/dist/dispatcher/hit-test/strategies/polygon.js +138 -0
- package/dist/dispatcher/hit-test/topmost.d.ts +48 -0
- package/dist/dispatcher/hit-test/topmost.js +157 -0
- package/dist/dispatcher/hit-test/visibility-lookup.d.ts +23 -0
- package/dist/dispatcher/hit-test/visibility-lookup.js +40 -0
- package/dist/dispatcher/index.d.ts +15 -0
- package/dist/dispatcher/index.js +3 -0
- package/dist/dispatcher/input-router.d.ts +1 -0
- package/dist/dispatcher/input-router.js +288 -0
- package/dist/dispatcher/normalizer.d.ts +1 -0
- package/dist/dispatcher/normalizer.js +513 -0
- package/dist/dispatcher/types.d.ts +144 -0
- package/dist/dispatcher/types.js +15 -0
- package/dist/display/chunk-set.d.ts +24 -0
- package/dist/display/chunk-set.js +533 -0
- package/dist/display/chunk.d.ts +1 -0
- package/dist/display/chunk.js +104 -0
- package/dist/display/columnar/index.d.ts +12 -0
- package/dist/display/columnar/index.js +13 -0
- package/dist/display/columnar/prepare.d.ts +42 -0
- package/dist/display/columnar/prepare.js +116 -0
- package/dist/display/columnar/source.d.ts +1 -0
- package/dist/display/columnar/source.js +531 -0
- package/dist/display/columnar/table.d.ts +1 -0
- package/dist/display/columnar/table.js +471 -0
- package/dist/display/columnar/types.d.ts +223 -0
- package/dist/display/columnar/types.js +3 -0
- package/dist/display/dataset.d.ts +2 -0
- package/dist/display/dataset.js +891 -0
- package/dist/display/index.d.ts +13 -0
- package/dist/display/index.js +3 -0
- package/dist/display/interaction.d.ts +1 -0
- package/dist/display/interaction.js +90 -0
- package/dist/display/manager.d.ts +1 -0
- package/dist/display/manager.js +440 -0
- package/dist/display/packed-rtree.d.ts +1 -0
- package/dist/display/packed-rtree.js +244 -0
- package/dist/display/partition.d.ts +1 -0
- package/dist/display/partition.js +226 -0
- package/dist/display/provider.d.ts +1 -0
- package/dist/display/provider.js +342 -0
- package/dist/display/retained.d.ts +40 -0
- package/dist/display/retained.js +898 -0
- package/dist/display/selection.d.ts +13 -0
- package/dist/display/selection.js +226 -0
- package/dist/display/source.d.ts +1 -0
- package/dist/display/source.js +119 -0
- package/dist/display/spatial.d.ts +1 -0
- package/dist/display/spatial.js +71 -0
- package/dist/display/style.d.ts +1 -0
- package/dist/display/style.js +126 -0
- package/dist/display/thinning.d.ts +65 -0
- package/dist/display/thinning.js +910 -0
- package/dist/display/triangulation.d.ts +1 -0
- package/dist/display/triangulation.js +0 -0
- package/dist/display/types.d.ts +561 -0
- package/dist/display/types.js +43 -0
- package/dist/extension/feature-handler.d.ts +182 -0
- package/dist/extension/feature-handler.js +3 -0
- package/dist/extension/index.d.ts +9 -0
- package/dist/extension/index.js +3 -0
- package/dist/extension/renderers.d.ts +208 -0
- package/dist/extension/renderers.js +3 -0
- package/dist/geometry/angle.d.ts +47 -0
- package/dist/geometry/angle.js +44 -0
- package/dist/geometry/bbox.d.ts +48 -0
- package/dist/geometry/bbox.js +83 -0
- package/dist/geometry/boolean.d.ts +162 -0
- package/dist/geometry/boolean.js +331 -0
- package/dist/geometry/buffer.d.ts +72 -0
- package/dist/geometry/buffer.js +218 -0
- package/dist/geometry/circle.d.ts +55 -0
- package/dist/geometry/circle.js +107 -0
- package/dist/geometry/coords.d.ts +97 -0
- package/dist/geometry/coords.js +149 -0
- package/dist/geometry/distance.d.ts +79 -0
- package/dist/geometry/distance.js +111 -0
- package/dist/geometry/errors.d.ts +74 -0
- package/dist/geometry/errors.js +104 -0
- package/dist/geometry/index.d.ts +28 -0
- package/dist/geometry/index.js +38 -0
- package/dist/geometry/measure.d.ts +81 -0
- package/dist/geometry/measure.js +236 -0
- package/dist/geometry/predicates.d.ts +62 -0
- package/dist/geometry/predicates.js +132 -0
- package/dist/geometry/simplify.d.ts +74 -0
- package/dist/geometry/simplify.js +159 -0
- package/dist/geometry/split.d.ts +68 -0
- package/dist/geometry/split.js +430 -0
- package/dist/geometry/types.d.ts +95 -0
- package/dist/geometry/types.js +3 -0
- package/dist/geometry/units.d.ts +35 -0
- package/dist/geometry/units.js +41 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +20 -0
- package/dist/maplibre-gl-draw.d.ts +47 -0
- package/dist/maplibre-gl-draw.js +407 -0
- package/dist/messages.d.ts +64 -0
- package/dist/messages.js +36 -0
- package/dist/modes/cursor.d.ts +1 -0
- package/dist/modes/cursor.js +72 -0
- package/dist/modes/draw/circle.d.ts +1 -0
- package/dist/modes/draw/circle.js +222 -0
- package/dist/modes/draw/commit-layer.d.ts +26 -0
- package/dist/modes/draw/commit-layer.js +31 -0
- package/dist/modes/draw/freehand.d.ts +1 -0
- package/dist/modes/draw/freehand.js +264 -0
- package/dist/modes/draw/image.d.ts +1 -0
- package/dist/modes/draw/image.js +60 -0
- package/dist/modes/draw/index.d.ts +9 -0
- package/dist/modes/draw/index.js +11 -0
- package/dist/modes/draw/line.d.ts +1 -0
- package/dist/modes/draw/line.js +363 -0
- package/dist/modes/draw/point.d.ts +1 -0
- package/dist/modes/draw/point.js +87 -0
- package/dist/modes/draw/polygon.d.ts +1 -0
- package/dist/modes/draw/polygon.js +378 -0
- package/dist/modes/draw/trace-support.d.ts +79 -0
- package/dist/modes/draw/trace-support.js +161 -0
- package/dist/modes/handler.d.ts +285 -0
- package/dist/modes/handler.js +3 -0
- package/dist/modes/index.d.ts +7 -0
- package/dist/modes/index.js +3 -0
- package/dist/modes/manager.d.ts +15 -0
- package/dist/modes/manager.js +196 -0
- package/dist/modes/select/box-selection.d.ts +52 -0
- package/dist/modes/select/box-selection.js +140 -0
- package/dist/modes/select/click-handler.d.ts +32 -0
- package/dist/modes/select/click-handler.js +166 -0
- package/dist/modes/select/cursor-handler.d.ts +15 -0
- package/dist/modes/select/cursor-handler.js +59 -0
- package/dist/modes/select/drag/auxiliary.d.ts +26 -0
- package/dist/modes/select/drag/auxiliary.js +56 -0
- package/dist/modes/select/drag/intermediate-writes.d.ts +1 -0
- package/dist/modes/select/drag/intermediate-writes.js +171 -0
- package/dist/modes/select/drag/move.d.ts +24 -0
- package/dist/modes/select/drag/move.js +59 -0
- package/dist/modes/select/drag/operation.d.ts +30 -0
- package/dist/modes/select/drag/operation.js +18 -0
- package/dist/modes/select/drag/radius.d.ts +15 -0
- package/dist/modes/select/drag/radius.js +49 -0
- package/dist/modes/select/drag/transform.d.ts +17 -0
- package/dist/modes/select/drag/transform.js +155 -0
- package/dist/modes/select/drag/vertex.d.ts +17 -0
- package/dist/modes/select/drag/vertex.js +163 -0
- package/dist/modes/select/drag-handler.d.ts +1 -0
- package/dist/modes/select/drag-handler.js +254 -0
- package/dist/modes/select/hit-helpers.d.ts +40 -0
- package/dist/modes/select/hit-helpers.js +51 -0
- package/dist/modes/select/mode.d.ts +1 -0
- package/dist/modes/select/mode.js +397 -0
- package/dist/modes/select/shortcut-handler.d.ts +40 -0
- package/dist/modes/select/shortcut-handler.js +128 -0
- package/dist/operations/index.d.ts +9 -0
- package/dist/operations/index.js +3 -0
- package/dist/operations/layer-operations.d.ts +1 -0
- package/dist/operations/layer-operations.js +350 -0
- package/dist/operations/resize.d.ts +71 -0
- package/dist/operations/resize.js +252 -0
- package/dist/operations/rotate.d.ts +17 -0
- package/dist/operations/rotate.js +166 -0
- package/dist/operations/selection-operations.d.ts +20 -0
- package/dist/operations/selection-operations.js +159 -0
- package/dist/operations/shared-vertex.d.ts +1 -0
- package/dist/operations/shared-vertex.js +210 -0
- package/dist/operations/trace-graph.d.ts +96 -0
- package/dist/operations/trace-graph.js +283 -0
- package/dist/operations/vertex.d.ts +1 -0
- package/dist/operations/vertex.js +538 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/mutation-hooks.d.ts +28 -0
- package/dist/plugins/mutation-hooks.js +84 -0
- package/dist/plugins/plugin-context.d.ts +1 -0
- package/dist/plugins/plugin-context.js +367 -0
- package/dist/plugins/plugin-manager.d.ts +103 -0
- package/dist/plugins/plugin-manager.js +316 -0
- package/dist/plugins/plugin.d.ts +529 -0
- package/dist/plugins/plugin.js +3 -0
- package/dist/shared/config/constants.d.ts +66 -0
- package/dist/shared/config/constants.js +60 -0
- package/dist/shared/config/feature-style.d.ts +155 -0
- package/dist/shared/config/feature-style.js +154 -0
- package/dist/shared/config/index.d.ts +17 -0
- package/dist/shared/config/index.js +8 -0
- package/dist/shared/config/rendering.d.ts +107 -0
- package/dist/shared/config/rendering.js +33 -0
- package/dist/shared/config/selection-highlight.d.ts +29 -0
- package/dist/shared/config/selection-highlight.js +35 -0
- package/dist/shared/config/selection.d.ts +273 -0
- package/dist/shared/config/selection.js +266 -0
- package/dist/shared/config/topology.d.ts +33 -0
- package/dist/shared/config/topology.js +17 -0
- package/dist/shared/config/trace.d.ts +40 -0
- package/dist/shared/config/trace.js +17 -0
- package/dist/shared/math/angle.d.ts +21 -0
- package/dist/shared/math/angle.js +34 -0
- package/dist/shared/math/circle.d.ts +6 -0
- package/dist/shared/math/circle.js +10 -0
- package/dist/shared/math/constants.d.ts +48 -0
- package/dist/shared/math/constants.js +59 -0
- package/dist/shared/math/distance.d.ts +78 -0
- package/dist/shared/math/distance.js +147 -0
- package/dist/shared/math/globe-subdivision.d.ts +62 -0
- package/dist/shared/math/globe-subdivision.js +99 -0
- package/dist/shared/math/index.d.ts +17 -0
- package/dist/shared/math/index.js +21 -0
- package/dist/shared/math/intersection.d.ts +63 -0
- package/dist/shared/math/intersection.js +236 -0
- package/dist/shared/math/longitude.d.ts +20 -0
- package/dist/shared/math/longitude.js +31 -0
- package/dist/shared/math/mercator-plane.d.ts +27 -0
- package/dist/shared/math/mercator-plane.js +26 -0
- package/dist/shared/math/obb.d.ts +65 -0
- package/dist/shared/math/obb.js +107 -0
- package/dist/shared/math/rotation.d.ts +93 -0
- package/dist/shared/math/rotation.js +186 -0
- package/dist/shared/math/segment-grid.d.ts +69 -0
- package/dist/shared/math/segment-grid.js +159 -0
- package/dist/shared/math/transform.d.ts +140 -0
- package/dist/shared/math/transform.js +189 -0
- package/dist/shared/types/events.d.ts +128 -0
- package/dist/shared/types/events.js +3 -0
- package/dist/shared/types/model.d.ts +950 -0
- package/dist/shared/types/model.js +3 -0
- package/dist/shared/types/selection-box.d.ts +23 -0
- package/dist/shared/types/selection-box.js +3 -0
- package/dist/shared/types/style.d.ts +68 -0
- package/dist/shared/types/style.js +3 -0
- package/dist/shared/utils/color.d.ts +49 -0
- package/dist/shared/utils/color.js +180 -0
- package/dist/shared/utils/coordinates.d.ts +52 -0
- package/dist/shared/utils/coordinates.js +75 -0
- package/dist/shared/utils/embedded-image.d.ts +34 -0
- package/dist/shared/utils/embedded-image.js +161 -0
- package/dist/shared/utils/event-emitter.d.ts +262 -0
- package/dist/shared/utils/event-emitter.js +44 -0
- package/dist/shared/utils/feature-bbox.d.ts +8 -0
- package/dist/shared/utils/feature-bbox.js +207 -0
- package/dist/shared/utils/feature-segments.d.ts +23 -0
- package/dist/shared/utils/feature-segments.js +179 -0
- package/dist/shared/utils/id.d.ts +1 -0
- package/dist/shared/utils/id.js +35 -0
- package/dist/shared/utils/image.d.ts +34 -0
- package/dist/shared/utils/image.js +106 -0
- package/dist/shared/utils/index.d.ts +15 -0
- package/dist/shared/utils/index.js +24 -0
- package/dist/shared/utils/map.d.ts +26 -0
- package/dist/shared/utils/map.js +35 -0
- package/dist/shared/utils/name-generator.d.ts +197 -0
- package/dist/shared/utils/name-generator.js +337 -0
- package/dist/shared/utils/pixel-ratio.d.ts +111 -0
- package/dist/shared/utils/pixel-ratio.js +85 -0
- package/dist/shared/utils/property.d.ts +88 -0
- package/dist/shared/utils/property.js +140 -0
- package/dist/shared/utils/vertex-ref.d.ts +23 -0
- package/dist/shared/utils/vertex-ref.js +20 -0
- package/dist/snapping/custom-targets.d.ts +1 -0
- package/dist/snapping/custom-targets.js +21 -0
- package/dist/snapping/geometry.d.ts +1 -0
- package/dist/snapping/geometry.js +61 -0
- package/dist/snapping/index.d.ts +14 -0
- package/dist/snapping/index.js +4 -0
- package/dist/snapping/indicator.d.ts +19 -0
- package/dist/snapping/indicator.js +145 -0
- package/dist/snapping/providers/display.d.ts +72 -0
- package/dist/snapping/providers/display.js +268 -0
- package/dist/snapping/providers/guide.d.ts +69 -0
- package/dist/snapping/providers/guide.js +187 -0
- package/dist/snapping/providers/intersection.d.ts +1 -0
- package/dist/snapping/providers/intersection.js +92 -0
- package/dist/snapping/providers/shared.d.ts +39 -0
- package/dist/snapping/providers/shared.js +146 -0
- package/dist/snapping/providers/store.d.ts +1 -0
- package/dist/snapping/providers/store.js +132 -0
- package/dist/snapping/service.d.ts +1 -0
- package/dist/snapping/service.js +272 -0
- package/dist/snapping/types.d.ts +267 -0
- package/dist/snapping/types.js +66 -0
- package/dist/store/change-merger.d.ts +1 -0
- package/dist/store/change-merger.js +102 -0
- package/dist/store/draw-store.d.ts +1 -0
- package/dist/store/draw-store.js +396 -0
- package/dist/store/event-bridge.d.ts +1 -0
- package/dist/store/event-bridge.js +161 -0
- package/dist/store/index.d.ts +12 -0
- package/dist/store/index.js +4 -0
- package/dist/store/local-visibility.d.ts +21 -0
- package/dist/store/local-visibility.js +27 -0
- package/dist/store/lock.d.ts +67 -0
- package/dist/store/lock.js +54 -0
- package/dist/store/memory/change-bus.d.ts +60 -0
- package/dist/store/memory/change-bus.js +232 -0
- package/dist/store/memory/file-store.d.ts +15 -0
- package/dist/store/memory/file-store.js +33 -0
- package/dist/store/memory/frozen.d.ts +21 -0
- package/dist/store/memory/frozen.js +51 -0
- package/dist/store/memory/ui-state.d.ts +51 -0
- package/dist/store/memory/ui-state.js +223 -0
- package/dist/store/memory.d.ts +26 -0
- package/dist/store/memory.js +708 -0
- package/dist/store/spatial/index.d.ts +6 -0
- package/dist/store/spatial/index.js +4 -0
- package/dist/store/spatial/spatial-index.d.ts +90 -0
- package/dist/store/spatial/spatial-index.js +148 -0
- package/dist/store/spatial/store-spatial-index.d.ts +60 -0
- package/dist/store/spatial/store-spatial-index.js +125 -0
- package/dist/store/store.d.ts +417 -0
- package/dist/store/store.js +3 -0
- package/dist/store/types.d.ts +8 -0
- package/dist/store/types.js +3 -0
- package/dist/store/writable-layer.d.ts +35 -0
- package/dist/store/writable-layer.js +20 -0
- package/dist/view/cache/buffer.d.ts +28 -0
- package/dist/view/cache/buffer.js +176 -0
- package/dist/view/cache/earcut.d.ts +1 -0
- package/dist/view/cache/earcut.js +122 -0
- package/dist/view/cache/style-rule.d.ts +1 -0
- package/dist/view/cache/style-rule.js +97 -0
- package/dist/view/cache/terrain-fill.d.ts +30 -0
- package/dist/view/cache/terrain-fill.js +60 -0
- package/dist/view/cache/texture.d.ts +14 -0
- package/dist/view/cache/texture.js +292 -0
- package/dist/view/coordinator.d.ts +27 -0
- package/dist/view/coordinator.js +72 -0
- package/dist/view/feature-companion.d.ts +173 -0
- package/dist/view/feature-companion.js +108 -0
- package/dist/view/globe-subdivision.d.ts +78 -0
- package/dist/view/globe-subdivision.js +128 -0
- package/dist/view/index.d.ts +47 -0
- package/dist/view/index.js +20 -0
- package/dist/view/layer/attach.d.ts +20 -0
- package/dist/view/layer/attach.js +47 -0
- package/dist/view/layer/blend.d.ts +57 -0
- package/dist/view/layer/blend.js +14 -0
- package/dist/view/layer/custom-layer.d.ts +1 -0
- package/dist/view/layer/custom-layer.js +509 -0
- package/dist/view/layer/depth-state.d.ts +14 -0
- package/dist/view/layer/depth-state.js +44 -0
- package/dist/view/layer/display-list.d.ts +1 -0
- package/dist/view/layer/display-list.js +111 -0
- package/dist/view/layer/drape-planner.d.ts +139 -0
- package/dist/view/layer/drape-planner.js +726 -0
- package/dist/view/layer/frame-render.d.ts +57 -0
- package/dist/view/layer/frame-render.js +209 -0
- package/dist/view/layer/frame-state.d.ts +147 -0
- package/dist/view/layer/frame-state.js +484 -0
- package/dist/view/layer/gl-state.d.ts +77 -0
- package/dist/view/layer/gl-state.js +132 -0
- package/dist/view/layer/index.d.ts +6 -0
- package/dist/view/layer/index.js +5 -0
- package/dist/view/layer/render-scope.d.ts +30 -0
- package/dist/view/layer/render-scope.js +28 -0
- package/dist/view/layer/render.d.ts +87 -0
- package/dist/view/layer/render.js +187 -0
- package/dist/view/layer/renderers.d.ts +81 -0
- package/dist/view/layer/renderers.js +142 -0
- package/dist/view/layer/slot-manager.d.ts +26 -0
- package/dist/view/layer/slot-manager.js +133 -0
- package/dist/view/layer/slots.d.ts +33 -0
- package/dist/view/layer/slots.js +50 -0
- package/dist/view/layer/store-retained-bbox.d.ts +36 -0
- package/dist/view/layer/store-retained-bbox.js +188 -0
- package/dist/view/layer/store-retained-chunk.d.ts +97 -0
- package/dist/view/layer/store-retained-chunk.js +94 -0
- package/dist/view/layer/store-retained-classify.d.ts +34 -0
- package/dist/view/layer/store-retained-classify.js +88 -0
- package/dist/view/layer/store-retained-collect.d.ts +24 -0
- package/dist/view/layer/store-retained-collect.js +121 -0
- package/dist/view/layer/store-retained-coord-patch.d.ts +119 -0
- package/dist/view/layer/store-retained-coord-patch.js +168 -0
- package/dist/view/layer/store-retained-immediate.d.ts +63 -0
- package/dist/view/layer/store-retained-immediate.js +49 -0
- package/dist/view/layer/store-retained-invalidation.d.ts +96 -0
- package/dist/view/layer/store-retained-invalidation.js +192 -0
- package/dist/view/layer/store-retained.d.ts +198 -0
- package/dist/view/layer/store-retained.js +430 -0
- package/dist/view/layer/terrain-resolver.d.ts +1 -0
- package/dist/view/layer/terrain-resolver.js +174 -0
- package/dist/view/renderers/batch-manager.d.ts +61 -0
- package/dist/view/renderers/batch-manager.js +718 -0
- package/dist/view/renderers/draw-factors.d.ts +60 -0
- package/dist/view/renderers/draw-factors.js +35 -0
- package/dist/view/renderers/drawer.d.ts +1 -0
- package/dist/view/renderers/drawer.js +346 -0
- package/dist/view/renderers/image.d.ts +1 -0
- package/dist/view/renderers/image.js +255 -0
- package/dist/view/renderers/line/dash.d.ts +31 -0
- package/dist/view/renderers/line/dash.js +152 -0
- package/dist/view/renderers/line/line-geometry.d.ts +39 -0
- package/dist/view/renderers/line/line-geometry.js +460 -0
- package/dist/view/renderers/line/line-gl.d.ts +1 -0
- package/dist/view/renderers/line/line-gl.js +236 -0
- package/dist/view/renderers/line/line-shader.d.ts +1 -0
- package/dist/view/renderers/line/line-shader.js +364 -0
- package/dist/view/renderers/line/line-types.d.ts +43 -0
- package/dist/view/renderers/line/line-types.js +3 -0
- package/dist/view/renderers/line/line-uniforms.d.ts +1 -0
- package/dist/view/renderers/line/line-uniforms.js +390 -0
- package/dist/view/renderers/line/sdf-line.d.ts +92 -0
- package/dist/view/renderers/line/sdf-line.js +567 -0
- package/dist/view/renderers/point/billboard-depth.d.ts +10 -0
- package/dist/view/renderers/point/billboard-depth.js +56 -0
- package/dist/view/renderers/point/point-instance.d.ts +124 -0
- package/dist/view/renderers/point/point-instance.js +738 -0
- package/dist/view/renderers/point/point-sdf.d.ts +58 -0
- package/dist/view/renderers/point/point-sdf.js +170 -0
- package/dist/view/renderers/point/point-shape.d.ts +99 -0
- package/dist/view/renderers/point/point-shape.js +504 -0
- package/dist/view/renderers/point/point-style.d.ts +1 -0
- package/dist/view/renderers/point/point-style.js +46 -0
- package/dist/view/renderers/polygon/batch.d.ts +26 -0
- package/dist/view/renderers/polygon/batch.js +336 -0
- package/dist/view/renderers/polygon/earcut-input.d.ts +37 -0
- package/dist/view/renderers/polygon/earcut-input.js +55 -0
- package/dist/view/renderers/polygon/earcut-sliced.d.ts +69 -0
- package/dist/view/renderers/polygon/earcut-sliced.js +960 -0
- package/dist/view/renderers/polygon/fill.d.ts +74 -0
- package/dist/view/renderers/polygon/fill.js +251 -0
- package/dist/view/renderers/polygon/sdf-polygon.d.ts +62 -0
- package/dist/view/renderers/polygon/sdf-polygon.js +919 -0
- package/dist/view/renderers/polygon/terrain-cull.d.ts +3 -0
- package/dist/view/renderers/polygon/terrain-cull.js +14 -0
- package/dist/view/renderers/polygon/triangulator.d.ts +41 -0
- package/dist/view/renderers/polygon/triangulator.js +3 -0
- package/dist/view/renderers/retained.d.ts +43 -0
- package/dist/view/renderers/retained.js +3 -0
- package/dist/view/renderers/stroke.d.ts +121 -0
- package/dist/view/renderers/stroke.js +621 -0
- package/dist/view/shaders/frame.d.ts +8 -0
- package/dist/view/shaders/frame.js +37 -0
- package/dist/view/shaders/helpers.d.ts +238 -0
- package/dist/view/shaders/helpers.js +611 -0
- package/dist/view/shaders/initializer.d.ts +27 -0
- package/dist/view/shaders/initializer.js +125 -0
- package/dist/view/shaders/projection.d.ts +123 -0
- package/dist/view/shaders/projection.js +299 -0
- package/dist/view/shaders/quad-grid.d.ts +77 -0
- package/dist/view/shaders/quad-grid.js +128 -0
- package/dist/view/shaders/quad.d.ts +189 -0
- package/dist/view/shaders/quad.js +582 -0
- package/dist/view/shaders/retained-origin.d.ts +50 -0
- package/dist/view/shaders/retained-origin.js +67 -0
- package/dist/view/shaders/terrain-shade.d.ts +23 -0
- package/dist/view/shaders/terrain-shade.js +93 -0
- package/dist/view/style-rule.d.ts +166 -0
- package/dist/view/style-rule.js +300 -0
- package/dist/view/terrain/anchor.d.ts +135 -0
- package/dist/view/terrain/anchor.js +226 -0
- package/dist/view/terrain/context.d.ts +132 -0
- package/dist/view/terrain/context.js +437 -0
- package/dist/view/terrain/dem-atlas.d.ts +97 -0
- package/dist/view/terrain/dem-atlas.js +534 -0
- package/dist/view/terrain/detect.d.ts +126 -0
- package/dist/view/terrain/detect.js +198 -0
- package/dist/view/terrain/drape/bin-store.d.ts +179 -0
- package/dist/view/terrain/drape/bin-store.js +529 -0
- package/dist/view/terrain/drape/binning.d.ts +259 -0
- package/dist/view/terrain/drape/binning.js +604 -0
- package/dist/view/terrain/drape/edge-constrain.d.ts +37 -0
- package/dist/view/terrain/drape/edge-constrain.js +175 -0
- package/dist/view/terrain/drape/geometry.d.ts +95 -0
- package/dist/view/terrain/drape/geometry.js +260 -0
- package/dist/view/terrain/drape/mesh.d.ts +50 -0
- package/dist/view/terrain/drape/mesh.js +86 -0
- package/dist/view/terrain/drape/pass.d.ts +122 -0
- package/dist/view/terrain/drape/pass.js +379 -0
- package/dist/view/terrain/drape/quad-glyphs.d.ts +64 -0
- package/dist/view/terrain/drape/quad-glyphs.js +117 -0
- package/dist/view/terrain/drape/quad.d.ts +249 -0
- package/dist/view/terrain/drape/quad.js +835 -0
- package/dist/view/terrain/drape/renderer.d.ts +184 -0
- package/dist/view/terrain/drape/renderer.js +706 -0
- package/dist/view/terrain/drape/shared.d.ts +80 -0
- package/dist/view/terrain/drape/shared.js +173 -0
- package/dist/view/terrain/drape/stitch.d.ts +155 -0
- package/dist/view/terrain/drape/stitch.js +228 -0
- package/dist/view/terrain/ground.d.ts +72 -0
- package/dist/view/terrain/ground.js +151 -0
- package/dist/view/terrain/metrics.d.ts +180 -0
- package/dist/view/terrain/metrics.js +231 -0
- package/dist/view/terrain/occlusion.d.ts +11 -0
- package/dist/view/terrain/occlusion.js +129 -0
- package/dist/view/terrain/polygon.d.ts +86 -0
- package/dist/view/terrain/polygon.js +301 -0
- package/dist/view/terrain/shade.d.ts +48 -0
- package/dist/view/terrain/shade.js +45 -0
- package/dist/view/terrain/state.d.ts +99 -0
- package/dist/view/terrain/state.js +186 -0
- package/dist/view/terrain/tessellation.d.ts +265 -0
- package/dist/view/terrain/tessellation.js +924 -0
- package/dist/view/terrain/tiling.d.ts +56 -0
- package/dist/view/terrain/tiling.js +155 -0
- package/dist/view/terrain/upstream-terrain.d.ts +82 -0
- package/dist/view/terrain/upstream-terrain.js +116 -0
- package/dist/view/ui/auxiliary-handles.d.ts +151 -0
- package/dist/view/ui/auxiliary-handles.js +22 -0
- package/dist/view/ui/bounds.d.ts +53 -0
- package/dist/view/ui/bounds.js +149 -0
- package/dist/view/ui/box-selection.d.ts +1 -0
- package/dist/view/ui/box-selection.js +83 -0
- package/dist/view/ui/handle-test.d.ts +1 -0
- package/dist/view/ui/handle-test.js +437 -0
- package/dist/view/ui/handle-thinning.d.ts +122 -0
- package/dist/view/ui/handle-thinning.js +430 -0
- package/dist/view/ui/handles.d.ts +25 -0
- package/dist/view/ui/handles.js +673 -0
- package/dist/view/ui/helper.d.ts +19 -0
- package/dist/view/ui/helper.js +76 -0
- package/dist/view/ui/index.d.ts +15 -0
- package/dist/view/ui/index.js +15 -0
- package/dist/view/ui/selection-scope.d.ts +25 -0
- package/dist/view/ui/selection-scope.js +34 -0
- package/dist/view/ui/selection-ui/bounding-box.d.ts +44 -0
- package/dist/view/ui/selection-ui/bounding-box.js +240 -0
- package/dist/view/ui/selection-ui/extension-registry.d.ts +76 -0
- package/dist/view/ui/selection-ui/extension-registry.js +78 -0
- package/dist/view/ui/selection-ui/index.d.ts +12 -0
- package/dist/view/ui/selection-ui/index.js +12 -0
- package/dist/view/ui/selection-ui/renderer.d.ts +29 -0
- package/dist/view/ui/selection-ui/renderer.js +227 -0
- package/dist/view/ui/selection-ui/types.d.ts +55 -0
- package/dist/view/ui/selection-ui/types.js +3 -0
- package/dist/view/ui/selection-ui-drawer.d.ts +52 -0
- package/dist/view/ui/selection-ui-drawer.js +329 -0
- package/dist/view/ui/tentative.d.ts +1 -0
- package/dist/view/ui/tentative.js +320 -0
- package/dist/view/viewport.d.ts +119 -0
- package/dist/view/viewport.js +254 -0
- package/package.json +113 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
import { segmentIntersection } from '../../geometry/split.js';
|
|
4
|
+
import { MESSAGES_EN } from '../../messages.js';
|
|
5
|
+
import { RBushSpatialIndex } from '../../store/spatial/spatial-index.js';
|
|
6
|
+
import { computeVertexHandles } from '../../view/ui/handles.js';
|
|
7
|
+
import { collectFeatureSegments, hasSnapEdges, isExcludedVertex, queryFeatures, segmentIntersectsBBox, } from './shared.js';
|
|
8
|
+
/**
|
|
9
|
+
* Whether the feature type is a target of vertex snapping
|
|
10
|
+
*
|
|
11
|
+
* It targets the point types in addition to the types that have edges. Types that do
|
|
12
|
+
* not originate from GeoJSON, such as Circle and Image, are out of scope.
|
|
13
|
+
*/
|
|
14
|
+
function hasSnapVertices(type) {
|
|
15
|
+
return hasSnapEdges(type) || type === 'Point' || type === 'MultiPoint';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds the snapping providers for datasets
|
|
19
|
+
*/
|
|
20
|
+
export function createDisplaySnapProviders(deps) {
|
|
21
|
+
const cache = new Map();
|
|
22
|
+
// The description of an intersection candidate (read by the status bar and the like)
|
|
23
|
+
const intersectionDescription = deps.messages?.snapIntersection ?? MESSAGES_EN.snapIntersection;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the cache entry of a dataset (building it when there is none)
|
|
26
|
+
*/
|
|
27
|
+
function entryOf(dataset) {
|
|
28
|
+
const cached = cache.get(dataset.id);
|
|
29
|
+
if (cached && cached.dataset === dataset)
|
|
30
|
+
return cached;
|
|
31
|
+
cached?.unsubscribe();
|
|
32
|
+
const entry = { dataset, built: null, unsubscribe: () => { } };
|
|
33
|
+
entry.unsubscribe = dataset.on('change', (payload) => {
|
|
34
|
+
// It is not rebuilt on a change of visibility or of style
|
|
35
|
+
if (payload.reason === 'features')
|
|
36
|
+
entry.built = null;
|
|
37
|
+
});
|
|
38
|
+
cache.set(dataset.id, entry);
|
|
39
|
+
return entry;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the index (rebuilding it when it was discarded)
|
|
43
|
+
*/
|
|
44
|
+
function indexOf(entry) {
|
|
45
|
+
if (entry.built)
|
|
46
|
+
return entry.built;
|
|
47
|
+
const index = new RBushSpatialIndex();
|
|
48
|
+
const byId = new Map();
|
|
49
|
+
for (const feature of entry.dataset.getFeatures()) {
|
|
50
|
+
index.insert(feature);
|
|
51
|
+
byId.set(feature.id, feature);
|
|
52
|
+
}
|
|
53
|
+
entry.built = { index, byId };
|
|
54
|
+
return entry.built;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Discards the cache of the datasets that were removed
|
|
58
|
+
*/
|
|
59
|
+
function prune(alive) {
|
|
60
|
+
for (const [id, entry] of cache) {
|
|
61
|
+
if (alive.has(id))
|
|
62
|
+
continue;
|
|
63
|
+
entry.unsubscribe();
|
|
64
|
+
cache.delete(id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Lists the snapping target features near the bbox
|
|
69
|
+
*
|
|
70
|
+
* ctx.excludeFeatureId / excludeVertex are not looked at. Both exist to keep a
|
|
71
|
+
* feature being edited in the Store from snapping to itself, and they have nothing
|
|
72
|
+
* to do with the features of datasets, which are never dragged.
|
|
73
|
+
*/
|
|
74
|
+
function nearbyFeatures(bbox) {
|
|
75
|
+
const datasets = deps.datasets.list();
|
|
76
|
+
prune(new Set(datasets.map((dataset) => dataset.id)));
|
|
77
|
+
const lng = (bbox.minX + bbox.maxX) / 2;
|
|
78
|
+
const lat = (bbox.minY + bbox.maxY) / 2;
|
|
79
|
+
// findNear queries a square extent, so the larger of the tolerances is used
|
|
80
|
+
const tolerance = Math.max(bbox.maxX - lng, bbox.maxY - lat);
|
|
81
|
+
const result = [];
|
|
82
|
+
for (const dataset of datasets) {
|
|
83
|
+
if (!dataset.visible)
|
|
84
|
+
continue;
|
|
85
|
+
// A feature that was not drawn because of collision thinning is not a snapping
|
|
86
|
+
// target either (a vertex being pulled towards a point that is not visible is a
|
|
87
|
+
// source of confusion, just as it is in hit testing)
|
|
88
|
+
const drawable = dataset.getVisibleFeatureIds();
|
|
89
|
+
const { index, byId } = indexOf(entryOf(dataset));
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
for (const id of index.findNear([lng, lat], tolerance)) {
|
|
92
|
+
if (seen.has(id))
|
|
93
|
+
continue;
|
|
94
|
+
seen.add(id);
|
|
95
|
+
const feature = byId.get(id);
|
|
96
|
+
if (!feature)
|
|
97
|
+
continue;
|
|
98
|
+
if (feature.visible === false)
|
|
99
|
+
continue;
|
|
100
|
+
if (drawable !== null && !drawable.has(feature.id))
|
|
101
|
+
continue;
|
|
102
|
+
result.push({ datasetId: dataset.id, feature });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Gathers the edges of the datasets that fall within the bbox
|
|
109
|
+
*/
|
|
110
|
+
function collectDisplaySegments(bbox) {
|
|
111
|
+
const groups = [];
|
|
112
|
+
for (const { datasetId, feature } of nearbyFeatures(bbox)) {
|
|
113
|
+
if (!hasSnapEdges(feature.type))
|
|
114
|
+
continue;
|
|
115
|
+
const segments = [];
|
|
116
|
+
collectFeatureSegments(feature, (start, end) => {
|
|
117
|
+
if (!segmentIntersectsBBox(start, end, bbox))
|
|
118
|
+
return;
|
|
119
|
+
segments.push({ start, end });
|
|
120
|
+
});
|
|
121
|
+
if (segments.length > 0)
|
|
122
|
+
groups.push({ datasetId, featureId: feature.id, segments });
|
|
123
|
+
}
|
|
124
|
+
return groups;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Gathers the edges of the Store that fall within the bbox (the counterpart of an
|
|
128
|
+
* intersection)
|
|
129
|
+
*/
|
|
130
|
+
function collectStoreSegments(bbox, ctx) {
|
|
131
|
+
const groups = [];
|
|
132
|
+
for (const feature of queryFeatures({ store: deps.store, spatialIndex: deps.spatialIndex, snapTargets: deps.snapTargets }, bbox, ctx)) {
|
|
133
|
+
// The candidates of a custom type are returned by the vertex provider
|
|
134
|
+
// (getSnapTargets)
|
|
135
|
+
if (deps.snapTargets?.get(feature.type))
|
|
136
|
+
continue;
|
|
137
|
+
if (!hasSnapEdges(feature.type))
|
|
138
|
+
continue;
|
|
139
|
+
const segments = [];
|
|
140
|
+
collectFeatureSegments(feature, (start, end, startRef, endRef) => {
|
|
141
|
+
if (!segmentIntersectsBBox(start, end, bbox))
|
|
142
|
+
return;
|
|
143
|
+
if (isExcludedVertex(feature.id, startRef, ctx))
|
|
144
|
+
return;
|
|
145
|
+
if (isExcludedVertex(feature.id, endRef, ctx))
|
|
146
|
+
return;
|
|
147
|
+
segments.push({ start, end });
|
|
148
|
+
});
|
|
149
|
+
if (segments.length > 0)
|
|
150
|
+
groups.push({ featureId: feature.id, segments });
|
|
151
|
+
}
|
|
152
|
+
return groups;
|
|
153
|
+
}
|
|
154
|
+
const vertexProvider = {
|
|
155
|
+
name: 'core:display-vertex',
|
|
156
|
+
candidates(bbox) {
|
|
157
|
+
if (!deps.isEnabled())
|
|
158
|
+
return [];
|
|
159
|
+
const candidates = [];
|
|
160
|
+
for (const { datasetId, feature } of nearbyFeatures(bbox)) {
|
|
161
|
+
if (!hasSnapVertices(feature.type))
|
|
162
|
+
continue;
|
|
163
|
+
for (const handle of computeVertexHandles(feature)) {
|
|
164
|
+
const candidate = {
|
|
165
|
+
kind: 'vertex',
|
|
166
|
+
coordinate: handle.position,
|
|
167
|
+
featureId: feature.id,
|
|
168
|
+
datasetId,
|
|
169
|
+
vertex: handle.vertexRef,
|
|
170
|
+
};
|
|
171
|
+
candidates.push(candidate);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return candidates;
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
const edgeProvider = {
|
|
178
|
+
name: 'core:display-edge',
|
|
179
|
+
candidates(bbox) {
|
|
180
|
+
if (!deps.isEnabled())
|
|
181
|
+
return [];
|
|
182
|
+
const candidates = [];
|
|
183
|
+
for (const { datasetId, feature } of nearbyFeatures(bbox)) {
|
|
184
|
+
if (!hasSnapEdges(feature.type))
|
|
185
|
+
continue;
|
|
186
|
+
collectFeatureSegments(feature, (start, end, startRef, endRef) => {
|
|
187
|
+
if (!segmentIntersectsBBox(start, end, bbox))
|
|
188
|
+
return;
|
|
189
|
+
const candidate = {
|
|
190
|
+
kind: 'edge',
|
|
191
|
+
start,
|
|
192
|
+
end,
|
|
193
|
+
startRef,
|
|
194
|
+
endRef,
|
|
195
|
+
featureId: feature.id,
|
|
196
|
+
datasetId,
|
|
197
|
+
};
|
|
198
|
+
candidates.push(candidate);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return candidates;
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
const intersectionProvider = {
|
|
205
|
+
name: 'core:display-intersection',
|
|
206
|
+
candidates(bbox, ctx) {
|
|
207
|
+
if (!deps.isEnabled())
|
|
208
|
+
return [];
|
|
209
|
+
const displayGroups = collectDisplaySegments(bbox);
|
|
210
|
+
if (displayGroups.length === 0)
|
|
211
|
+
return [];
|
|
212
|
+
const storeGroups = collectStoreSegments(bbox, ctx);
|
|
213
|
+
if (displayGroups.length < 2 && storeGroups.length === 0)
|
|
214
|
+
return [];
|
|
215
|
+
const candidates = [];
|
|
216
|
+
const seen = new Set();
|
|
217
|
+
/** Makes the intersections of the segments of 2 features into candidates (the
|
|
218
|
+
* origin is the display side) */
|
|
219
|
+
const intersect = (source, other) => {
|
|
220
|
+
for (const a of source.segments) {
|
|
221
|
+
for (const b of other.segments) {
|
|
222
|
+
const point = segmentIntersection(a.start, a.end, b.start, b.end);
|
|
223
|
+
if (point === null)
|
|
224
|
+
continue;
|
|
225
|
+
// The same point can come out of several pairs, so they are merged into one
|
|
226
|
+
const key = `${point[0]},${point[1]}`;
|
|
227
|
+
if (seen.has(key))
|
|
228
|
+
continue;
|
|
229
|
+
seen.add(key);
|
|
230
|
+
const candidate = {
|
|
231
|
+
kind: 'intersection',
|
|
232
|
+
coordinate: point,
|
|
233
|
+
featureId: source.featureId,
|
|
234
|
+
datasetId: source.datasetId,
|
|
235
|
+
description: intersectionDescription,
|
|
236
|
+
};
|
|
237
|
+
candidates.push(candidate);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
for (let i = 0; i < displayGroups.length; i++) {
|
|
242
|
+
for (let j = i + 1; j < displayGroups.length; j++) {
|
|
243
|
+
intersect(displayGroups[i], displayGroups[j]);
|
|
244
|
+
}
|
|
245
|
+
for (const group of storeGroups) {
|
|
246
|
+
intersect(displayGroups[i], group);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return candidates;
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
return {
|
|
253
|
+
providers: [vertexProvider, edgeProvider, intersectionProvider],
|
|
254
|
+
queryFeatures(bbox) {
|
|
255
|
+
return nearbyFeatures(bbox).map((entry) => entry.feature);
|
|
256
|
+
},
|
|
257
|
+
getFeature(datasetId, featureId) {
|
|
258
|
+
const dataset = deps.datasets.get(datasetId);
|
|
259
|
+
if (!dataset) {
|
|
260
|
+
const stale = cache.get(datasetId);
|
|
261
|
+
stale?.unsubscribe();
|
|
262
|
+
cache.delete(datasetId);
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
return indexOf(entryOf(dataset)).byId.get(featureId) ?? null;
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type Messages } from '../../messages.js';
|
|
2
|
+
import type { Store } from '../../store/store.js';
|
|
3
|
+
import { type SnapProvider } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The dependencies of {@link createGuideSnapProvider}.
|
|
6
|
+
*
|
|
7
|
+
* The guides are built from the vertices committed so far in the drawing in progress, so the
|
|
8
|
+
* Store alone is enough.
|
|
9
|
+
*/
|
|
10
|
+
export interface GuideSnapProviderDeps {
|
|
11
|
+
/** The Store of the draw instance, such as `ctx.getStore()` of a plugin */
|
|
12
|
+
store: Store;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The options of {@link createGuideSnapProvider}.
|
|
16
|
+
*/
|
|
17
|
+
export interface GuideSnapProviderOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The step angle of the north-based guides in degrees (default: 45, which gives 8 guides).
|
|
20
|
+
* 0, a negative value or a non-finite value gives the default
|
|
21
|
+
*/
|
|
22
|
+
northStepDegrees?: number;
|
|
23
|
+
/** The tile size in px the map uses, to convert px into degrees (default: 512) */
|
|
24
|
+
tileSize?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The messages table the descriptions of the candidates come from (`snapNorth`,
|
|
27
|
+
* `snapExtension`, `snapPerpendicular`; default: `MESSAGES_EN`)
|
|
28
|
+
*/
|
|
29
|
+
messages?: Partial<Messages>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a snapping provider of construction guides for `draw_line` and `draw_polygon`.
|
|
33
|
+
*
|
|
34
|
+
* The guides start at the last committed vertex (the anchor): the north-based guides at every
|
|
35
|
+
* `northStepDegrees` from true north (from the first vertex on), and the extension and the
|
|
36
|
+
* perpendiculars of the previous segment (from the second vertex on). Each guide is a
|
|
37
|
+
* segment 4096 screen px long, returned as a candidate of kind `'guide'` whose description
|
|
38
|
+
* comes from `messages` (`snapNorth`, `snapExtension`, `snapPerpendicular`). Outside those
|
|
39
|
+
* two modes it returns no candidates.
|
|
40
|
+
*
|
|
41
|
+
* The draw instance already registers a built-in one, whose step is set with
|
|
42
|
+
* `options.snap.guideStepDegrees` and changed at runtime with `draw.snapping.setGuideStep`.
|
|
43
|
+
* Register another one to add guides at a second step on top of the built-in ones.
|
|
44
|
+
*
|
|
45
|
+
* @param deps The Store to read the drawing in progress from
|
|
46
|
+
* @param options The step angle, the tile size and the messages
|
|
47
|
+
* @returns A provider to pass to `draw.snapping.register`
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { createGuideSnapProvider, type Plugin } from '@sakuzu/maplibre-gl-draw';
|
|
52
|
+
*
|
|
53
|
+
* // Guides every 15 degrees from north, in addition to the built-in ones
|
|
54
|
+
* let unregister: (() => void) | undefined;
|
|
55
|
+
* const fineGuides: Plugin = {
|
|
56
|
+
* name: 'fine-guides',
|
|
57
|
+
* onInstall(ctx) {
|
|
58
|
+
* unregister = draw.snapping.register(
|
|
59
|
+
* createGuideSnapProvider({ store: ctx.getStore() }, { northStepDegrees: 15 }),
|
|
60
|
+
* );
|
|
61
|
+
* },
|
|
62
|
+
* onUninstall() {
|
|
63
|
+
* unregister?.();
|
|
64
|
+
* },
|
|
65
|
+
* };
|
|
66
|
+
* draw.addPlugin(fineGuides);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function createGuideSnapProvider(deps: GuideSnapProviderDeps, options?: GuideSnapProviderOptions): SnapProvider;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
/**
|
|
4
|
+
* Built-in snapping provider (construction guides)
|
|
5
|
+
*
|
|
6
|
+
* It works only while drawing (draw_line / draw_polygon); it reads the confirmed
|
|
7
|
+
* vertices from the Tentative of the Store and returns the guides as segment
|
|
8
|
+
* candidates with kind: 'guide'. Because they are segment candidates, the
|
|
9
|
+
* computation of the point closest to the cursor can be left to SnapService.
|
|
10
|
+
*
|
|
11
|
+
* It produces 3 kinds of guides.
|
|
12
|
+
*
|
|
13
|
+
* Extension Forward from the anchor along the bearing of the previous segment
|
|
14
|
+
* (2 or more confirmed points)
|
|
15
|
+
* Perpendicular At the bearing of the previous segment +-90 degrees, to both
|
|
16
|
+
* sides of the anchor (2 or more confirmed points)
|
|
17
|
+
* North-based Towards every bearing at each step angle, starting from true
|
|
18
|
+
* north at 0 degrees (1 or more confirmed points)
|
|
19
|
+
*
|
|
20
|
+
* Only the north-based guide works from the very first segment. The built-in provider
|
|
21
|
+
* reads the step angle from SnapOptions.guideStepDegrees at every query (through a
|
|
22
|
+
* getter), so a change at runtime takes effect without rebuilding the provider. A
|
|
23
|
+
* provider made with createGuideSnapProvider keeps the step it was built with.
|
|
24
|
+
*
|
|
25
|
+
* A guide is not an infinite line; it is cut off at the equivalent of 4096 pixels on
|
|
26
|
+
* screen. The priority order stays SNAP_KIND_PRIORITY, so a real vertex,
|
|
27
|
+
* intersection or edge wins when it is within the tolerance.
|
|
28
|
+
*/
|
|
29
|
+
import { getPointAtAngle } from '../../geometry/angle.js';
|
|
30
|
+
import { initialBearingDegrees } from '../../geometry/distance.js';
|
|
31
|
+
import { EARTH_RADIUS_METERS, toRadians } from '../../geometry/units.js';
|
|
32
|
+
import { resolveMessages } from '../../messages.js';
|
|
33
|
+
import { DEFAULT_TILE_SIZE } from '../../shared/math/index.js';
|
|
34
|
+
import { degreesPerPixel } from '../geometry.js';
|
|
35
|
+
import { resolveGuideStepDegrees, } from '../types.js';
|
|
36
|
+
/** The drawing modes that produce guides */
|
|
37
|
+
const GUIDE_MODES = new Set(['draw_line', 'draw_polygon']);
|
|
38
|
+
/** The length of a guide (pixels). The cut-off that keeps it from being an infinite line */
|
|
39
|
+
const GUIDE_LENGTH_PIXELS = 4096;
|
|
40
|
+
/**
|
|
41
|
+
* Takes the confirmed vertices out of the Tentative
|
|
42
|
+
*
|
|
43
|
+
* For a line it is the first confirmedCount items of the coordinate sequence. For a
|
|
44
|
+
* polygon it is the first confirmedCount items of the closed ring. The first point of
|
|
45
|
+
* a polygon has type 'Point' because it is shown as a marker (in that case there is
|
|
46
|
+
* no confirmedCount, and that single point is the confirmed one).
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export function getConfirmedTentativeVertices(tentative) {
|
|
51
|
+
switch (tentative.type) {
|
|
52
|
+
case 'Point':
|
|
53
|
+
return [tentative.coordinates];
|
|
54
|
+
case 'LineString': {
|
|
55
|
+
const coords = tentative.coordinates;
|
|
56
|
+
const count = tentative.confirmedCount ?? coords.length;
|
|
57
|
+
return coords.slice(0, Math.max(0, Math.min(count, coords.length)));
|
|
58
|
+
}
|
|
59
|
+
case 'Polygon': {
|
|
60
|
+
const ring = tentative.coordinates[0];
|
|
61
|
+
if (!ring || ring.length === 0)
|
|
62
|
+
return [];
|
|
63
|
+
// It is a closed ring, so the last item is a copy of the first one. When there is
|
|
64
|
+
// no confirmedCount, the closing point is excluded
|
|
65
|
+
const count = tentative.confirmedCount ?? ring.length - 1;
|
|
66
|
+
return ring.slice(0, Math.max(0, Math.min(count, ring.length)));
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Computes the length of a guide (meters)
|
|
74
|
+
*
|
|
75
|
+
* The equivalent of GUIDE_LENGTH_PIXELS on screen is converted into degrees in the
|
|
76
|
+
* latitude direction, and that is converted into meters (because getPointAtAngle
|
|
77
|
+
* takes the distance in meters).
|
|
78
|
+
*/
|
|
79
|
+
function guideLengthMeters(anchor, zoom, tileSize) {
|
|
80
|
+
const perPixel = degreesPerPixel(anchor[1], zoom, tileSize);
|
|
81
|
+
const degrees = perPixel.lat * GUIDE_LENGTH_PIXELS;
|
|
82
|
+
return toRadians(degrees) * EARTH_RADIUS_METERS;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Builds a segment candidate extended from the anchor towards the bearing
|
|
86
|
+
*
|
|
87
|
+
* When backwardBearing is given, it becomes a single segment extended towards that
|
|
88
|
+
* side as well (a guide on both sides passing through the anchor).
|
|
89
|
+
*/
|
|
90
|
+
function guideSegment(anchor, lengthMeters, bearing, description, backwardBearing) {
|
|
91
|
+
return {
|
|
92
|
+
kind: 'guide',
|
|
93
|
+
start: backwardBearing === undefined
|
|
94
|
+
? [anchor[0], anchor[1]]
|
|
95
|
+
: getPointAtAngle(anchor, lengthMeters, backwardBearing),
|
|
96
|
+
end: getPointAtAngle(anchor, lengthMeters, bearing),
|
|
97
|
+
description,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates a snapping provider of construction guides for `draw_line` and `draw_polygon`.
|
|
102
|
+
*
|
|
103
|
+
* The guides start at the last committed vertex (the anchor): the north-based guides at every
|
|
104
|
+
* `northStepDegrees` from true north (from the first vertex on), and the extension and the
|
|
105
|
+
* perpendiculars of the previous segment (from the second vertex on). Each guide is a
|
|
106
|
+
* segment 4096 screen px long, returned as a candidate of kind `'guide'` whose description
|
|
107
|
+
* comes from `messages` (`snapNorth`, `snapExtension`, `snapPerpendicular`). Outside those
|
|
108
|
+
* two modes it returns no candidates.
|
|
109
|
+
*
|
|
110
|
+
* The draw instance already registers a built-in one, whose step is set with
|
|
111
|
+
* `options.snap.guideStepDegrees` and changed at runtime with `draw.snapping.setGuideStep`.
|
|
112
|
+
* Register another one to add guides at a second step on top of the built-in ones.
|
|
113
|
+
*
|
|
114
|
+
* @param deps The Store to read the drawing in progress from
|
|
115
|
+
* @param options The step angle, the tile size and the messages
|
|
116
|
+
* @returns A provider to pass to `draw.snapping.register`
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { createGuideSnapProvider, type Plugin } from '@sakuzu/maplibre-gl-draw';
|
|
121
|
+
*
|
|
122
|
+
* // Guides every 15 degrees from north, in addition to the built-in ones
|
|
123
|
+
* let unregister: (() => void) | undefined;
|
|
124
|
+
* const fineGuides: Plugin = {
|
|
125
|
+
* name: 'fine-guides',
|
|
126
|
+
* onInstall(ctx) {
|
|
127
|
+
* unregister = draw.snapping.register(
|
|
128
|
+
* createGuideSnapProvider({ store: ctx.getStore() }, { northStepDegrees: 15 }),
|
|
129
|
+
* );
|
|
130
|
+
* },
|
|
131
|
+
* onUninstall() {
|
|
132
|
+
* unregister?.();
|
|
133
|
+
* },
|
|
134
|
+
* };
|
|
135
|
+
* draw.addPlugin(fineGuides);
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export function createGuideSnapProvider(deps, options = {}) {
|
|
139
|
+
const step = resolveGuideStepDegrees(options.northStepDegrees);
|
|
140
|
+
return createSteppedGuideSnapProvider(deps, () => step, options);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Creates the guide provider whose step angle is read through a getter at every query
|
|
144
|
+
* (the built-in provider reads the current `guideStepDegrees` of the SnapService this way)
|
|
145
|
+
*
|
|
146
|
+
* @param deps The Store to read the drawing in progress from
|
|
147
|
+
* @param getNorthStepDegrees Returns the step angle; an invalid value gives the default
|
|
148
|
+
* @param options The tile size and the messages (`northStepDegrees` is ignored)
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
export function createSteppedGuideSnapProvider(deps, getNorthStepDegrees, options = {}) {
|
|
152
|
+
const tileSize = options.tileSize ?? DEFAULT_TILE_SIZE;
|
|
153
|
+
// The descriptions of the candidates (read by the status bar and the like)
|
|
154
|
+
const messages = resolveMessages(options.messages);
|
|
155
|
+
return {
|
|
156
|
+
name: 'core:guide',
|
|
157
|
+
candidates(_bbox, ctx) {
|
|
158
|
+
if (!GUIDE_MODES.has(deps.store.getMode()))
|
|
159
|
+
return [];
|
|
160
|
+
const tentative = deps.store.getTentative();
|
|
161
|
+
if (!tentative)
|
|
162
|
+
return [];
|
|
163
|
+
const confirmed = getConfirmedTentativeVertices(tentative);
|
|
164
|
+
if (confirmed.length === 0)
|
|
165
|
+
return [];
|
|
166
|
+
const anchor = confirmed[confirmed.length - 1];
|
|
167
|
+
const lengthMeters = guideLengthMeters(anchor, ctx.zoom, tileSize);
|
|
168
|
+
const candidates = [];
|
|
169
|
+
const step = resolveGuideStepDegrees(getNorthStepDegrees());
|
|
170
|
+
// North-based: every bearing at each step angle, starting from true north. The
|
|
171
|
+
// only guide that works from the very first segment
|
|
172
|
+
for (let bearing = 0; bearing < 360; bearing += step) {
|
|
173
|
+
candidates.push(guideSegment(anchor, lengthMeters, bearing, messages.snapNorth));
|
|
174
|
+
}
|
|
175
|
+
if (confirmed.length >= 2) {
|
|
176
|
+
const previous = confirmed[confirmed.length - 2];
|
|
177
|
+
const bearing = initialBearingDegrees(previous, anchor);
|
|
178
|
+
// Extension: forward along the bearing of the previous segment
|
|
179
|
+
candidates.push(guideSegment(anchor, lengthMeters, bearing, messages.snapExtension));
|
|
180
|
+
// Perpendicular: the bearing of the previous segment +-90 degrees. Merged into a
|
|
181
|
+
// single line passing through the anchor
|
|
182
|
+
candidates.push(guideSegment(anchor, lengthMeters, (bearing + 90) % 360, messages.snapPerpendicular, (bearing + 270) % 360));
|
|
183
|
+
}
|
|
184
|
+
return candidates;
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
/**
|
|
4
|
+
* Built-in snapping provider (intersections between edges)
|
|
5
|
+
*
|
|
6
|
+
* It gathers the edges that fall near the cursor (within the bbox of the tolerance)
|
|
7
|
+
* and returns the intersections of pairs of segments from different features as
|
|
8
|
+
* point candidates with kind: 'intersection'. Self-intersections within the same
|
|
9
|
+
* feature are out of scope (a self-intersecting polygon is an invalid shape, and
|
|
10
|
+
* there is no demand for snapping to the self-intersection point of a polyline).
|
|
11
|
+
*
|
|
12
|
+
* The bbox is the size of the tolerance (10px by default), so the number of edges
|
|
13
|
+
* that fall within it stays at a few. Combining them by brute force is small enough,
|
|
14
|
+
* so no dedicated index is kept.
|
|
15
|
+
*
|
|
16
|
+
* The rules of exclusion are the same as for the vertex and edge providers: the
|
|
17
|
+
* edges of an excluded feature and the edges touching the vertex being dragged are
|
|
18
|
+
* not used in the computation of the intersections.
|
|
19
|
+
*/
|
|
20
|
+
import { segmentIntersection } from '../../geometry/split.js';
|
|
21
|
+
import { MESSAGES_EN } from '../../messages.js';
|
|
22
|
+
import { collectFeatureSegmentsInBBox, hasSnapEdges, isExcludedVertex, queryFeatures, segmentIntersectsBBox, } from './shared.js';
|
|
23
|
+
/**
|
|
24
|
+
* Gathers the edges that fall within the bbox, per feature
|
|
25
|
+
*/
|
|
26
|
+
function collectNearbySegments(deps, bbox, ctx) {
|
|
27
|
+
const result = [];
|
|
28
|
+
for (const feature of queryFeatures(deps, bbox, ctx)) {
|
|
29
|
+
// The candidates of a custom type are returned by the vertex provider
|
|
30
|
+
// (getSnapTargets)
|
|
31
|
+
if (deps.snapTargets?.get(feature.type))
|
|
32
|
+
continue;
|
|
33
|
+
if (!hasSnapEdges(feature.type))
|
|
34
|
+
continue;
|
|
35
|
+
const segments = [];
|
|
36
|
+
collectFeatureSegmentsInBBox(feature, bbox, (start, end, startRef, endRef) => {
|
|
37
|
+
if (!segmentIntersectsBBox(start, end, bbox))
|
|
38
|
+
return;
|
|
39
|
+
if (isExcludedVertex(feature.id, startRef, ctx))
|
|
40
|
+
return;
|
|
41
|
+
if (isExcludedVertex(feature.id, endRef, ctx))
|
|
42
|
+
return;
|
|
43
|
+
segments.push({ start, end });
|
|
44
|
+
});
|
|
45
|
+
if (segments.length > 0)
|
|
46
|
+
result.push({ featureId: feature.id, segments });
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Builds the intersection provider for the Store
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export function createStoreIntersectionSnapProvider(deps) {
|
|
56
|
+
// The description of the candidates (read by the status bar and the like)
|
|
57
|
+
const description = deps.messages?.snapIntersection ?? MESSAGES_EN.snapIntersection;
|
|
58
|
+
return {
|
|
59
|
+
name: 'core:store-intersection',
|
|
60
|
+
candidates(bbox, ctx) {
|
|
61
|
+
const nearby = collectNearbySegments(deps, bbox, ctx);
|
|
62
|
+
if (nearby.length < 2)
|
|
63
|
+
return [];
|
|
64
|
+
const candidates = [];
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
for (let i = 0; i < nearby.length; i++) {
|
|
67
|
+
for (let j = i + 1; j < nearby.length; j++) {
|
|
68
|
+
for (const a of nearby[i].segments) {
|
|
69
|
+
for (const b of nearby[j].segments) {
|
|
70
|
+
const point = segmentIntersection(a.start, a.end, b.start, b.end);
|
|
71
|
+
if (point === null)
|
|
72
|
+
continue;
|
|
73
|
+
// The same point can come out of several pairs, so they are merged into one
|
|
74
|
+
const key = `${point[0]},${point[1]}`;
|
|
75
|
+
if (seen.has(key))
|
|
76
|
+
continue;
|
|
77
|
+
seen.add(key);
|
|
78
|
+
const candidate = {
|
|
79
|
+
kind: 'intersection',
|
|
80
|
+
coordinate: point,
|
|
81
|
+
featureId: nearby[i].featureId,
|
|
82
|
+
description,
|
|
83
|
+
};
|
|
84
|
+
candidates.push(candidate);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return candidates;
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Store } from '../../store/store.js';
|
|
2
|
+
import type { BoundingBox, Coordinate, Feature, VertexRef } from '../../store/types.js';
|
|
3
|
+
import type { SnapProviderContext } from '../types.js';
|
|
4
|
+
export type { SegmentVisitor } from '../../shared/utils/feature-segments.js';
|
|
5
|
+
export { collectFeatureSegments, collectFeatureSegmentsInBBox, hasSnapEdges, segmentIntersectsBBox, } from '../../shared/utils/feature-segments.js';
|
|
6
|
+
/**
|
|
7
|
+
* Whether the feature is a snapping target (whether it is displayed)
|
|
8
|
+
*
|
|
9
|
+
* It looks at both the shared visible cascade (feature / group / layer) and the local
|
|
10
|
+
* hiding that applies to this client only.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSnapVisible(feature: Feature, store: Store): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Lists the candidate features near the bbox
|
|
15
|
+
*/
|
|
16
|
+
export declare function queryFeatures(deps: StoreSnapProviderDeps, bbox: BoundingBox, ctx: SnapProviderContext): Feature[];
|
|
17
|
+
/**
|
|
18
|
+
* Whether the vertex is to be excluded
|
|
19
|
+
*/
|
|
20
|
+
export declare function isExcludedVertex(featureId: string, vertex: VertexRef | undefined, ctx: SnapProviderContext): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* A vertex candidate limited to the bbox
|
|
23
|
+
*/
|
|
24
|
+
export interface VertexCandidate {
|
|
25
|
+
position: Coordinate;
|
|
26
|
+
vertexRef: VertexRef;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Gathers the vertices of a feature that are inside the bbox
|
|
30
|
+
*
|
|
31
|
+
* The bbox is the cursor position +- the tolerance (in longitude and in latitude),
|
|
32
|
+
* and the distance test of SnapService measures the pixel distance with the same
|
|
33
|
+
* conversion. A vertex outside the bbox can therefore never be inside the tolerance,
|
|
34
|
+
* and discarding it here does not change the candidates.
|
|
35
|
+
*
|
|
36
|
+
* For types without edges (Point / MultiPoint / custom types), the full listing of
|
|
37
|
+
* computeVertexHandles is simply narrowed down by the bbox, as before.
|
|
38
|
+
*/
|
|
39
|
+
export declare function collectVertexCandidatesInBBox(feature: Feature, bbox: BoundingBox): VertexCandidate[];
|