@florasync/leaflet-geokit 0.8.3 → 0.9.1
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/ARCHITECTURE.md +195 -0
- package/CHANGELOG.md +8 -0
- package/README.md +146 -11
- package/custom-toolbar.html +165 -0
- package/dist/django/index.js +8993 -5090
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +21536 -5994
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +18006 -2461
- package/dist/leaflet-geokit.external.es.js.map +1 -1
- package/dist/leaflet-geokit.umd.js +263 -60
- package/dist/leaflet-geokit.umd.js.map +1 -1
- package/dist/preact/index-DCKj0r6a.js +8545 -0
- package/dist/preact/index-DCKj0r6a.js.map +1 -0
- package/dist/preact/index.js +1 -1
- package/dist/preact-bundled/index.js +9002 -5089
- package/dist/preact-bundled/index.js.map +1 -1
- package/dist/react/index-DCKj0r6a.js +8545 -0
- package/dist/react/index-DCKj0r6a.js.map +1 -0
- package/dist/react/index.js +1 -1
- package/dist/react-bundled/index.js +9040 -5127
- package/dist/react-bundled/index.js.map +1 -1
- package/dist/types/components/LeafletDrawMapElement.d.ts +42 -3
- package/dist/types/django/index.d.ts +2 -2
- package/dist/types/external.d.ts +9 -3
- package/dist/types/index.d.ts +9 -3
- package/dist/types/lib/FeatureStore.d.ts +2 -2
- package/dist/types/lib/LayerRegistry.d.ts +19 -0
- package/dist/types/lib/MapController.d.ts +95 -5
- package/dist/types/lib/draw/L.Draw.Move.d.ts +1 -0
- package/dist/types/lib/draw/move-pointer.d.ts +12 -0
- package/dist/types/lib/layer-cake/LayerCakeManager.d.ts +10 -2
- package/dist/types/lib/layer-style-panel.d.ts +3 -0
- package/dist/types/lib/marker-icons.d.ts +1 -1
- package/dist/types/lib/providers.d.ts +64 -0
- package/dist/types/lib/snapping.d.ts +30 -0
- package/dist/types/lib/tool-buttons.d.ts +3 -1
- package/dist/types/lib/tool-capabilities.d.ts +27 -0
- package/dist/types/lib/toolbar-accessibility.d.ts +3 -0
- package/dist/types/lib/toolbar-layout.d.ts +14 -0
- package/dist/types/lib/toolbar-styles.d.ts +2 -0
- package/dist/types/preact/core.d.ts +2 -2
- package/dist/types/preact/index.d.ts +2 -2
- package/dist/types/preact-bundled/index.d.ts +3 -3
- package/dist/types/react/core.d.ts +2 -2
- package/dist/types/react/index.d.ts +2 -2
- package/dist/types/react-bundled/index.d.ts +3 -3
- package/dist/types/types/events.d.ts +15 -1
- package/dist/types/types/layers.d.ts +65 -0
- package/dist/types/types/public.d.ts +160 -5
- package/dist/types/utils/geojson-pipeline.d.ts +51 -0
- package/dist/types/utils/geojson.d.ts +15 -2
- package/dist/types/utils/grower-geometry.d.ts +107 -0
- package/docs/accessibility.md +142 -0
- package/docs/api-reference.md +249 -0
- package/docs/custom-toolbar.md +168 -0
- package/docs/diagnostics.md +216 -0
- package/docs/geojson-pipelines.md +145 -0
- package/docs/google-maps-adapter-spike.md +77 -0
- package/docs/grower-geometry.md +237 -0
- package/docs/grower-measurement.md +23 -0
- package/docs/integration-recipes.md +301 -0
- package/docs/layers.md +136 -0
- package/docs/providers.md +191 -0
- package/docs/release-verification.md +75 -0
- package/docs/shims/django.md +102 -0
- package/docs/shims/preact.md +98 -0
- package/docs/shims/react.md +98 -0
- package/docs/snapping-and-measurements.md +42 -0
- package/docs/tool-capabilities.md +131 -0
- package/docs/tool-lifecycle.md +124 -0
- package/docs/toolbar-layout.md +158 -0
- package/docs/toolbar-styling.md +118 -0
- package/package.json +35 -3
- package/dist/preact/index-BMfJn-mD.js +0 -4632
- package/dist/preact/index-BMfJn-mD.js.map +0 -1
- package/dist/react/index-BMfJn-mD.js +0 -4632
- package/dist/react/index-BMfJn-mD.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../index";
|
|
2
|
-
import { type ReactLeafletGeoKitProps } from "../react/core";
|
|
1
|
+
import "../index.js";
|
|
2
|
+
import { type ReactLeafletGeoKitProps } from "../react/core.js";
|
|
3
3
|
export type { ReactLeafletGeoKitProps };
|
|
4
4
|
export declare const ReactLeafletGeoKit: (props: ReactLeafletGeoKitProps) => import("react").ReactElement<{
|
|
5
|
-
ref: import("react").MutableRefObject<import("../index").LeafletDrawMapElement | null>;
|
|
5
|
+
ref: import("react").MutableRefObject<import("../index.js").LeafletDrawMapElement | null>;
|
|
6
6
|
className: string | undefined;
|
|
7
7
|
}, string | import("react").JSXElementConstructor<any>>;
|
|
8
8
|
export default ReactLeafletGeoKit;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
-
import type { GeoJSONExportAdapter } from "../utils/geojson";
|
|
2
|
+
import type { GeoJSONExportAdapter } from "../utils/geojson.js";
|
|
3
3
|
export type GeoKitStatusState = "uninitialized" | "initializing" | "ready" | "loading" | "error";
|
|
4
4
|
export interface GeoKitDiagnosticSummary {
|
|
5
5
|
code: string;
|
|
@@ -96,4 +96,18 @@ export declare const DrawEvent: {
|
|
|
96
96
|
export declare const GeoKitEvent: {
|
|
97
97
|
readonly Status: "leaflet-geokit:status";
|
|
98
98
|
readonly Diagnostic: "leaflet-geokit:diagnostic";
|
|
99
|
+
readonly ToolCommand: "leaflet-geokit:tool-command";
|
|
100
|
+
readonly ToolCommanded: "leaflet-geokit:tool-commanded";
|
|
101
|
+
readonly ToolStarted: "leaflet-geokit:tool-started";
|
|
102
|
+
readonly ToolCompleted: "leaflet-geokit:tool-completed";
|
|
103
|
+
readonly ToolCancelled: "leaflet-geokit:tool-cancelled";
|
|
104
|
+
readonly ToolFailed: "leaflet-geokit:tool-failed";
|
|
105
|
+
readonly ToolStateChanged: "leaflet-geokit:tool-state-changed";
|
|
106
|
+
readonly ToolCapabilitiesChanged: "leaflet-geokit:tool-capabilities-changed";
|
|
107
|
+
readonly LayersChanged: "leaflet-geokit:layers-changed";
|
|
108
|
+
readonly LayerStyleRequest: "leaflet-geokit:layer-style-request";
|
|
109
|
+
readonly LayerCakeSessionStarted: "tool:layer-cake:session-started";
|
|
110
|
+
readonly LayerCakeSessionChanged: "tool:layer-cake:session-changed";
|
|
111
|
+
readonly LayerCakeSaved: "tool:layer-cake:saved";
|
|
112
|
+
readonly LayerCakeCancelled: "tool:layer-cake:cancelled";
|
|
99
113
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { FeatureCollection } from "geojson";
|
|
2
|
+
export type LayerKind = "base" | "drawn" | "imported" | "guide" | "measurement";
|
|
3
|
+
/** Portable styles only; no Leaflet instances, HTML, or provider credentials. */
|
|
4
|
+
export interface LayerStyle {
|
|
5
|
+
color?: string;
|
|
6
|
+
fillColor?: string;
|
|
7
|
+
weight?: number;
|
|
8
|
+
opacity?: number;
|
|
9
|
+
fillOpacity?: number;
|
|
10
|
+
dashArray?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface MapLayer {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
kind: LayerKind;
|
|
16
|
+
visible: boolean;
|
|
17
|
+
/** Back to front within Leaflet's base/vector/marker pane boundaries. */
|
|
18
|
+
order: number;
|
|
19
|
+
featureIds: string[];
|
|
20
|
+
style: LayerStyle;
|
|
21
|
+
}
|
|
22
|
+
export interface LayerDefinition {
|
|
23
|
+
id?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
kind?: Exclude<LayerKind, "base">;
|
|
26
|
+
style?: LayerStyle;
|
|
27
|
+
}
|
|
28
|
+
export type LayerStylePreset = "crop" | "water" | "reference";
|
|
29
|
+
export declare const LAYER_STYLE_PRESETS: Record<LayerStylePreset, Readonly<LayerStyle>>;
|
|
30
|
+
export interface LayerCakeSession {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
center: {
|
|
34
|
+
lat: number;
|
|
35
|
+
lng: number;
|
|
36
|
+
};
|
|
37
|
+
rings: {
|
|
38
|
+
radius: number;
|
|
39
|
+
}[];
|
|
40
|
+
style: LayerStyle;
|
|
41
|
+
}
|
|
42
|
+
export interface LayerCakeSessionUpdate {
|
|
43
|
+
name?: string;
|
|
44
|
+
/** Radii in meters, strictly increasing; one to ten rings. */
|
|
45
|
+
radii?: number[];
|
|
46
|
+
style?: LayerStyle;
|
|
47
|
+
preset?: LayerStylePreset;
|
|
48
|
+
}
|
|
49
|
+
export interface LayerCakeEventDetail {
|
|
50
|
+
session: LayerCakeSession;
|
|
51
|
+
source?: string;
|
|
52
|
+
commandId?: string;
|
|
53
|
+
groupId?: string;
|
|
54
|
+
featureCollection?: FeatureCollection;
|
|
55
|
+
layerId?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Cancel the style-request event to replace the built-in panel with host UI. */
|
|
58
|
+
export interface LayerStyleRequestDetail {
|
|
59
|
+
layers: MapLayer[];
|
|
60
|
+
selectedLayerId?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface LayerSnapshot {
|
|
63
|
+
version: 1;
|
|
64
|
+
layers: MapLayer[];
|
|
65
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection, Geometry } from "geojson";
|
|
2
|
-
import type { LogLevel } from "../utils/logger";
|
|
3
|
-
import type { StatusEventDetail } from "../types/events";
|
|
4
|
-
import type { GeoJSONExportAdapter, GeoJSONExportOptions, GeoJSONImportBehavior, GeoJSONImportOptions } from "../utils/geojson";
|
|
2
|
+
import type { LogLevel } from "../utils/logger.js";
|
|
3
|
+
import type { StatusEventDetail } from "../types/events.js";
|
|
4
|
+
import type { GeoJSONExportAdapter, GeoJSONExportOptions, GeoJSONImportBehavior, GeoJSONImportOptions } from "../utils/geojson.js";
|
|
5
5
|
import type * as Leaflet from "leaflet";
|
|
6
|
+
import type { MapLayer, LayerStyle, LayerCakeSession, LayerCakeSessionUpdate } from "../types/layers.js";
|
|
7
|
+
export * from "../types/layers.js";
|
|
8
|
+
import type { BasemapAdapter, ProviderDiagnostics } from "../lib/providers.js";
|
|
6
9
|
/**
|
|
7
10
|
* Basic map configuration derived from element attributes.
|
|
8
11
|
*/
|
|
@@ -33,6 +36,35 @@ export interface MapConfig {
|
|
|
33
36
|
skipLeafletStyles?: boolean;
|
|
34
37
|
}
|
|
35
38
|
export type MeasurementSystem = "metric" | "imperial";
|
|
39
|
+
export type SnapMode = "vertex" | "edge" | "grid" | "guide";
|
|
40
|
+
/** Opt-in drawing/editing snapping. All distances are screen-space pixels. */
|
|
41
|
+
export interface SnappingOptions {
|
|
42
|
+
enabled?: boolean;
|
|
43
|
+
modes?: SnapMode[];
|
|
44
|
+
/** Maximum screen-space distance for a candidate to win. Defaults to 12px. */
|
|
45
|
+
tolerancePx?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Physical WGS84 grid spacing in meters. Required when grid mode is enabled.
|
|
48
|
+
* Nodes are stable relative to gridOrigin and use the ellipsoidal meridian
|
|
49
|
+
* scale for latitude and the local parallel scale for longitude.
|
|
50
|
+
*/
|
|
51
|
+
gridSizeMeters?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Fixed grid anchor as [longitude, latitude]. Defaults to [0, 0].
|
|
54
|
+
* Grid snapping is supported for WGS84 latitudes inside ±89.9°; it is a
|
|
55
|
+
* local editing aid, not antimeridian/polar survey or CRS transformation.
|
|
56
|
+
*/
|
|
57
|
+
gridOrigin?: [number, number];
|
|
58
|
+
}
|
|
59
|
+
/** Controls the lightweight live draw/edit measurement overlay. */
|
|
60
|
+
export interface MeasurementOverlayOptions {
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
showLength?: boolean;
|
|
63
|
+
showPerimeter?: boolean;
|
|
64
|
+
showArea?: boolean;
|
|
65
|
+
maximumFractionDigits?: number;
|
|
66
|
+
autoScale?: boolean;
|
|
67
|
+
}
|
|
36
68
|
export type MarkerIconPoint = [number, number];
|
|
37
69
|
export interface MarkerIconConfig {
|
|
38
70
|
/** Required to activate a custom marker icon. Absolute, relative, data:, or blob: URL. */
|
|
@@ -49,6 +81,42 @@ export interface MarkerIconConfig {
|
|
|
49
81
|
popupAnchor?: MarkerIconPoint;
|
|
50
82
|
}
|
|
51
83
|
export type ToolButtonName = "polygon" | "polyline" | "rectangle" | "circle" | "marker" | "layerCake" | "move" | "select" | "edit" | "delete" | "ruler" | "measurementSettings" | "layerStyle" | "save";
|
|
84
|
+
export type ToolCapabilityState = "enabled" | "disabled" | "unavailable";
|
|
85
|
+
export type ToolRequirementReason = "not_ready" | "read_only" | "missing_attribute" | "unavailable_plugin" | "empty_selection" | "no_editable_layers" | "missing_provider" | "missing_api_key" | "runtime_error" | "configured_disabled";
|
|
86
|
+
export interface ToolCapabilityReason {
|
|
87
|
+
code: ToolRequirementReason;
|
|
88
|
+
message: string;
|
|
89
|
+
requirement?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface ToolCapability {
|
|
92
|
+
tool: ToolButtonName;
|
|
93
|
+
state: ToolCapabilityState;
|
|
94
|
+
reason: ToolCapabilityReason | null;
|
|
95
|
+
active: boolean;
|
|
96
|
+
/** Configured toolbar groups containing this tool, not caller-supplied command groups. */
|
|
97
|
+
groupIds: string[];
|
|
98
|
+
/** Actual built-in activation shortcut; null means no shortcut is registered. */
|
|
99
|
+
hotkey: string | null;
|
|
100
|
+
commands: {
|
|
101
|
+
activate: boolean;
|
|
102
|
+
deactivate: boolean;
|
|
103
|
+
};
|
|
104
|
+
/** UI-only disabled config does not block imperative activation. Runtime failures may be retried. */
|
|
105
|
+
commandEnabled: boolean;
|
|
106
|
+
behavior: "draw" | "mode" | "action" | "deactivate";
|
|
107
|
+
}
|
|
108
|
+
export interface ToolProviderCapability {
|
|
109
|
+
requested: string;
|
|
110
|
+
active: string;
|
|
111
|
+
state: ToolCapabilityState;
|
|
112
|
+
reason: ToolCapabilityReason | null;
|
|
113
|
+
}
|
|
114
|
+
/** Detached snapshot; also the detail of tool-capabilities-changed. No credentials. */
|
|
115
|
+
export interface ToolCapabilities {
|
|
116
|
+
tools: Record<ToolButtonName, ToolCapability>;
|
|
117
|
+
provider: ToolProviderCapability;
|
|
118
|
+
selectedFeatureIds: string[];
|
|
119
|
+
}
|
|
52
120
|
export interface ToolButtonRenderContext {
|
|
53
121
|
tool: ToolButtonName;
|
|
54
122
|
groupId?: string;
|
|
@@ -91,9 +159,28 @@ export interface ToolButtonStyleConfig {
|
|
|
91
159
|
className?: string;
|
|
92
160
|
/** Optional point-of-action guidance shown when the button is used. */
|
|
93
161
|
popover?: ToolPopoverConfig;
|
|
162
|
+
/** Disable managed toolbar buttons, not the imperative tool API. */
|
|
163
|
+
disabled?: boolean;
|
|
164
|
+
/** Optional host prerequisites; built-in local tools need neither provider nor selection. */
|
|
165
|
+
requirements?: {
|
|
166
|
+
selection?: boolean;
|
|
167
|
+
provider?: boolean;
|
|
168
|
+
};
|
|
169
|
+
/** Decorative badge text; include meaningful counts in ariaLabel too. */
|
|
170
|
+
badge?: string;
|
|
171
|
+
/** Visible hover/focus tooltip; defaults to the accessible label. */
|
|
172
|
+
tooltip?: string;
|
|
94
173
|
}
|
|
95
174
|
export type ToolButtonConfig = Partial<Record<ToolButtonName, ToolButtonStyleConfig>>;
|
|
96
|
-
export type ToolToolbarPosition = "topleft" | "topright" | "bottomleft" | "bottomright";
|
|
175
|
+
export type ToolToolbarPosition = "topleft" | "topright" | "bottomleft" | "bottomright" | ToolToolbarZone;
|
|
176
|
+
export type ToolToolbarZone = "top-start" | "top-end" | "bottom-start" | "bottom-end" | "center-end";
|
|
177
|
+
export interface ToolToolbarPlacement {
|
|
178
|
+
position?: ToolToolbarPosition;
|
|
179
|
+
orientation?: "vertical" | "horizontal";
|
|
180
|
+
order?: number;
|
|
181
|
+
overflow?: "wrap" | "scroll";
|
|
182
|
+
offset?: MarkerIconPoint;
|
|
183
|
+
}
|
|
97
184
|
export interface ToolToolbarGroupConfig {
|
|
98
185
|
/** Stable group id used in events and DOM data attributes. */
|
|
99
186
|
id: string;
|
|
@@ -107,6 +194,20 @@ export interface ToolToolbarGroupConfig {
|
|
|
107
194
|
className?: string;
|
|
108
195
|
/** Pixel offset from the chosen map corner. Defaults to [10, 10]. */
|
|
109
196
|
offset?: MarkerIconPoint;
|
|
197
|
+
/** Defaults to vertical. CSS may override the visual direction. */
|
|
198
|
+
orientation?: "vertical" | "horizontal";
|
|
199
|
+
/** Nonnegative button gap in pixels. Defaults to 6; CSS may override it. */
|
|
200
|
+
gap?: number;
|
|
201
|
+
/** Opt in to bounded zones; responsive uses a bottom sheet below 600px map width. */
|
|
202
|
+
preset?: "zones" | "responsive";
|
|
203
|
+
/** Numeric stacking order inside a zone; CSS --geokit-toolbar-order wins. */
|
|
204
|
+
order?: number;
|
|
205
|
+
/** Wrap tools or keep a scrollable single row/column. Defaults to wrap. */
|
|
206
|
+
overflow?: "wrap" | "scroll";
|
|
207
|
+
/** Map-width breakpoint and narrow placement overrides (also enables zones). */
|
|
208
|
+
responsive?: ToolToolbarPlacement & {
|
|
209
|
+
breakpoint?: number;
|
|
210
|
+
};
|
|
110
211
|
/**
|
|
111
212
|
* Hide the built-in Leaflet.draw/ruler toolbars while this custom group is present.
|
|
112
213
|
* Defaults to true so custom buttons are the only visible map tool chrome.
|
|
@@ -118,6 +219,36 @@ export interface ToolTriggerOptions {
|
|
|
118
219
|
source?: "api" | "event" | "toolbar" | "leaflet-toolbar" | string;
|
|
119
220
|
/** Toolbar group id when triggered from a configured toolbar group. */
|
|
120
221
|
groupId?: string;
|
|
222
|
+
/** Optional caller-supplied correlation id. GeoKit generates one when omitted. */
|
|
223
|
+
commandId?: string;
|
|
224
|
+
}
|
|
225
|
+
export type ToolCommandAction = "activate" | "deactivate";
|
|
226
|
+
/**
|
|
227
|
+
* Detail accepted by the public `leaflet-geokit:tool-command` event.
|
|
228
|
+
* `action` defaults to `activate`; `deactivate` returns the map to select mode.
|
|
229
|
+
*/
|
|
230
|
+
export interface ToolCommandEventDetail extends ToolTriggerOptions {
|
|
231
|
+
tool: ToolButtonName;
|
|
232
|
+
action?: ToolCommandAction;
|
|
233
|
+
}
|
|
234
|
+
export type ToolLifecycleEventName = "leaflet-geokit:tool-command" | "leaflet-geokit:tool-commanded" | "leaflet-geokit:tool-started" | "leaflet-geokit:tool-completed" | "leaflet-geokit:tool-cancelled" | "leaflet-geokit:tool-failed" | "leaflet-geokit:tool-state-changed";
|
|
235
|
+
/**
|
|
236
|
+
* Correlated payload shared by every public tool lifecycle event.
|
|
237
|
+
* Empty featureIds and omitted geometry/reason mean those fields are not
|
|
238
|
+
* relevant to that lifecycle transition.
|
|
239
|
+
*/
|
|
240
|
+
export interface ToolEventDetail {
|
|
241
|
+
tool: ToolButtonName;
|
|
242
|
+
action: ToolCommandAction;
|
|
243
|
+
source: string;
|
|
244
|
+
groupId?: string;
|
|
245
|
+
commandId: string;
|
|
246
|
+
previousTool: ToolButtonName | null;
|
|
247
|
+
activeTool: ToolButtonName | null;
|
|
248
|
+
featureIds: string[];
|
|
249
|
+
geometry?: Feature | FeatureCollection;
|
|
250
|
+
reason?: string;
|
|
251
|
+
timestamp: number;
|
|
121
252
|
}
|
|
122
253
|
export interface ToolTriggerEventDetail extends ToolTriggerOptions {
|
|
123
254
|
tool: ToolButtonName;
|
|
@@ -125,7 +256,7 @@ export interface ToolTriggerEventDetail extends ToolTriggerOptions {
|
|
|
125
256
|
timestamp: number;
|
|
126
257
|
error?: string;
|
|
127
258
|
}
|
|
128
|
-
export type IntegratedToolEventName = "tool:polygon:created" | "tool:polyline:created" | "tool:rectangle:created" | "tool:circle:created" | "tool:marker:created" | "tool:layer-cake:session-started" | "tool:layer-cake:saved" | "tool:move:pending" | "tool:move:confirmed" | "tool:move:cancelled" | "tool:edit:applied" | "tool:delete:applied" | "tool:ruler:units-changed" | "tool:save";
|
|
259
|
+
export type IntegratedToolEventName = ToolLifecycleEventName | "tool:polygon:created" | "tool:polyline:created" | "tool:rectangle:created" | "tool:circle:created" | "tool:marker:created" | "tool:layer-cake:session-started" | "tool:layer-cake:saved" | "tool:layer-cake:session-changed" | "tool:layer-cake:cancelled" | "tool:move:pending" | "tool:move:confirmed" | "tool:move:cancelled" | "tool:edit:applied" | "tool:delete:applied" | "tool:ruler:units-changed" | "tool:save";
|
|
129
260
|
export type IntegratedToolHooks = Partial<Record<IntegratedToolEventName, (detail: unknown) => void>>;
|
|
130
261
|
export interface IntegratedToolEventEmitter {
|
|
131
262
|
emit?: (eventName: IntegratedToolEventName, detail: unknown) => void;
|
|
@@ -235,6 +366,10 @@ export interface LeafletDrawMapElementAPI {
|
|
|
235
366
|
* `undefined` falls back to the `toolbar-groups` attribute, `null` clears custom groups.
|
|
236
367
|
*/
|
|
237
368
|
toolbarGroups?: ToolToolbarGroupConfig[] | null;
|
|
369
|
+
/** Opt-in screen-space snapping for drawing and vertex editing. */
|
|
370
|
+
snapping?: SnappingOptions | null;
|
|
371
|
+
/** Opt-in live length/area/perimeter feedback while drawing or editing. */
|
|
372
|
+
measurementOverlay?: MeasurementOverlayOptions | null;
|
|
238
373
|
/** Optional injection of a pre-existing Leaflet namespace to use instead of bundled import. */
|
|
239
374
|
leafletInstance?: typeof Leaflet;
|
|
240
375
|
/** Optional per-tool hooks keyed by integrated tool event name. */
|
|
@@ -249,6 +384,22 @@ export interface LeafletDrawMapElementAPI {
|
|
|
249
384
|
apiKey?: string;
|
|
250
385
|
/** Durable readiness/loading/error snapshot mirrored by `leaflet-geokit:status`. */
|
|
251
386
|
readonly status: StatusEventDetail;
|
|
387
|
+
/** Optional basemap bridge, applied after ready. Null restores attribute-configured tiles. */
|
|
388
|
+
setBasemapAdapter(adapter: BasemapAdapter | null): void;
|
|
389
|
+
getProviderDiagnostics(): ProviderDiagnostics | null;
|
|
390
|
+
getLayers(): MapLayer[];
|
|
391
|
+
setLayerVisibility(id: string, visible: boolean): Promise<void>;
|
|
392
|
+
setLayerStyle(id: string, style: LayerStyle): Promise<void>;
|
|
393
|
+
reorderLayers(ids: readonly string[]): Promise<void>;
|
|
394
|
+
focusLayer(id: string): Promise<void>;
|
|
395
|
+
removeLayer(id: string): Promise<void>;
|
|
396
|
+
getLayerCakeSession(): LayerCakeSession | null;
|
|
397
|
+
updateLayerCakeSession(update: LayerCakeSessionUpdate): Promise<void>;
|
|
398
|
+
saveLayerCakeSession(): Promise<void>;
|
|
399
|
+
cancelLayerCakeSession(): Promise<void>;
|
|
400
|
+
getToolCapabilities(): ToolCapabilities;
|
|
401
|
+
/** Supply host selection; unknown/deleted ids are excluded from capability snapshots. */
|
|
402
|
+
setToolSelection(featureIds: readonly string[]): void;
|
|
252
403
|
getGeoJSON(): Promise<FeatureCollection>;
|
|
253
404
|
importGeoJSON(fc: FeatureCollection, options?: GeoJSONImportOptions): Promise<string[]>;
|
|
254
405
|
loadGeoJSON(fc: FeatureCollection): Promise<void>;
|
|
@@ -284,6 +435,10 @@ export interface LeafletDrawMapElementAPI {
|
|
|
284
435
|
* Change the measurement system for the Leaflet ruler tool.
|
|
285
436
|
*/
|
|
286
437
|
setMeasurementUnits(system: MeasurementSystem): Promise<void>;
|
|
438
|
+
/** Return the current screen-space snap configuration. */
|
|
439
|
+
getSnappingOptions(): SnappingOptions | null;
|
|
440
|
+
/** Return the current live measurement overlay configuration. */
|
|
441
|
+
getMeasurementOverlayOptions(): MeasurementOverlayOptions | null;
|
|
287
442
|
/**
|
|
288
443
|
* Programmatically activate a map tool through the public web component API.
|
|
289
444
|
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
+
import { type GeoJSONExportOptions } from "./geojson.js";
|
|
3
|
+
export interface GeoJSONDiagnostic {
|
|
4
|
+
severity: "error" | "warning" | "info";
|
|
5
|
+
code: string;
|
|
6
|
+
path: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GeoJSONValidationSummary {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
featureCount: number;
|
|
12
|
+
diagnostics: GeoJSONDiagnostic[];
|
|
13
|
+
}
|
|
14
|
+
export interface GeoJSONNormalizationOptions {
|
|
15
|
+
/** Opt in to Leaflet.draw-compatible single geometries. */
|
|
16
|
+
expandMulti?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface GeoJSONImportResult extends GeoJSONValidationSummary {
|
|
19
|
+
data: FeatureCollection | null;
|
|
20
|
+
}
|
|
21
|
+
export interface GeoJSONPatch {
|
|
22
|
+
created: Feature[];
|
|
23
|
+
updated: Feature[];
|
|
24
|
+
deleted: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface GeoJSONDiff extends GeoJSONPatch {
|
|
27
|
+
createdIds: string[];
|
|
28
|
+
updatedIds: string[];
|
|
29
|
+
deletedIds: string[];
|
|
30
|
+
}
|
|
31
|
+
/** Structural RFC 7946 preflight; never mutates its input or a map. */
|
|
32
|
+
export declare function validateGeoJSON(input: unknown): GeoJSONValidationSummary;
|
|
33
|
+
export declare class GeoJSONValidationError extends Error {
|
|
34
|
+
readonly summary: GeoJSONValidationSummary;
|
|
35
|
+
constructor(summary: GeoJSONValidationSummary);
|
|
36
|
+
}
|
|
37
|
+
/** Wrap app shapes, clone metadata, assign missing IDs once, optionally expand. */
|
|
38
|
+
export declare function normalizeGeoJSON(input: unknown, options?: GeoJSONNormalizationOptions): FeatureCollection;
|
|
39
|
+
export declare function importGeoJSONData(input: unknown, options?: GeoJSONNormalizationOptions): GeoJSONImportResult;
|
|
40
|
+
export declare function importGeoJSONText(text: string, options?: GeoJSONNormalizationOptions): GeoJSONImportResult;
|
|
41
|
+
/** Validate export too; source mode refuses divergent child properties rather than losing edits. */
|
|
42
|
+
export declare function exportGeoJSONData(input: FeatureCollection, options?: GeoJSONExportOptions): GeoJSONImportResult;
|
|
43
|
+
/** Explicit URL adapter: no implicit fetching of arbitrary strings. Fetch errors reject. */
|
|
44
|
+
export declare function importGeoJSONURL(url: string | URL, options?: GeoJSONNormalizationOptions & {
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
fetcher?: typeof fetch;
|
|
47
|
+
}): Promise<GeoJSONImportResult>;
|
|
48
|
+
/** ID-based, order-insensitive comparison; property and geometry edits both count. */
|
|
49
|
+
export declare function diffGeoJSON(before: FeatureCollection, after: FeatureCollection): GeoJSONDiff;
|
|
50
|
+
/** Strict, atomic pure patch: reject missing targets, duplicate operations and creates. */
|
|
51
|
+
export declare function applyGeoJSONPatch(base: FeatureCollection, patch: GeoJSONPatch): FeatureCollection;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import type { LayerDefinition } from "../types/layers.js";
|
|
1
2
|
import type { Feature, FeatureCollection, Geometry, Position, Polygon, MultiPolygon, GeoJsonProperties } from "geojson";
|
|
2
3
|
export type GeoJSONImportBehavior = "replace" | "add";
|
|
3
4
|
export interface GeoJSONImportOptions {
|
|
5
|
+
/** Restore the portable registry snapshot; supported with replace only. */
|
|
6
|
+
preserveLayers?: boolean;
|
|
7
|
+
/** Group imported features, including guide/reference or measurement overlays. */
|
|
8
|
+
layer?: LayerDefinition;
|
|
4
9
|
behavior?: GeoJSONImportBehavior;
|
|
5
10
|
fitToData?: boolean;
|
|
11
|
+
/** Reject invalid data before changing layers. Legacy default is false. */
|
|
12
|
+
validate?: boolean;
|
|
6
13
|
}
|
|
7
14
|
export type GeoJSONExportAdapter = "editing" | "source";
|
|
8
15
|
export interface GeoJSONExportOptions {
|
|
16
|
+
/** Include geokit:layers registry metadata. Default false. */
|
|
17
|
+
preserveLayers?: boolean;
|
|
9
18
|
adapter?: GeoJSONExportAdapter;
|
|
10
19
|
}
|
|
11
20
|
export type BBox = [
|
|
@@ -45,8 +54,12 @@ export declare function bboxToBoundsPair(b: BBox): BoundsPair;
|
|
|
45
54
|
* - GeometryCollection → one feature per child geometry
|
|
46
55
|
* Other geometry types are returned unchanged.
|
|
47
56
|
*/
|
|
48
|
-
export declare function expandMultiGeometries(fc: FeatureCollection
|
|
49
|
-
|
|
57
|
+
export declare function expandMultiGeometries(fc: FeatureCollection, options?: {
|
|
58
|
+
preserveMetadata?: boolean;
|
|
59
|
+
}): FeatureCollection;
|
|
60
|
+
export declare function adaptFeatureCollectionForExport(fc: FeatureCollection, options?: GeoJSONExportOptions & {
|
|
61
|
+
provenanceOnly?: boolean;
|
|
62
|
+
}): FeatureCollection;
|
|
50
63
|
/**
|
|
51
64
|
* Check if a geometry is a Polygon
|
|
52
65
|
*/
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Feature, FeatureCollection, GeoJsonProperties, Geometry, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Position } from "geojson";
|
|
2
|
+
export type SupportedGeoJSON = Geometry | Feature<Geometry> | FeatureCollection<Geometry>;
|
|
3
|
+
export type GrowerGeometryErrorCode = "invalid-input" | "invalid-options" | "unsupported-geometry" | "topology-error" | "empty-result" | "operation-failed";
|
|
4
|
+
export interface GrowerGeometryError {
|
|
5
|
+
code: GrowerGeometryErrorCode;
|
|
6
|
+
message: string;
|
|
7
|
+
details?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export type GrowerGeometryResult<T> = {
|
|
10
|
+
ok: true;
|
|
11
|
+
value: T;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: GrowerGeometryError;
|
|
15
|
+
};
|
|
16
|
+
export type BufferedGeoJSON = Feature<Polygon | MultiPolygon> | FeatureCollection<Polygon | MultiPolygon>;
|
|
17
|
+
export type SplitterGeometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;
|
|
18
|
+
export interface BufferGeoJSONOptions {
|
|
19
|
+
/** Polygonization resolution per quadrant. */
|
|
20
|
+
steps?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface SimplifyGeoJSONOptions {
|
|
23
|
+
/** Ramer-Douglas-Peucker tolerance in longitude/latitude degrees. */
|
|
24
|
+
toleranceDegrees: number;
|
|
25
|
+
highQuality?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface GeoJSONMeasurements {
|
|
28
|
+
/** Open LineString and MultiLineString distance. */
|
|
29
|
+
lengthMeters: number;
|
|
30
|
+
/** Total exterior and hole-ring boundary distance. */
|
|
31
|
+
perimeterMeters: number;
|
|
32
|
+
/** Geodesic Polygon and MultiPolygon area, with holes removed. */
|
|
33
|
+
areaSquareMeters: number;
|
|
34
|
+
}
|
|
35
|
+
export type MeasurementSystem = "metric" | "imperial";
|
|
36
|
+
export type DistanceUnit = "m" | "km" | "ft" | "mi";
|
|
37
|
+
export type AreaUnit = "m²" | "ha" | "ft²" | "ac";
|
|
38
|
+
export interface FormattedQuantity<Unit extends string> {
|
|
39
|
+
/** Converted, unrounded value. */
|
|
40
|
+
value: number;
|
|
41
|
+
unit: Unit;
|
|
42
|
+
/** Locale-formatted value and unit label. */
|
|
43
|
+
text: string;
|
|
44
|
+
}
|
|
45
|
+
export interface FormattedGeoJSONMeasurements {
|
|
46
|
+
length: FormattedQuantity<DistanceUnit>;
|
|
47
|
+
perimeter: FormattedQuantity<DistanceUnit>;
|
|
48
|
+
area: FormattedQuantity<AreaUnit>;
|
|
49
|
+
}
|
|
50
|
+
export interface MeasurementFormatOptions {
|
|
51
|
+
locale?: string;
|
|
52
|
+
maximumFractionDigits?: number;
|
|
53
|
+
/** Switch large values to km/mi and ha/ac. Defaults to false. */
|
|
54
|
+
autoScale?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface RowSpacingGuideOptions {
|
|
57
|
+
/** Number of parallel guides on each side of the baseline. Defaults to 2. */
|
|
58
|
+
rowsPerSide?: number;
|
|
59
|
+
/** Include an unchanged clone of the baseline. Defaults to true. */
|
|
60
|
+
includeBaseline?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface IrrigationZoneOptions {
|
|
63
|
+
/** Number of equal-width concentric zones. Defaults to 1. */
|
|
64
|
+
zoneCount?: number;
|
|
65
|
+
/** Vertices used to approximate each circle. Defaults to 64. */
|
|
66
|
+
steps?: number;
|
|
67
|
+
}
|
|
68
|
+
/** Practical starting values only; callers remain responsible for crop/system design. */
|
|
69
|
+
export declare const GROWER_PRESETS: {
|
|
70
|
+
readonly bedWidthMeters: {
|
|
71
|
+
readonly compact: 0.75;
|
|
72
|
+
readonly standard: 1;
|
|
73
|
+
readonly wide: 1.2;
|
|
74
|
+
};
|
|
75
|
+
readonly rowSpacingMeters: {
|
|
76
|
+
readonly dense: 0.15;
|
|
77
|
+
readonly vegetables: 0.3;
|
|
78
|
+
readonly orchard: 3;
|
|
79
|
+
};
|
|
80
|
+
readonly irrigationRadiusMeters: {
|
|
81
|
+
readonly dripEmitter: 0.3;
|
|
82
|
+
readonly microSprinkler: 3;
|
|
83
|
+
readonly sprinkler: 12;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** Buffer valid WGS84 GeoJSON by a signed distance in meters. */
|
|
87
|
+
export declare function bufferGeoJSON(input: SupportedGeoJSON, distanceMeters: number, options?: BufferGeoJSONOptions): GrowerGeometryResult<BufferedGeoJSON>;
|
|
88
|
+
/** Split one LineString feature. A non-intersecting splitter is an explicit error. */
|
|
89
|
+
export declare function splitGeoJSON(line: Feature<LineString>, splitter: Feature<SplitterGeometry>): GrowerGeometryResult<FeatureCollection<LineString>>;
|
|
90
|
+
/** Perform a real polygon overlay union; disconnected inputs become a MultiPolygon. */
|
|
91
|
+
export declare function mergeGeoJSON(polygons: FeatureCollection<Polygon | MultiPolygon>, properties?: GeoJsonProperties): GrowerGeometryResult<Feature<Polygon | MultiPolygon>>;
|
|
92
|
+
/** Simplify line/polygon GeoJSON without mutating input; tolerance is explicitly degrees. */
|
|
93
|
+
export declare function simplifyGeoJSON<T extends SupportedGeoJSON>(input: T, options: SimplifyGeoJSONOptions): GrowerGeometryResult<T>;
|
|
94
|
+
/** Return Turf's vertex-mean centroid as a Point feature. */
|
|
95
|
+
export declare function centroidGeoJSON(input: SupportedGeoJSON, properties?: GeoJsonProperties): GrowerGeometryResult<Feature<Point>>;
|
|
96
|
+
/** Return [west, south, east, north], always recomputing stale GeoJSON bbox fields. */
|
|
97
|
+
export declare function boundingBoxGeoJSON(input: SupportedGeoJSON): GrowerGeometryResult<[number, number, number, number]>;
|
|
98
|
+
/** Measure all geometries; holes and multipart members are accumulated. */
|
|
99
|
+
export declare function measureGeoJSON(input: SupportedGeoJSON): GrowerGeometryResult<GeoJSONMeasurements>;
|
|
100
|
+
/** Convert and format an existing SI measurement result. */
|
|
101
|
+
export declare function formatMeasurements(measurements: GeoJSONMeasurements, system: MeasurementSystem, options?: MeasurementFormatOptions): GrowerGeometryResult<FormattedGeoJSONMeasurements>;
|
|
102
|
+
/** Create the two parallel edge guides for a centerline and full bed width. */
|
|
103
|
+
export declare function createBedWidthGuides<T extends LineString | MultiLineString>(centerLine: Feature<T>, bedWidthMeters: number): GrowerGeometryResult<FeatureCollection<T>>;
|
|
104
|
+
/** Create evenly spaced guide lines on both sides of a baseline. */
|
|
105
|
+
export declare function createRowSpacingGuides<T extends LineString | MultiLineString>(baseline: Feature<T>, spacingMeters: number, options?: RowSpacingGuideOptions): GrowerGeometryResult<FeatureCollection<T>>;
|
|
106
|
+
/** Bake one or more equal-width concentric irrigation zones. */
|
|
107
|
+
export declare function createIrrigationZones(center: Position, outerRadiusMeters: number, options?: IrrigationZoneOptions): GrowerGeometryResult<FeatureCollection<Polygon>>;
|