@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,950 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data model: coordinates, features, layers, groups and the state the Store holds
|
|
3
|
+
*
|
|
4
|
+
* Types only. They sit in shared/ so that every layer can use them (store/types.ts
|
|
5
|
+
* re-exports them).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A position as `[longitude, latitude]` in degrees (WGS 84), in the same order as GeoJSON
|
|
9
|
+
*/
|
|
10
|
+
export type Coordinate = [number, number];
|
|
11
|
+
/**
|
|
12
|
+
* The coordinates of a feature, nested as deep as its type needs
|
|
13
|
+
*
|
|
14
|
+
* The nesting depth of the array expresses the structure of the geometry. It follows the
|
|
15
|
+
* `coordinates` of the GeoJSON geometry of the same name.
|
|
16
|
+
*
|
|
17
|
+
* - `Coordinate`: Point, Image (the anchor of the image) and Circle (the center; the radius
|
|
18
|
+
* is `properties.radiusMeters`)
|
|
19
|
+
* - `Coordinate[]`: LineString, Freehand and MultiPoint (a sequence of coordinates)
|
|
20
|
+
* - `Coordinate[][]`: Polygon (an array of rings: ring 0 is the outer ring, the rest are
|
|
21
|
+
* holes) and MultiLineString (an array of lines)
|
|
22
|
+
* - `Coordinate[][][]`: MultiPolygon (an array of polygons, each an array of rings)
|
|
23
|
+
*
|
|
24
|
+
* A ring of a Polygon is closed: its last coordinate repeats its first.
|
|
25
|
+
*/
|
|
26
|
+
export type FeatureCoordinates = Coordinate | Coordinate[] | Coordinate[][] | Coordinate[][][];
|
|
27
|
+
/**
|
|
28
|
+
* The type of a feature: one of the nine built-in types, or the name of a custom type
|
|
29
|
+
*
|
|
30
|
+
* The built-in types are Point, LineString, Polygon, MultiPoint, MultiLineString,
|
|
31
|
+
* MultiPolygon, Image, Circle and Freehand. The type decides the shape of
|
|
32
|
+
* `Feature.coordinates` ({@link FeatureCoordinates}). Any other string names a custom type,
|
|
33
|
+
* which an extension adds with `registerFeatureHandler` ({@link CustomFeatureHandler}).
|
|
34
|
+
*
|
|
35
|
+
* The Multi types come from imports and from the results of geometry operations; no drawing
|
|
36
|
+
* mode creates them.
|
|
37
|
+
*/
|
|
38
|
+
export type FeatureType = 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'Image' | 'Circle' | 'Freehand' | (string & {});
|
|
39
|
+
/**
|
|
40
|
+
* The name of an interaction mode: one of the seven built-in modes, or a custom mode
|
|
41
|
+
*
|
|
42
|
+
* `select` selects and edits features, and each `draw_*` mode creates one feature type
|
|
43
|
+
* (`draw_line` creates a LineString). Any other string names a custom mode, registered with
|
|
44
|
+
* `registerMode` or {@link Plugin.modes}.
|
|
45
|
+
*/
|
|
46
|
+
export type Mode = 'select' | 'draw_point' | 'draw_line' | 'draw_polygon' | 'draw_image' | 'draw_circle' | 'draw_freehand' | (string & {});
|
|
47
|
+
/**
|
|
48
|
+
* What the selection holds: features, groups or layers
|
|
49
|
+
*
|
|
50
|
+
* The selection is exclusive: it holds items of one type at a time.
|
|
51
|
+
*/
|
|
52
|
+
export type SelectionType = 'feature' | 'group' | 'layer';
|
|
53
|
+
/**
|
|
54
|
+
* The current selection: its type and the IDs of the selected items
|
|
55
|
+
*/
|
|
56
|
+
export interface Selection {
|
|
57
|
+
/** Selection type (null means nothing is selected) */
|
|
58
|
+
type: SelectionType | null;
|
|
59
|
+
/** IDs of the selected items */
|
|
60
|
+
ids: string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Vertex reference
|
|
64
|
+
*
|
|
65
|
+
* Points at a single vertex with the triple of part number, ring number and the
|
|
66
|
+
* vertex index within the ring.
|
|
67
|
+
* A Polygon can have inner rings (holes), so a vertex is always specified in this form.
|
|
68
|
+
* For LineString / Point, which have no rings, ring is always 0.
|
|
69
|
+
*
|
|
70
|
+
* part points at the part of the Multi kinds (MultiPoint / MultiLineString /
|
|
71
|
+
* MultiPolygon). When omitted it is interpreted as 0, so for single geometries that
|
|
72
|
+
* have no parts it is still enough to write just `{ ring, index }` as before.
|
|
73
|
+
* Use the functions in shared/utils/vertex-ref for comparison and lookup (they treat
|
|
74
|
+
* undefined and 0 as the same).
|
|
75
|
+
*/
|
|
76
|
+
export interface VertexRef {
|
|
77
|
+
/**
|
|
78
|
+
* Part number (MultiPoint: the number of the coordinate, MultiLineString: the number
|
|
79
|
+
* of the line, MultiPolygon: the number of the polygon. 0 for single geometries).
|
|
80
|
+
* Omitted means 0.
|
|
81
|
+
*/
|
|
82
|
+
part?: number;
|
|
83
|
+
/** Ring number (Polygon: 0 = outer ring, 1 and later = inner rings. 0 for LineString / Point) */
|
|
84
|
+
ring: number;
|
|
85
|
+
/** Vertex index within the ring */
|
|
86
|
+
index: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The selected vertices of one feature
|
|
90
|
+
*
|
|
91
|
+
* Several vertices of a single feature can be selected at once, to move or delete them
|
|
92
|
+
* together. It is local state of this client, like the selection.
|
|
93
|
+
*/
|
|
94
|
+
export interface VertexSelection {
|
|
95
|
+
/** The ID of the feature whose vertices are selected */
|
|
96
|
+
featureId: string;
|
|
97
|
+
/** The selected vertices */
|
|
98
|
+
vertexIndices: VertexRef[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The style a feature carries in `Feature.style`, overriding the defaults key by key
|
|
102
|
+
*
|
|
103
|
+
* Every key is optional. A color key left unset takes the color of the layer's style rule
|
|
104
|
+
* ({@link StyleRule}) when the layer has one, and any other key left unset takes the default
|
|
105
|
+
* of the `style` option ({@link FeatureStyleConfig}). The precedence is "the feature's own key
|
|
106
|
+
* > the layer's style rule > the default". Colors are `#rgb` or `#rrggbb`.
|
|
107
|
+
*
|
|
108
|
+
* Each feature type reads its own keys:
|
|
109
|
+
*
|
|
110
|
+
* | Feature types | Keys |
|
|
111
|
+
* | --- | --- |
|
|
112
|
+
* | Point, MultiPoint | pointColor, pointRadius, pointShape |
|
|
113
|
+
* | LineString, MultiLineString, Freehand | strokeColor, strokeOpacity, strokeWidth, lineStyle |
|
|
114
|
+
* | Polygon, MultiPolygon, Circle | the stroke keys, fillColor, fillOpacity |
|
|
115
|
+
* | Image | imageOpacity and the keys of {@link ImageStyle} |
|
|
116
|
+
*
|
|
117
|
+
* On import each key is validated and a key that fails is dropped.
|
|
118
|
+
*
|
|
119
|
+
* A key this type does not define is kept as it is, whatever its value: it is stored,
|
|
120
|
+
* synchronized, exported and loaded back like the keys above, and core does not read it. An
|
|
121
|
+
* extension or a host gives features style keys of its own this way. It declares them with
|
|
122
|
+
* declaration merging and checks their values where it reads them, since a value can also
|
|
123
|
+
* arrive through `updateFeature` or a replaced store without an import.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* draw.updateFeature(id, {
|
|
128
|
+
* style: { strokeColor: '#0055ff', strokeWidth: 4, lineStyle: 'dashed' },
|
|
129
|
+
* });
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @example A style key of an extension
|
|
133
|
+
* ```ts
|
|
134
|
+
* declare module '@sakuzu/maplibre-gl-draw' {
|
|
135
|
+
* interface FeatureStyle {
|
|
136
|
+
* markerLabel?: string;
|
|
137
|
+
* }
|
|
138
|
+
* }
|
|
139
|
+
*
|
|
140
|
+
* // In the extension's renderer: check the value before using it
|
|
141
|
+
* const label = feature.style?.markerLabel;
|
|
142
|
+
* if (typeof label === 'string') drawLabel(label);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export interface FeatureStyle {
|
|
146
|
+
/**
|
|
147
|
+
* The fill color of a polygon
|
|
148
|
+
*
|
|
149
|
+
* @defaultValue `'#FF0077'` (`polygon.fill` of {@link FeatureStyleConfig})
|
|
150
|
+
*/
|
|
151
|
+
fillColor?: string;
|
|
152
|
+
/**
|
|
153
|
+
* The opacity of the fill of a polygon, from 0 to 1
|
|
154
|
+
*
|
|
155
|
+
* @defaultValue `0.25` (the alpha of `polygon.fill` of {@link FeatureStyleConfig})
|
|
156
|
+
*/
|
|
157
|
+
fillOpacity?: number;
|
|
158
|
+
/**
|
|
159
|
+
* The color of a line, or of the outline of a polygon
|
|
160
|
+
*
|
|
161
|
+
* @defaultValue `'#FF0077'` (`lineString.stroke` and `polygon.stroke` of
|
|
162
|
+
* {@link FeatureStyleConfig})
|
|
163
|
+
*/
|
|
164
|
+
strokeColor?: string;
|
|
165
|
+
/**
|
|
166
|
+
* The width of a line, or of the outline of a polygon, in CSS pixels
|
|
167
|
+
*
|
|
168
|
+
* A feature drawn in a drawing mode records the zoom it was created at
|
|
169
|
+
* ({@link getCreatedZoom}), and its width follows the map from there: it doubles with each
|
|
170
|
+
* zoom level in and halves with each level out. A feature without a created zoom keeps the
|
|
171
|
+
* same width on the screen at every zoom.
|
|
172
|
+
*
|
|
173
|
+
* @defaultValue `2`
|
|
174
|
+
*/
|
|
175
|
+
strokeWidth?: number;
|
|
176
|
+
/**
|
|
177
|
+
* The opacity of a line, or of the outline of a polygon, from 0 to 1
|
|
178
|
+
*
|
|
179
|
+
* @defaultValue `1`
|
|
180
|
+
*/
|
|
181
|
+
strokeOpacity?: number;
|
|
182
|
+
/**
|
|
183
|
+
* The dash pattern of a line, or of the outline of a polygon
|
|
184
|
+
*
|
|
185
|
+
* @defaultValue `'solid'`
|
|
186
|
+
*/
|
|
187
|
+
lineStyle?: 'solid' | 'dashed' | 'dotted';
|
|
188
|
+
/**
|
|
189
|
+
* The radius of the marker of a point, in CSS pixels
|
|
190
|
+
*
|
|
191
|
+
* @defaultValue `6` (a 12 px marker; `point.point.size` of {@link FeatureStyleConfig} is
|
|
192
|
+
* the diameter)
|
|
193
|
+
*/
|
|
194
|
+
pointRadius?: number;
|
|
195
|
+
/**
|
|
196
|
+
* The fill color of the marker of a point (the marker keeps its white outline)
|
|
197
|
+
*
|
|
198
|
+
* @defaultValue `'#FF6633'`
|
|
199
|
+
*/
|
|
200
|
+
pointColor?: string;
|
|
201
|
+
/**
|
|
202
|
+
* The shape of the marker of a point
|
|
203
|
+
*
|
|
204
|
+
* It wins over the shape of the `style` option (`point.point.shape` of
|
|
205
|
+
* {@link FeatureStyleConfig}), so points of one instance can mix shapes. Hit testing does not
|
|
206
|
+
* look at the shape: a square, a triangle or a star is hit like the circle that encloses it.
|
|
207
|
+
*
|
|
208
|
+
* @defaultValue the shape of the `style` option (`'circle'` unless it is changed)
|
|
209
|
+
*/
|
|
210
|
+
pointShape?: 'circle' | 'square' | 'triangle' | 'star';
|
|
211
|
+
/**
|
|
212
|
+
* The opacity of an image, from 0 to 1 (it takes precedence over {@link ImageStyle.opacity})
|
|
213
|
+
*
|
|
214
|
+
* @defaultValue `1`
|
|
215
|
+
*/
|
|
216
|
+
imageOpacity?: number;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The style of an Image feature: {@link FeatureStyle} plus its size, rotation and opacity
|
|
220
|
+
*
|
|
221
|
+
* The image is drawn at its size at the zoom it was created at (`properties.createdZoom`)
|
|
222
|
+
* and scales with the map from there, like a picture laid on the ground.
|
|
223
|
+
*/
|
|
224
|
+
export interface ImageStyle extends FeatureStyle {
|
|
225
|
+
/**
|
|
226
|
+
* The width in pixels at the created zoom
|
|
227
|
+
*
|
|
228
|
+
* @defaultValue the width of the image (`properties.imageWidth`)
|
|
229
|
+
*/
|
|
230
|
+
width?: number;
|
|
231
|
+
/**
|
|
232
|
+
* The height in pixels at the created zoom
|
|
233
|
+
*
|
|
234
|
+
* @defaultValue the height of the image (`properties.imageHeight`)
|
|
235
|
+
*/
|
|
236
|
+
height?: number;
|
|
237
|
+
/**
|
|
238
|
+
* A rotation in degrees, added to `properties.rotation`
|
|
239
|
+
*
|
|
240
|
+
* @defaultValue `0`
|
|
241
|
+
*/
|
|
242
|
+
rotation?: number;
|
|
243
|
+
/**
|
|
244
|
+
* The opacity from 0 to 1, used when {@link FeatureStyle.imageOpacity} is unset
|
|
245
|
+
*
|
|
246
|
+
* @defaultValue `1`
|
|
247
|
+
*/
|
|
248
|
+
opacity?: number;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The properties core keeps in `Feature.properties` of an Image feature
|
|
252
|
+
*
|
|
253
|
+
* The image mode and `load()` of an image file write them. The image data itself is a
|
|
254
|
+
* {@link FileData} of the Store, which `imageFileId` names, so that several features can share
|
|
255
|
+
* one image.
|
|
256
|
+
*/
|
|
257
|
+
export interface ImageProperties {
|
|
258
|
+
/** The ID of the {@link FileData} that holds the image */
|
|
259
|
+
imageFileId: string;
|
|
260
|
+
/** The width of the image in pixels */
|
|
261
|
+
imageWidth: number;
|
|
262
|
+
/** The height of the image in pixels */
|
|
263
|
+
imageHeight: number;
|
|
264
|
+
/** The zoom the image was placed at; at this zoom it is drawn at its size in pixels */
|
|
265
|
+
createdZoom: number;
|
|
266
|
+
/** The rotation in degrees (0 when unset) */
|
|
267
|
+
rotation?: number;
|
|
268
|
+
/** The scale that resizing applies to the size of the image (1 when unset) */
|
|
269
|
+
scale?: number;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* An embedded file of the document, such as the data of an image
|
|
273
|
+
*
|
|
274
|
+
* Features refer to it by ID (`properties.imageFileId` of an Image), and the native format
|
|
275
|
+
* exports the files the exported features use.
|
|
276
|
+
*/
|
|
277
|
+
export interface FileData {
|
|
278
|
+
/** The ID of the file, unique within the document */
|
|
279
|
+
id: string;
|
|
280
|
+
/** The MIME type, such as `image/webp` */
|
|
281
|
+
mimeType: string;
|
|
282
|
+
/** The content as a data URL (`data:<mimeType>;base64,...`) */
|
|
283
|
+
dataURL: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* A feature of the document: its geometry, the layer and group it belongs to, its attributes
|
|
287
|
+
* and its style
|
|
288
|
+
*
|
|
289
|
+
* The draw instance returns features from `getFeature`, `getAllFeatures` and the events, and
|
|
290
|
+
* creates them from a {@link FeatureInput}. What the instance returns is read-only: change a
|
|
291
|
+
* feature with `updateFeature`, which stores a new object.
|
|
292
|
+
*
|
|
293
|
+
* The stacking order of the features is not a property of the feature: it is the position of
|
|
294
|
+
* its ID in `Layer.order`, or in `Group.featureIds` when it belongs to a group.
|
|
295
|
+
*/
|
|
296
|
+
export interface Feature {
|
|
297
|
+
/** The ID of the feature, unique within the document (a ULID when core generates it) */
|
|
298
|
+
id: string;
|
|
299
|
+
/** The type of the feature, which decides the shape of `coordinates` */
|
|
300
|
+
type: FeatureType;
|
|
301
|
+
/** The geometry, nested as {@link FeatureCoordinates} describes for each type */
|
|
302
|
+
coordinates: FeatureCoordinates;
|
|
303
|
+
/**
|
|
304
|
+
* The ID of the layer the feature belongs to (for a feature in a group, the layer of the
|
|
305
|
+
* group)
|
|
306
|
+
*/
|
|
307
|
+
layerId: string;
|
|
308
|
+
/**
|
|
309
|
+
* The ID of the group the feature belongs to, when it belongs to one
|
|
310
|
+
*
|
|
311
|
+
* A feature in a group is listed in `Group.featureIds` instead of `Layer.order`.
|
|
312
|
+
*/
|
|
313
|
+
groupId?: string;
|
|
314
|
+
/**
|
|
315
|
+
* The attributes of the feature
|
|
316
|
+
*
|
|
317
|
+
* They are free-form, and GeoJSON export writes them as the GeoJSON properties. Core also
|
|
318
|
+
* reads and writes a few keys of its own here: `name` and `description`, `createdZoom`,
|
|
319
|
+
* `rotation` and `scale` (see {@link getCreatedZoom}, {@link getRotation} and
|
|
320
|
+
* {@link getScale}), `radiusMeters` and `radiusHandleAngle` of a Circle, and the keys of
|
|
321
|
+
* {@link ImageProperties} of an Image.
|
|
322
|
+
*/
|
|
323
|
+
properties: Record<string, unknown>;
|
|
324
|
+
/**
|
|
325
|
+
* The style of this feature (the defaults and the layer's style rule apply when omitted);
|
|
326
|
+
* an Image takes an {@link ImageStyle}
|
|
327
|
+
*/
|
|
328
|
+
style?: FeatureStyle | ImageStyle;
|
|
329
|
+
/**
|
|
330
|
+
* Whether the feature is locked
|
|
331
|
+
*
|
|
332
|
+
* A locked feature can be selected but not moved, resized, rotated, reshaped or deleted by
|
|
333
|
+
* the user. A feature is also locked when its group or its layer is ({@link isFeatureLocked}).
|
|
334
|
+
*/
|
|
335
|
+
locked: boolean;
|
|
336
|
+
/**
|
|
337
|
+
* Whether the feature is shown
|
|
338
|
+
*
|
|
339
|
+
* It is part of the document, so it is saved and exported. A hidden
|
|
340
|
+
* feature is neither drawn nor hit. To hide a feature in this instance only, use local
|
|
341
|
+
* visibility (`setLocallyHidden`) instead.
|
|
342
|
+
*/
|
|
343
|
+
visible: boolean;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The input for adding a feature with `addFeature`: a {@link Feature} whose other fields
|
|
347
|
+
* may be omitted
|
|
348
|
+
*
|
|
349
|
+
* Only `type` and `coordinates` are required; the other fields take the defaults written on
|
|
350
|
+
* them.
|
|
351
|
+
*/
|
|
352
|
+
export interface FeatureInput {
|
|
353
|
+
/** Feature ID (generated automatically when omitted) */
|
|
354
|
+
id?: string;
|
|
355
|
+
/** Feature type */
|
|
356
|
+
type: FeatureType;
|
|
357
|
+
/** Coordinates */
|
|
358
|
+
coordinates: FeatureCoordinates;
|
|
359
|
+
/** Layer ID (the active layer when omitted) */
|
|
360
|
+
layerId?: string;
|
|
361
|
+
/** Properties (an empty object when omitted) */
|
|
362
|
+
properties?: Record<string, unknown>;
|
|
363
|
+
/** Style */
|
|
364
|
+
style?: FeatureStyle | ImageStyle;
|
|
365
|
+
/** Locked state (false when omitted) */
|
|
366
|
+
locked?: boolean;
|
|
367
|
+
/** Visible state (true when omitted) */
|
|
368
|
+
visible?: boolean;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* A rule that colors the features of a layer from their attributes (`Layer.styleRule`)
|
|
372
|
+
*
|
|
373
|
+
* The rule is evaluated when the features are drawn, so a feature follows the rule as soon
|
|
374
|
+
* as an attribute changes, with nothing to rewrite in its style. The precedence is "the
|
|
375
|
+
* feature's own color > the layer's rule > the default color". The color goes to
|
|
376
|
+
* `pointColor` of a point, `strokeColor` of a line and `fillColor` of a polygon
|
|
377
|
+
* ({@link getStyleRuleChannel}). Colors are `#rrggbb`.
|
|
378
|
+
*
|
|
379
|
+
* There are four kinds:
|
|
380
|
+
*
|
|
381
|
+
* - `single`: gives every feature the same `color`, without looking at attributes
|
|
382
|
+
* - `categorical`: looks up the value of `property` (a string, a number or a boolean, as a
|
|
383
|
+
* string) in `map`
|
|
384
|
+
* - `graduated`: classes the number in `property` by the ascending `breaks` (n of them) and
|
|
385
|
+
* takes the color from `colors` (n + 1 of them): a value below `breaks[i]` takes
|
|
386
|
+
* `colors[i]`, and a value below no break takes `colors[n]`
|
|
387
|
+
* - `continuous`: interpolates the two colors of `ramp` in OKLab from `min` to `max` (so no
|
|
388
|
+
* muddy middle color appears); a value outside the range is clamped
|
|
389
|
+
*
|
|
390
|
+
* A feature that lacks the attribute, or whose value has the wrong type (a numeric string
|
|
391
|
+
* for `graduated`, say), takes `other` rather than the default color, so a rule that does not
|
|
392
|
+
* apply can be told apart from a missing value. {@link evaluateStyleRule} evaluates a rule and
|
|
393
|
+
* {@link deriveLegend} lists its legend entries; the library does not draw the legend.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* draw.updateLayer(layerId, {
|
|
398
|
+
* styleRule: {
|
|
399
|
+
* kind: 'graduated',
|
|
400
|
+
* property: 'population',
|
|
401
|
+
* breaks: [1000, 10000],
|
|
402
|
+
* colors: ['#fee8c8', '#fdbb84', '#e34a33'],
|
|
403
|
+
* other: '#cccccc',
|
|
404
|
+
* },
|
|
405
|
+
* });
|
|
406
|
+
* // population 500 -> #fee8c8, 5000 -> #fdbb84, 20000 -> #e34a33, missing -> #cccccc
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
export type StyleRule = {
|
|
410
|
+
kind: 'single';
|
|
411
|
+
color: string;
|
|
412
|
+
} | {
|
|
413
|
+
kind: 'categorical';
|
|
414
|
+
property: string;
|
|
415
|
+
map: Record<string, string>;
|
|
416
|
+
other: string;
|
|
417
|
+
} | {
|
|
418
|
+
kind: 'graduated';
|
|
419
|
+
property: string;
|
|
420
|
+
breaks: number[];
|
|
421
|
+
colors: string[];
|
|
422
|
+
other: string;
|
|
423
|
+
} | {
|
|
424
|
+
kind: 'continuous';
|
|
425
|
+
property: string;
|
|
426
|
+
min: number;
|
|
427
|
+
max: number;
|
|
428
|
+
ramp: [string, string];
|
|
429
|
+
other: string;
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* A layer of the document: an ordered list of features and groups, with its own visibility,
|
|
433
|
+
* lock and style rule
|
|
434
|
+
*
|
|
435
|
+
* Every feature belongs to one layer. The layers are stacked in the order of
|
|
436
|
+
* `getLayerOrder()`, and within a layer the items are stacked in the order of `order`. New
|
|
437
|
+
* features are drawn into the active layer.
|
|
438
|
+
*/
|
|
439
|
+
export interface Layer {
|
|
440
|
+
/** The ID of the layer, unique within the document */
|
|
441
|
+
id: string;
|
|
442
|
+
/** The display name */
|
|
443
|
+
name: string;
|
|
444
|
+
/**
|
|
445
|
+
* Whether the layer is shown
|
|
446
|
+
*
|
|
447
|
+
* It is part of the document, like {@link Feature.visible}. A hidden layer hides every
|
|
448
|
+
* feature in it, and no feature can be drawn into it.
|
|
449
|
+
*/
|
|
450
|
+
visible: boolean;
|
|
451
|
+
/**
|
|
452
|
+
* Whether the layer is locked
|
|
453
|
+
*
|
|
454
|
+
* Every feature in a locked layer is locked ({@link isFeatureLocked}), and no feature can
|
|
455
|
+
* be drawn into it.
|
|
456
|
+
*/
|
|
457
|
+
locked: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* The opacity of the layer, from 0 to 1
|
|
460
|
+
*
|
|
461
|
+
* It is multiplied into the alpha of everything drawn for the layer (fills, lines, points,
|
|
462
|
+
* images, and what the renderers of custom types and feature companions draw, which receive
|
|
463
|
+
* it as `CustomRendererDrawContext.opacity`). It is applied at draw time, so changing it is
|
|
464
|
+
* cheap: nothing is rebuilt. It is only a look: hit testing ignores it, and a feature in a
|
|
465
|
+
* layer at opacity 0 can still be selected.
|
|
466
|
+
*/
|
|
467
|
+
opacity: number;
|
|
468
|
+
/**
|
|
469
|
+
* The IDs of the standalone features and of the groups in the layer, back to front (the
|
|
470
|
+
* last is the frontmost)
|
|
471
|
+
*
|
|
472
|
+
* A feature in a group is listed in `Group.featureIds` instead.
|
|
473
|
+
*/
|
|
474
|
+
order: string[];
|
|
475
|
+
/** Free-form data of the host, saved and exported with the layer */
|
|
476
|
+
metadata?: Record<string, unknown>;
|
|
477
|
+
/**
|
|
478
|
+
* Style rule (no rule when omitted)
|
|
479
|
+
*
|
|
480
|
+
* Because it is an ordinary field it is subject to saving, subscription and undo, and
|
|
481
|
+
* it is updated with `updateLayer(id, { styleRule })`.
|
|
482
|
+
*/
|
|
483
|
+
styleRule?: StyleRule;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* A group of features within one layer, selected, moved and stacked as a unit
|
|
487
|
+
*
|
|
488
|
+
* A group is listed in `Layer.order` of its layer like a feature, and its members are listed
|
|
489
|
+
* in `featureIds` (each member has `groupId` set). The layer of a group is the layer whose
|
|
490
|
+
* order lists it, so a group has no `layerId`.
|
|
491
|
+
*/
|
|
492
|
+
export interface Group {
|
|
493
|
+
/** The ID of the group, unique within the document */
|
|
494
|
+
id: string;
|
|
495
|
+
/** The display name */
|
|
496
|
+
name: string;
|
|
497
|
+
/** The IDs of the members, back to front (the last is the frontmost) */
|
|
498
|
+
featureIds: string[];
|
|
499
|
+
/**
|
|
500
|
+
* Whether the group is locked (every member is then locked, see {@link isFeatureLocked})
|
|
501
|
+
*/
|
|
502
|
+
locked: boolean;
|
|
503
|
+
/** Whether the group is shown (a hidden group hides every member) */
|
|
504
|
+
visible: boolean;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* The geometry being drawn, before it is committed as a feature
|
|
508
|
+
*
|
|
509
|
+
* A drawing mode keeps it in the Store while the user draws, and it is cleared when the
|
|
510
|
+
* feature is committed or the drawing is cancelled. It is local state of this instance; a
|
|
511
|
+
* subscriber that wants the drawing in progress reads it from the notifications of the Store
|
|
512
|
+
* ({@link StateChanges.tentative}).
|
|
513
|
+
*/
|
|
514
|
+
export interface TentativeState {
|
|
515
|
+
/** The type of the feature being drawn */
|
|
516
|
+
type: FeatureType;
|
|
517
|
+
/** The coordinates drawn so far, in the format of the feature type */
|
|
518
|
+
coordinates: Coordinate | Coordinate[] | Coordinate[][];
|
|
519
|
+
/**
|
|
520
|
+
* ID of the layer being drawn into
|
|
521
|
+
*
|
|
522
|
+
* Indicates the layer the Tentative belongs to.
|
|
523
|
+
* Used in order to render according to the layer order.
|
|
524
|
+
*/
|
|
525
|
+
layerId: string;
|
|
526
|
+
/**
|
|
527
|
+
* The number of committed coordinates. Used for LineString/Polygon.
|
|
528
|
+
* Of the coordinates, the first confirmedCount of them are committed.
|
|
529
|
+
* The ones after that (such as the cursor position) are not committed.
|
|
530
|
+
* When omitted, all of them are treated as committed.
|
|
531
|
+
*/
|
|
532
|
+
confirmedCount?: number;
|
|
533
|
+
/**
|
|
534
|
+
* The index of the vertex to highlight.
|
|
535
|
+
* Set when the mouse comes close to a vertex.
|
|
536
|
+
*/
|
|
537
|
+
highlightedVertexIndex?: number;
|
|
538
|
+
/**
|
|
539
|
+
* For Circle: the radius (in meters)
|
|
540
|
+
*/
|
|
541
|
+
radiusMeters?: number;
|
|
542
|
+
/**
|
|
543
|
+
* For Circle: the angle of the radius handle (in degrees)
|
|
544
|
+
*/
|
|
545
|
+
radiusHandleAngle?: number;
|
|
546
|
+
/**
|
|
547
|
+
* The ID of the Feature that is going to be created
|
|
548
|
+
*
|
|
549
|
+
* The ID of the Feature that will be created when drawing finishes is decided in
|
|
550
|
+
* advance and included in the Tentative.
|
|
551
|
+
* Lets a subscriber that receives the committed Feature drop the corresponding Tentative
|
|
552
|
+
* at once.
|
|
553
|
+
*/
|
|
554
|
+
pendingFeatureId?: string;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Where a change came from, carried by every change notification of the Store
|
|
558
|
+
*
|
|
559
|
+
* A subscriber reads it to decide what to do with a change. The source is only a label: it
|
|
560
|
+
* does not change which events are emitted
|
|
561
|
+
* or how they are grouped. Every change is emitted, one notification per transaction, and
|
|
562
|
+
* features.change carries the source of its flush.
|
|
563
|
+
*
|
|
564
|
+
* - local: an operation of the user or a call of the API (the default)
|
|
565
|
+
* - silent: a change that a subscriber recording changes leaves out: loading a native file, which replaces
|
|
566
|
+
* the whole document, and clearing the selection when a mode starts
|
|
567
|
+
* - batch: loading a GeoJSON file, a bulk change recorded as one step (it is one transaction,
|
|
568
|
+
* which is what makes it one notification)
|
|
569
|
+
* - remote: a change that came from outside the instance. A replaced {@link DocumentStore}
|
|
570
|
+
* writes it for the changes it applies from elsewhere, so that subscribers can tell them from
|
|
571
|
+
* local edits and core keeps the local editing state (a vertex selection) consistent with them
|
|
572
|
+
* - import: for a host or an extension that loads data by its own means; core does not write
|
|
573
|
+
* it
|
|
574
|
+
*
|
|
575
|
+
* Any other string can be used by a plugin or a store for the changes it applies itself.
|
|
576
|
+
*/
|
|
577
|
+
export type UpdateSource = 'local' | 'silent' | 'batch' | 'remote' | 'import' | (string & Record<never, never>);
|
|
578
|
+
/**
|
|
579
|
+
* Options of `updateFeature` on the Store, for the updates of an edit in progress
|
|
580
|
+
*/
|
|
581
|
+
export interface UpdateFeatureOptions {
|
|
582
|
+
/**
|
|
583
|
+
* Indicates that this update is an intermediate state in the middle of an edit
|
|
584
|
+
* operation.
|
|
585
|
+
*
|
|
586
|
+
* An intermediate state is always overwritten by the committing update that follows
|
|
587
|
+
* (the one without options).
|
|
588
|
+
* MemoryStore ignores it and applies the update as usual, and passes it through to
|
|
589
|
+
* isIntermediate of StateChanges.features.updated. An external store can look at this
|
|
590
|
+
* flag to decide whether to keep the update or to hold it apart until the commit.
|
|
591
|
+
*/
|
|
592
|
+
isIntermediate?: boolean;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* One change notification of the Store: everything one transaction changed
|
|
596
|
+
*
|
|
597
|
+
* `subscribe` of the Store delivers one per outermost transaction (or per write outside
|
|
598
|
+
* one). Each category is present only when the transaction changed it. The document
|
|
599
|
+
* categories (features, layers, groups, layerReorder, groupReorder, metadata) are what a
|
|
600
|
+
* {@link DocumentStore} notifies; the others are local state of this client.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```ts
|
|
604
|
+
* draw.getStore().subscribe((changes) => {
|
|
605
|
+
* if (changes.source === 'remote') return;
|
|
606
|
+
* for (const feature of changes.features?.created ?? []) console.log('created', feature.id);
|
|
607
|
+
* });
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
export interface StateChanges {
|
|
611
|
+
/**
|
|
612
|
+
* The source of the operation
|
|
613
|
+
*
|
|
614
|
+
* Used by subscribers to identify the source of the operation. Core writes 'local',
|
|
615
|
+
* 'silent' and 'batch', and a replaced store writes 'remote' for the changes it applies
|
|
616
|
+
* from outside (see {@link UpdateSource}); plugins and external store implementations can
|
|
617
|
+
* use their own values.
|
|
618
|
+
*/
|
|
619
|
+
source?: UpdateSource;
|
|
620
|
+
/** The features created, updated and deleted (each update with the feature before it) */
|
|
621
|
+
features?: {
|
|
622
|
+
created?: Feature[];
|
|
623
|
+
updated?: Array<{
|
|
624
|
+
id: string;
|
|
625
|
+
feature: Feature;
|
|
626
|
+
previous: Feature;
|
|
627
|
+
/**
|
|
628
|
+
* A flag indicating whether an edit is in progress (being dragged / being drawn)
|
|
629
|
+
*
|
|
630
|
+
* When true, this change is an intermediate state that is not yet committed, and it
|
|
631
|
+
* is always overwritten by the committing update that follows. An external store
|
|
632
|
+
* can look at this flag to decide whether to keep the update or to hold it apart
|
|
633
|
+
* until the commit.
|
|
634
|
+
*/
|
|
635
|
+
isIntermediate?: boolean;
|
|
636
|
+
}>;
|
|
637
|
+
deleted?: Feature[];
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* The layers created, updated and deleted, and the change of the stacking order of the
|
|
641
|
+
* layers (`orderChanged`)
|
|
642
|
+
*/
|
|
643
|
+
layers?: {
|
|
644
|
+
created?: Layer[];
|
|
645
|
+
updated?: Array<{
|
|
646
|
+
id: string;
|
|
647
|
+
layer: Layer;
|
|
648
|
+
previous: Layer;
|
|
649
|
+
}>;
|
|
650
|
+
deleted?: Layer[];
|
|
651
|
+
orderChanged?: {
|
|
652
|
+
order: string[];
|
|
653
|
+
previous: string[];
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
/** The groups created, updated and deleted */
|
|
657
|
+
groups?: {
|
|
658
|
+
created?: Group[];
|
|
659
|
+
updated?: Array<{
|
|
660
|
+
id: string;
|
|
661
|
+
group: Group;
|
|
662
|
+
previous: Group;
|
|
663
|
+
}>;
|
|
664
|
+
deleted?: Group[];
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* Reordering of items within a layer
|
|
668
|
+
*
|
|
669
|
+
* The reordering of items (features or groups) within the layer.order array.
|
|
670
|
+
* It is emitted separately from layers.updated, and is recorded as a dedicated command
|
|
671
|
+
* by history management.
|
|
672
|
+
*/
|
|
673
|
+
layerReorder?: {
|
|
674
|
+
layerId: string;
|
|
675
|
+
order: string[];
|
|
676
|
+
previous: string[];
|
|
677
|
+
};
|
|
678
|
+
/**
|
|
679
|
+
* Reordering of features within a group
|
|
680
|
+
*
|
|
681
|
+
* The reordering of features within the group.featureIds array.
|
|
682
|
+
* It is emitted separately from groups.updated, and is recorded as a dedicated command
|
|
683
|
+
* by history management.
|
|
684
|
+
*/
|
|
685
|
+
groupReorder?: {
|
|
686
|
+
groupId: string;
|
|
687
|
+
featureIds: string[];
|
|
688
|
+
previous: string[];
|
|
689
|
+
};
|
|
690
|
+
/** The new selection and the one before it */
|
|
691
|
+
selection?: {
|
|
692
|
+
type: SelectionType | null;
|
|
693
|
+
ids: string[];
|
|
694
|
+
previousType: SelectionType | null;
|
|
695
|
+
previousIds: string[];
|
|
696
|
+
};
|
|
697
|
+
/** The IDs of the features whose editing started and ended */
|
|
698
|
+
editing?: {
|
|
699
|
+
started?: string[];
|
|
700
|
+
ended?: string[];
|
|
701
|
+
};
|
|
702
|
+
/** The new geometry being drawn and the one before it (null when there is none) */
|
|
703
|
+
tentative?: {
|
|
704
|
+
state: TentativeState | null;
|
|
705
|
+
previous: TentativeState | null;
|
|
706
|
+
};
|
|
707
|
+
/** The new mode and the one before it */
|
|
708
|
+
mode?: {
|
|
709
|
+
mode: Mode;
|
|
710
|
+
previous: Mode;
|
|
711
|
+
};
|
|
712
|
+
/**
|
|
713
|
+
* A flag indicating that the UI state (dragState, boxSelection) has changed
|
|
714
|
+
* These are not included in the details of StateChanges, but they are notified in order
|
|
715
|
+
* to trigger a redraw
|
|
716
|
+
*/
|
|
717
|
+
uiStateChanged?: boolean;
|
|
718
|
+
/** The new metadata of the document and the one before it */
|
|
719
|
+
metadata?: {
|
|
720
|
+
metadata: Metadata;
|
|
721
|
+
previous: Metadata;
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* An axis-aligned bounding box in longitude (X) and latitude (Y), in degrees
|
|
726
|
+
*/
|
|
727
|
+
export interface BoundingBox {
|
|
728
|
+
/** The west edge (the smallest longitude) */
|
|
729
|
+
minX: number;
|
|
730
|
+
/** The south edge (the smallest latitude) */
|
|
731
|
+
minY: number;
|
|
732
|
+
/** The east edge (the largest longitude) */
|
|
733
|
+
maxX: number;
|
|
734
|
+
/** The north edge (the largest latitude) */
|
|
735
|
+
maxY: number;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* The metadata of the document
|
|
739
|
+
*
|
|
740
|
+
* Core stores, saves and exports it, and does not read it. `setMetadata` merges into it.
|
|
741
|
+
*
|
|
742
|
+
* It declares a title and a description. An application keeps settings of its own here (the
|
|
743
|
+
* basemap it shows, a default view) by adding keys to this interface with declaration
|
|
744
|
+
* merging; the keys are stored and exported like the declared ones.
|
|
745
|
+
*
|
|
746
|
+
* @example
|
|
747
|
+
* ```ts
|
|
748
|
+
* declare module '@sakuzu/maplibre-gl-draw' {
|
|
749
|
+
* interface Metadata {
|
|
750
|
+
* basemap?: string;
|
|
751
|
+
* }
|
|
752
|
+
* }
|
|
753
|
+
*
|
|
754
|
+
* draw.setMetadata({ basemap: 'https://example.com/style.json' });
|
|
755
|
+
* ```
|
|
756
|
+
*/
|
|
757
|
+
export interface Metadata {
|
|
758
|
+
/** The title of the document */
|
|
759
|
+
title?: string;
|
|
760
|
+
/** The description of the document */
|
|
761
|
+
description?: string;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* The whole document in the native format, as `export('native')` writes it and
|
|
765
|
+
* `load()` reads it
|
|
766
|
+
*
|
|
767
|
+
* `load()` validates it as a whole before replacing the document, and rejects it on the
|
|
768
|
+
* first problem. The format is described in the data format reference.
|
|
769
|
+
*/
|
|
770
|
+
export interface Data {
|
|
771
|
+
/** The version of the native format (`'2.0.0'` for this release) */
|
|
772
|
+
version: string;
|
|
773
|
+
/** When the data was written (an ISO 8601 timestamp) */
|
|
774
|
+
created?: string;
|
|
775
|
+
/** When the data was last modified (an ISO 8601 timestamp) */
|
|
776
|
+
modified?: string;
|
|
777
|
+
/** The metadata of the document */
|
|
778
|
+
metadata?: Metadata;
|
|
779
|
+
/** The layers, with their order of items (the order of this array has no meaning) */
|
|
780
|
+
layers?: Layer[];
|
|
781
|
+
/**
|
|
782
|
+
* The stacking order, from the back: every layer of `layers` once, and the entries of the
|
|
783
|
+
* application that are not layers (see {@link DocumentStore.setLayerOrder}) at their
|
|
784
|
+
* positions
|
|
785
|
+
*/
|
|
786
|
+
layerOrder: string[];
|
|
787
|
+
/** The groups */
|
|
788
|
+
groups?: Group[];
|
|
789
|
+
/** The features */
|
|
790
|
+
features: Feature[];
|
|
791
|
+
/** The embedded files the features use, by ID */
|
|
792
|
+
files?: Record<string, FileData>;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Options for load()
|
|
796
|
+
*
|
|
797
|
+
* For an image file, the coordinate, the zoom and the layer ID are required.
|
|
798
|
+
* For GeoJSON and the like they are not required, because the coordinate information is
|
|
799
|
+
* contained in the file.
|
|
800
|
+
*/
|
|
801
|
+
export interface LoadOptions {
|
|
802
|
+
/** The coordinate at which to place the image feature */
|
|
803
|
+
coordinate?: Coordinate;
|
|
804
|
+
/** The zoom level at which the image feature is created */
|
|
805
|
+
zoom?: number;
|
|
806
|
+
/** The ID of the layer to add the image feature to */
|
|
807
|
+
layerId?: string;
|
|
808
|
+
/**
|
|
809
|
+
* Whether to expand the Multi* geometries of GeoJSON into individual features
|
|
810
|
+
* (default: false)
|
|
811
|
+
*
|
|
812
|
+
* By default MultiPoint / MultiLineString / MultiPolygon are kept as they are, as Multi
|
|
813
|
+
* features. Setting it to true gives the former expanding behavior.
|
|
814
|
+
*/
|
|
815
|
+
flattenMulti?: boolean;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* What `load()` imported: the detected format, the IDs of the new features and what it
|
|
819
|
+
* skipped
|
|
820
|
+
*/
|
|
821
|
+
export interface LoadResult {
|
|
822
|
+
/** The detected data format */
|
|
823
|
+
format: 'native' | 'geojson' | 'image';
|
|
824
|
+
/** The IDs of the imported features */
|
|
825
|
+
featureIds: string[];
|
|
826
|
+
/** Whether the existing data was replaced */
|
|
827
|
+
replaced: boolean;
|
|
828
|
+
/**
|
|
829
|
+
* Features that the import left out, with the reason. Only GeoJSON input
|
|
830
|
+
* skips features; the native format is validated as a whole and rejected
|
|
831
|
+
* on the first problem.
|
|
832
|
+
*/
|
|
833
|
+
skipped?: SkippedFeature[];
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* A feature of a GeoJSON input that `load()` left out, and why
|
|
837
|
+
*/
|
|
838
|
+
export interface SkippedFeature {
|
|
839
|
+
/** Index of the feature in the input */
|
|
840
|
+
index: number;
|
|
841
|
+
/** Why it was skipped (English, for logs and diagnostics) */
|
|
842
|
+
reason: string;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* The format `export()` writes: the native format ({@link Data}) or GeoJSON
|
|
846
|
+
*/
|
|
847
|
+
export type ExportFormat = 'native' | 'geojson';
|
|
848
|
+
/**
|
|
849
|
+
* Options of `export()`: the file name, and which features or layers to export
|
|
850
|
+
*/
|
|
851
|
+
export interface ExportOptions {
|
|
852
|
+
/** A custom file name */
|
|
853
|
+
fileName?: string;
|
|
854
|
+
/** Export only certain features */
|
|
855
|
+
featureIds?: string[];
|
|
856
|
+
/** Export only certain layers */
|
|
857
|
+
layerIds?: string[];
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* What `export()` returns: the data as a string, with its MIME type and a file name
|
|
861
|
+
*/
|
|
862
|
+
export interface ExportResult {
|
|
863
|
+
/** The export format */
|
|
864
|
+
format: ExportFormat;
|
|
865
|
+
/** The exported data */
|
|
866
|
+
data: string;
|
|
867
|
+
/** The MIME type */
|
|
868
|
+
mimeType: string;
|
|
869
|
+
/** The recommended file name */
|
|
870
|
+
fileName: string;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* The box selection in progress (a Shift-drag in the select mode), local state of this client
|
|
874
|
+
*/
|
|
875
|
+
export interface BoxSelection {
|
|
876
|
+
/** The point where the drag started (geographic coordinates) */
|
|
877
|
+
startPoint: Coordinate;
|
|
878
|
+
/** The current drag position (geographic coordinates) */
|
|
879
|
+
endPoint: Coordinate;
|
|
880
|
+
/** The selection state when the drag started (in order to restore it on cancel) */
|
|
881
|
+
previousSelection: string[];
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* The kind of drag in progress in the select mode (null when there is none)
|
|
885
|
+
*/
|
|
886
|
+
export type DragOperationType = 'move' | 'resize' | 'rotate' | 'vertex' | 'midpoint' | 'radius'
|
|
887
|
+
/**
|
|
888
|
+
* The drag of an auxiliary handle provided by an extension implementation (core does not own
|
|
889
|
+
* the meaning of the coordinates)
|
|
890
|
+
*/
|
|
891
|
+
| 'auxiliary' | null;
|
|
892
|
+
/**
|
|
893
|
+
* The four corners and the center of an axis-aligned box, as geographic coordinates
|
|
894
|
+
*/
|
|
895
|
+
export interface BoundingBoxCoordsSimple {
|
|
896
|
+
/** The north-west corner */
|
|
897
|
+
topLeft: Coordinate;
|
|
898
|
+
/** The north-east corner */
|
|
899
|
+
topRight: Coordinate;
|
|
900
|
+
/** The south-east corner */
|
|
901
|
+
bottomRight: Coordinate;
|
|
902
|
+
/** The south-west corner */
|
|
903
|
+
bottomLeft: Coordinate;
|
|
904
|
+
/** The center */
|
|
905
|
+
center: Coordinate;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* The state of a rotation in progress, for drawing the rotating bounding box
|
|
909
|
+
*/
|
|
910
|
+
export interface RotateInfo {
|
|
911
|
+
/** The combined AABB when the rotation started (before the margin is applied) */
|
|
912
|
+
initialBbox: BoundingBoxCoordsSimple;
|
|
913
|
+
/** The bbox of each feature when the rotation started (only for a multiple selection) */
|
|
914
|
+
initialFeatureBboxes?: Map<string, BoundingBoxCoordsSimple>;
|
|
915
|
+
/** The current rotation angle (in radians) */
|
|
916
|
+
currentAngle: number;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* The drag in progress on the selected features, local state of this client
|
|
920
|
+
*
|
|
921
|
+
* The selection UI reads it to decide which handles to show during the drag.
|
|
922
|
+
*/
|
|
923
|
+
export interface DragState {
|
|
924
|
+
/** The kind of the current drag operation */
|
|
925
|
+
operation: DragOperationType;
|
|
926
|
+
/**
|
|
927
|
+
* The vertex being operated on while editing a vertex/midpoint (part number + ring
|
|
928
|
+
* number + vertex index)
|
|
929
|
+
* Set only when operation is 'vertex' or 'midpoint'
|
|
930
|
+
*/
|
|
931
|
+
activeVertex?: VertexRef;
|
|
932
|
+
/**
|
|
933
|
+
* The ID of the feature being operated on while editing a vertex/midpoint
|
|
934
|
+
* Set only when operation is 'vertex' or 'midpoint'
|
|
935
|
+
*/
|
|
936
|
+
activeFeatureId?: string;
|
|
937
|
+
/**
|
|
938
|
+
* For drawing the bbox during a rotation operation
|
|
939
|
+
* Set only when operation is 'rotate'
|
|
940
|
+
*/
|
|
941
|
+
rotateInfo?: RotateInfo;
|
|
942
|
+
/**
|
|
943
|
+
* The IDs of the features being moved (a group/layer selection is already resolved into
|
|
944
|
+
* its members)
|
|
945
|
+
* Set only when operation is 'move'
|
|
946
|
+
*
|
|
947
|
+
* Used so that snapping can exclude "the very feature being moved" from the candidates.
|
|
948
|
+
*/
|
|
949
|
+
movingFeatureIds?: string[];
|
|
950
|
+
}
|