@florasync/leaflet-geokit 0.8.2 → 0.9.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 +14 -0
- package/README.md +140 -11
- package/dist/django/index.js +8999 -5044
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +21508 -5914
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +18022 -2425
- package/dist/leaflet-geokit.external.es.js.map +1 -1
- package/dist/leaflet-geokit.umd.js +270 -19
- 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 +9001 -5036
- 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 +9043 -5078
- package/dist/react-bundled/index.js.map +1 -1
- package/dist/types/components/LeafletDrawMapElement.d.ts +40 -1
- package/dist/types/external.d.ts +6 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/lib/LayerRegistry.d.ts +19 -0
- package/dist/types/lib/MapController.d.ts +91 -1
- 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 +9 -1
- package/dist/types/lib/layer-style-panel.d.ts +3 -0
- 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 +2 -0
- 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/types/events.d.ts +14 -0
- package/dist/types/types/layers.d.ts +65 -0
- package/dist/types/types/public.d.ts +157 -2
- 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/geojson-pipelines.md +145 -0
- package/docs/google-maps-adapter-spike.md +77 -0
- package/docs/grower-geometry.md +237 -0
- package/docs/layers.md +136 -0
- package/docs/providers.md +191 -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-styling.md +118 -0
- package/package.json +24 -3
- package/dist/preact/index-DCGBWrrm.js +0 -4580
- package/dist/preact/index-DCGBWrrm.js.map +0 -1
- package/dist/react/index-DCGBWrrm.js +0 -4580
- package/dist/react/index-DCGBWrrm.js.map +0 -1
|
@@ -3,6 +3,9 @@ import type { LogLevel } from "../utils/logger";
|
|
|
3
3
|
import type { StatusEventDetail } from "../types/events";
|
|
4
4
|
import type { GeoJSONExportAdapter, GeoJSONExportOptions, GeoJSONImportBehavior, GeoJSONImportOptions } from "../utils/geojson";
|
|
5
5
|
import type * as Leaflet from "leaflet";
|
|
6
|
+
import type { MapLayer, LayerStyle, LayerCakeSession, LayerCakeSessionUpdate } from "../types/layers";
|
|
7
|
+
export * from "../types/layers";
|
|
8
|
+
import type { BasemapAdapter, ProviderDiagnostics } from "../lib/providers";
|
|
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";
|
|
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";
|
|
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>>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Keyboard and accessibility contract
|
|
2
|
+
|
|
3
|
+
GeoKit 0.8.3 keeps the existing framework-agnostic tool command API. Keyboard
|
|
4
|
+
activation uses the same toolbar command path as a pointer click, including the
|
|
5
|
+
existing capability gates and public lifecycle events.
|
|
6
|
+
|
|
7
|
+
## Command map
|
|
8
|
+
|
|
9
|
+
| Key | Context | Action |
|
|
10
|
+
| ---------------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| Tab / Shift+Tab | Map controls | Visit enabled controls using the browser's normal tab order; no toolbar focus trap. |
|
|
12
|
+
| Left / Right | Horizontal toolbar | Previous / next enabled tool, wrapping at the ends. |
|
|
13
|
+
| Up / Down | Vertical toolbar | Previous / next enabled tool, wrapping at the ends. |
|
|
14
|
+
| Home / End | Toolbar | First / last enabled tool. |
|
|
15
|
+
| Enter / Space | Tool button | Activate the tool. Also works on native Leaflet anchor buttons and the ruler control. |
|
|
16
|
+
| Escape | Active map mode | Deactivate/cancel using the existing select command; no export. |
|
|
17
|
+
| Escape | Focused tool popover or settings dialog | Close it and return focus to its trigger. A subsequent Escape can cancel an active map mode. |
|
|
18
|
+
| Ctrl+Enter / Cmd+Enter | Map or toolbar | Commit active edit/delete changes; confirm a pending move; otherwise export completed geometry via the save command. |
|
|
19
|
+
| Tab / Shift+Tab | Measurement units dialog | Cycle through the selected unit radio and Close button. Radio arrow keys remain native. |
|
|
20
|
+
|
|
21
|
+
Text fields, selects, editable content and dialogs do not receive map-level
|
|
22
|
+
shortcuts. Single-letter shortcuts are deliberately avoided. Measurement mode is
|
|
23
|
+
reached with the toolbar's **Measure distance** button; Measurement settings opens
|
|
24
|
+
the named units dialog. Disabled tools are not keyboard-activatable. Their
|
|
25
|
+
requirements are available through the existing capability API.
|
|
26
|
+
|
|
27
|
+
These commands do not implement keyboard vertex placement or move a selected
|
|
28
|
+
geometry with arrow keys. Complete drawing with the tool's existing interaction;
|
|
29
|
+
Ctrl+Enter exports completed geometry rather than finishing an unfinished polygon
|
|
30
|
+
or layer-cake session. Layer-cake session Save/Cancel controls remain separate.
|
|
31
|
+
|
|
32
|
+
## Semantics and announcements
|
|
33
|
+
|
|
34
|
+
- Managed groups and native draw/edit groups expose named `toolbar` roles and
|
|
35
|
+
orientation; buttons have accessible names and native anchor controls expose
|
|
36
|
+
`button` roles.
|
|
37
|
+
- Persistent managed tools (including ruler) reflect `aria-pressed`.
|
|
38
|
+
- Configured popover triggers expose `aria-haspopup="dialog"` and explicit
|
|
39
|
+
`aria-expanded` state. Non-modal popovers receive focus without trapping Tab.
|
|
40
|
+
Their inside/outside click handling uses the composed event path across shadow
|
|
41
|
+
DOM. Escape is scoped to the originating control/popover, not every map.
|
|
42
|
+
- Measurement settings has an accessible dialog name, bounded Tab navigation,
|
|
43
|
+
and focus restoration. The existing layer-style dialog retains its own focus
|
|
44
|
+
restoration.
|
|
45
|
+
- Persistent `role="status"` / polite and `role="alert"` / assertive regions
|
|
46
|
+
announce tool outcomes and failure reasons. Messages use text, never HTML, and
|
|
47
|
+
survive toolbar configuration rerenders.
|
|
48
|
+
|
|
49
|
+
## Contrast, motion, and target sizing
|
|
50
|
+
|
|
51
|
+
`forced-colors: active` and `prefers-contrast: more` choose system-color defaults
|
|
52
|
+
through the existing `--geokit-toolbar-*`, `--geokit-tool-*`,
|
|
53
|
+
`--geokit-popover-*`, and `--geokit-panel-*` tokens. Focus and pressed states have
|
|
54
|
+
visible outlines as well as color changes. Host overrides should preserve these
|
|
55
|
+
states and contrast; tokens can also be overridden on the exposed parts.
|
|
56
|
+
|
|
57
|
+
`prefers-reduced-motion: reduce` removes animations/transitions in the map subtree
|
|
58
|
+
and disables smooth scrolling. `--geokit-reduced-motion-duration` defaults to `0s`
|
|
59
|
+
in this media mode. This does not change JavaScript Leaflet animation options.
|
|
60
|
+
|
|
61
|
+
Managed buttons retain 44px desktop defaults and 48px narrow responsive defaults.
|
|
62
|
+
Dense layouts reduce default group padding, not target size. Explicit host size
|
|
63
|
+
and padding overrides remain authoritative; hosts must not reduce usable targets.
|
|
64
|
+
The responsive layout reserves native zoom/attribution space and keeps enabled
|
|
65
|
+
controls reachable through overflow scrolling. See [Toolbar layout](toolbar-layout.md).
|
|
66
|
+
|
|
67
|
+
## Repeatable checks
|
|
68
|
+
|
|
69
|
+
From the repository root:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
npm run typecheck
|
|
73
|
+
npm run test:unit:focused -- tests/toolbar-accessibility.spec.ts tests/toolbar-contract.spec.ts tests/tool-lifecycle.spec.ts tests/map-controller.spec.ts tests/draw-event-runtime.spec.ts
|
|
74
|
+
npm run test:unit:focused -- tests/draw-move-pointer.spec.ts
|
|
75
|
+
npx playwright test -c playwright.accessibility.config.ts --output="$PAPERCLIP_RUN_SCRATCH_DIR/a11y-results"
|
|
76
|
+
PLAYWRIGHT_JSON_OUTPUT_NAME="$PAPERCLIP_RUN_SCRATCH_DIR/touch-report.json" npx playwright test -c playwright.touch.config.ts --reporter=list,json --output="$PAPERCLIP_RUN_SCRATCH_DIR/touch-results"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Outside Paperclip, choose a writable output directory instead. The finite
|
|
80
|
+
Playwright-owned Vite preview uses port 5187, disables HMR, and shuts down after
|
|
81
|
+
the suite. It does not reuse an existing server.
|
|
82
|
+
|
|
83
|
+
The Chromium suite exercises all 14 public tools using keyboard activation on
|
|
84
|
+
the existing irrigation harness, native anchor activation, edit/delete commit,
|
|
85
|
+
measurement cancellation, modal focus, popover shadow-DOM clicks, error/status
|
|
86
|
+
announcements, high-contrast/reduced-motion media, and measured mobile targets.
|
|
87
|
+
It also runs the existing CSS-contract and responsive-layout regressions,
|
|
88
|
+
including 320px and 390px maps. These are basic accessibility checks, not an axe
|
|
89
|
+
scan or screen-reader certification.
|
|
90
|
+
|
|
91
|
+
## Touch geometry contract and verified coverage
|
|
92
|
+
|
|
93
|
+
Bundled `DrawMove` and external `RuntimeDrawMove` share `move-pointer.ts`.
|
|
94
|
+
Move captures the primary pointer on the stable map container, including when a
|
|
95
|
+
feature is Canvas-rendered. It disables map dragging only for the active gesture
|
|
96
|
+
and restores its prior enabled state on release. Pointer cancellation, lost
|
|
97
|
+
capture, mode switch and destruction release capture and roll back uncommitted
|
|
98
|
+
geometry. Normal pointerup preserves a transaction for Save/Cancel; Save clears
|
|
99
|
+
rollback state before notifying synchronous completion listeners. There is no
|
|
100
|
+
parallel compatibility-mouse drag path.
|
|
101
|
+
|
|
102
|
+
Draw, edit and delete reuse Leaflet.draw and the irrigation harness rather than
|
|
103
|
+
adding a second gesture implementation. Coarse-pointer edit handles expose 44px
|
|
104
|
+
hit targets around 12px visible vertices. Move confirmation controls have 44px
|
|
105
|
+
minimum targets, suppress map touch propagation, and sit above bottom toolbars.
|
|
106
|
+
|
|
107
|
+
`e2e/touch-geometry.spec.ts` passes 20 Chromium tests: ten cases each with Canvas
|
|
108
|
+
and SVG on a 390 × 844 touch viewport. Real `page.touchscreen` taps and Chromium
|
|
109
|
+
CDP `Input.dispatchTouchEvent` drags exercise:
|
|
110
|
+
|
|
111
|
+
- Polygon creation by vertex taps and closure, plus unfinished-draw cancellation.
|
|
112
|
+
- Edit geometry change with cancellation rollback and Save persistence.
|
|
113
|
+
- Delete with cancellation restoration and Save removal.
|
|
114
|
+
- Captured move outside map bounds without map panning; Cancel rollback and Save
|
|
115
|
+
persistence, with no duplicate compatibility mousedown.
|
|
116
|
+
- Browser-generated pointercancel and lost-capture rollback; mouse pointer
|
|
117
|
+
release outside the map remains supported.
|
|
118
|
+
- Mode switch and controller destruction during an active touch, with capture,
|
|
119
|
+
transaction and touch-action cleanup.
|
|
120
|
+
- External Move registration, touch cancellation and confirmation.
|
|
121
|
+
- Measured edit hit targets, an off-center finger drag, and non-overlap with
|
|
122
|
+
toolbar/native controls in the tested layout.
|
|
123
|
+
- Correlated command IDs and exactly one completion for saved draw/edit/delete/
|
|
124
|
+
move operations; cancelled operations do not produce extra completions.
|
|
125
|
+
|
|
126
|
+
Focused unit tests additionally cover both Move implementations with map dragging
|
|
127
|
+
initially disabled, unrelated pointer IDs, pending-transaction protection,
|
|
128
|
+
re-enabling, teardown and synchronous completion listeners. The JSON report
|
|
129
|
+
preserves geometry/event evidence and the harness saves screenshots per case.
|
|
130
|
+
|
|
131
|
+
### Platform and scope constraints
|
|
132
|
+
|
|
133
|
+
This is Chromium touch emulation, not physical Android/iOS certification. CDP
|
|
134
|
+
touchCancel is a browser input event, not `handler.fire` or a constructed DOM
|
|
135
|
+
PointerEvent. Lost-capture testing explicitly calls `releasePointerCapture`
|
|
136
|
+
during a real drag; mode switch/destroy invoke the controller API during a real
|
|
137
|
+
drag. External coverage registers a fresh host namespace against the same
|
|
138
|
+
installed Leaflet version; it does not certify arbitrary host Leaflet versions.
|
|
139
|
+
The gesture fixture uses six managed tools and a polygon. It does not claim
|
|
140
|
+
every shape, dense overlapping vertex target, custom host toolbar layout,
|
|
141
|
+
multi-touch gesture, Firefox or WebKit has been tested. The separate keyboard
|
|
142
|
+
suite continues to cover all 14 public tools and 320px/390px responsive layouts.
|