terra-draw 0.0.1-alpha.54 → 0.0.1-alpha.55
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/dist/common.d.ts +2 -2
- package/dist/modes/base.mode.d.ts +4 -4
- package/dist/modes/great-circle-snapping.behavior.d.ts +2 -1
- package/dist/modes/select/behaviors/drag-coordinate.behavior.d.ts +3 -2
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +3 -2
- package/dist/modes/select/behaviors/midpoint.behavior.d.ts +2 -1
- package/dist/modes/select/behaviors/rotate-feature.behavior.d.ts +2 -1
- package/dist/modes/select/behaviors/scale-feature.behavior.d.ts +2 -1
- package/dist/modes/select/behaviors/selection-point.behavior.d.ts +5 -4
- package/dist/modes/snapping.behavior.d.ts +2 -1
- package/dist/store/spatial-index/spatial-index.d.ts +3 -3
- package/dist/store/store-feature-validation.d.ts +4 -3
- package/dist/store/store.d.ts +24 -13
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +23 -5
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoreChangeHandler, GeoJSONStore, GeoJSONStoreFeatures } from "./store/store";
|
|
1
|
+
import { StoreChangeHandler, GeoJSONStore, GeoJSONStoreFeatures, FeatureId } from "./store/store";
|
|
2
2
|
export type HexColor = `#${string}`;
|
|
3
3
|
export type HexColorStyling = HexColor | ((feature: GeoJSONStoreFeatures) => HexColor);
|
|
4
4
|
export type NumericStyling = number | ((feature: GeoJSONStoreFeatures) => number);
|
|
@@ -74,7 +74,7 @@ export interface TerraDrawChanges {
|
|
|
74
74
|
created: GeoJSONStoreFeatures[];
|
|
75
75
|
updated: GeoJSONStoreFeatures[];
|
|
76
76
|
unchanged: GeoJSONStoreFeatures[];
|
|
77
|
-
deletedIds:
|
|
77
|
+
deletedIds: FeatureId[];
|
|
78
78
|
}
|
|
79
79
|
export type TerraDrawStylingFunction = {
|
|
80
80
|
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
2
|
import { HexColor, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent } from "../common";
|
|
3
|
-
import { GeoJSONStore, GeoJSONStoreFeatures, StoreChangeHandler } from "../store/store";
|
|
3
|
+
import { FeatureId, GeoJSONStore, GeoJSONStoreFeatures, StoreChangeHandler } from "../store/store";
|
|
4
4
|
export type CustomStyling = Record<string, string | number | ((feature: GeoJSONStoreFeatures) => HexColor) | ((feature: GeoJSONStoreFeatures) => number)>;
|
|
5
5
|
export declare enum ModeTypes {
|
|
6
6
|
Drawing = "drawing",
|
|
@@ -41,9 +41,9 @@ export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
|
41
41
|
abstract stop(): void;
|
|
42
42
|
abstract cleanUp(): void;
|
|
43
43
|
abstract styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
44
|
-
onFinish(finishedId:
|
|
45
|
-
onDeselect(deselectedId:
|
|
46
|
-
onSelect(selectedId:
|
|
44
|
+
onFinish(finishedId: FeatureId): void;
|
|
45
|
+
onDeselect(deselectedId: FeatureId): void;
|
|
46
|
+
onSelect(selectedId: FeatureId): void;
|
|
47
47
|
onKeyDown(event: TerraDrawKeyboardEvent): void;
|
|
48
48
|
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
49
49
|
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
@@ -2,12 +2,13 @@ import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
|
2
2
|
import { TerraDrawMouseEvent } from "../common";
|
|
3
3
|
import { Position } from "geojson";
|
|
4
4
|
import { ClickBoundingBoxBehavior } from "./click-bounding-box.behavior";
|
|
5
|
+
import { FeatureId } from "../store/store";
|
|
5
6
|
import { PixelDistanceBehavior } from "./pixel-distance.behavior";
|
|
6
7
|
export declare class GreatCircleSnappingBehavior extends TerraDrawModeBehavior {
|
|
7
8
|
readonly config: BehaviorConfig;
|
|
8
9
|
private readonly pixelDistance;
|
|
9
10
|
private readonly clickBoundingBox;
|
|
10
11
|
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, clickBoundingBox: ClickBoundingBoxBehavior);
|
|
11
|
-
getSnappableCoordinate: (event: TerraDrawMouseEvent, currentFeatureId?:
|
|
12
|
+
getSnappableCoordinate: (event: TerraDrawMouseEvent, currentFeatureId?: FeatureId) => Position | undefined;
|
|
12
13
|
private getSnappableEnds;
|
|
13
14
|
}
|
|
@@ -3,6 +3,7 @@ import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
|
3
3
|
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
4
4
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
5
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
6
|
+
import { FeatureId } from "../../../store/store";
|
|
6
7
|
export declare class DragCoordinateBehavior extends TerraDrawModeBehavior {
|
|
7
8
|
readonly config: BehaviorConfig;
|
|
8
9
|
private readonly pixelDistance;
|
|
@@ -11,9 +12,9 @@ export declare class DragCoordinateBehavior extends TerraDrawModeBehavior {
|
|
|
11
12
|
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
12
13
|
private draggedCoordinate;
|
|
13
14
|
private getClosestCoordinate;
|
|
14
|
-
getDraggableIndex(event: TerraDrawMouseEvent, selectedId:
|
|
15
|
+
getDraggableIndex(event: TerraDrawMouseEvent, selectedId: FeatureId): number;
|
|
15
16
|
drag(event: TerraDrawMouseEvent, allowSelfIntersection: boolean): boolean;
|
|
16
17
|
isDragging(): boolean;
|
|
17
|
-
startDragging(id:
|
|
18
|
+
startDragging(id: FeatureId, index: number): void;
|
|
18
19
|
stopDragging(): void;
|
|
19
20
|
}
|
|
@@ -3,6 +3,7 @@ import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
|
3
3
|
import { FeatureAtPointerEventBehavior } from "./feature-at-pointer-event.behavior";
|
|
4
4
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
5
5
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
6
|
+
import { FeatureId } from "../../../store/store";
|
|
6
7
|
export declare class DragFeatureBehavior extends TerraDrawModeBehavior {
|
|
7
8
|
readonly config: BehaviorConfig;
|
|
8
9
|
private readonly featuresAtMouseEvent;
|
|
@@ -11,9 +12,9 @@ export declare class DragFeatureBehavior extends TerraDrawModeBehavior {
|
|
|
11
12
|
constructor(config: BehaviorConfig, featuresAtMouseEvent: FeatureAtPointerEventBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
12
13
|
private draggedFeatureId;
|
|
13
14
|
private dragPosition;
|
|
14
|
-
startDragging(event: TerraDrawMouseEvent, id:
|
|
15
|
+
startDragging(event: TerraDrawMouseEvent, id: FeatureId): void;
|
|
15
16
|
stopDragging(): void;
|
|
16
17
|
isDragging(): boolean;
|
|
17
|
-
canDrag(event: TerraDrawMouseEvent, selectedId:
|
|
18
|
+
canDrag(event: TerraDrawMouseEvent, selectedId: FeatureId): boolean;
|
|
18
19
|
drag(event: TerraDrawMouseEvent): false | undefined;
|
|
19
20
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Point, Position } from "geojson";
|
|
2
2
|
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
3
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
4
|
+
import { FeatureId } from "../../../store/store";
|
|
4
5
|
export declare class MidPointBehavior extends TerraDrawModeBehavior {
|
|
5
6
|
readonly config: BehaviorConfig;
|
|
6
7
|
private readonly selectionPointBehavior;
|
|
@@ -9,7 +10,7 @@ export declare class MidPointBehavior extends TerraDrawModeBehavior {
|
|
|
9
10
|
get ids(): string[];
|
|
10
11
|
set ids(_: string[]);
|
|
11
12
|
insert(midPointId: string, coordinatePrecision: number): void;
|
|
12
|
-
create(selectedCoords: Position[], featureId:
|
|
13
|
+
create(selectedCoords: Position[], featureId: FeatureId, coordinatePrecision: number): void;
|
|
13
14
|
delete(): void;
|
|
14
15
|
getUpdated(updatedCoordinates: Position[]): {
|
|
15
16
|
id: string;
|
|
@@ -2,6 +2,7 @@ import { TerraDrawMouseEvent } from "../../../common";
|
|
|
2
2
|
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
3
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
4
4
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
|
+
import { FeatureId } from "../../../store/store";
|
|
5
6
|
export declare class RotateFeatureBehavior extends TerraDrawModeBehavior {
|
|
6
7
|
readonly config: BehaviorConfig;
|
|
7
8
|
private readonly selectionPoints;
|
|
@@ -9,5 +10,5 @@ export declare class RotateFeatureBehavior extends TerraDrawModeBehavior {
|
|
|
9
10
|
constructor(config: BehaviorConfig, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
10
11
|
private lastBearing;
|
|
11
12
|
reset(): void;
|
|
12
|
-
rotate(event: TerraDrawMouseEvent, selectedId:
|
|
13
|
+
rotate(event: TerraDrawMouseEvent, selectedId: FeatureId): void;
|
|
13
14
|
}
|
|
@@ -2,6 +2,7 @@ import { TerraDrawMouseEvent } from "../../../common";
|
|
|
2
2
|
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
3
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
4
4
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
|
+
import { FeatureId } from "../../../store/store";
|
|
5
6
|
export declare class ScaleFeatureBehavior extends TerraDrawModeBehavior {
|
|
6
7
|
readonly config: BehaviorConfig;
|
|
7
8
|
private readonly selectionPoints;
|
|
@@ -9,5 +10,5 @@ export declare class ScaleFeatureBehavior extends TerraDrawModeBehavior {
|
|
|
9
10
|
constructor(config: BehaviorConfig, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
10
11
|
private lastDistance;
|
|
11
12
|
reset(): void;
|
|
12
|
-
scale(event: TerraDrawMouseEvent, selectedId:
|
|
13
|
+
scale(event: TerraDrawMouseEvent, selectedId: FeatureId): void;
|
|
13
14
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { LineString, Point, Polygon, Position } from "geojson";
|
|
2
2
|
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
+
import { FeatureId } from "../../../store/store";
|
|
3
4
|
export declare class SelectionPointBehavior extends TerraDrawModeBehavior {
|
|
4
5
|
constructor(config: BehaviorConfig);
|
|
5
6
|
private _selectionPoints;
|
|
6
|
-
get ids():
|
|
7
|
-
set ids(_:
|
|
8
|
-
create(selectedCoords: Position[], type: Polygon["type"] | LineString["type"], featureId:
|
|
7
|
+
get ids(): FeatureId[];
|
|
8
|
+
set ids(_: FeatureId[]);
|
|
9
|
+
create(selectedCoords: Position[], type: Polygon["type"] | LineString["type"], featureId: FeatureId): void;
|
|
9
10
|
delete(): void;
|
|
10
11
|
getUpdated(updatedCoordinates: Position[]): {
|
|
11
|
-
id:
|
|
12
|
+
id: FeatureId;
|
|
12
13
|
geometry: Point;
|
|
13
14
|
}[] | undefined;
|
|
14
15
|
getOneUpdated(index: number, updatedCoordinate: Position): {
|
|
@@ -2,6 +2,7 @@ import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
|
2
2
|
import { TerraDrawMouseEvent } from "../common";
|
|
3
3
|
import { Position } from "geojson";
|
|
4
4
|
import { ClickBoundingBoxBehavior } from "./click-bounding-box.behavior";
|
|
5
|
+
import { FeatureId } from "../store/store";
|
|
5
6
|
import { PixelDistanceBehavior } from "./pixel-distance.behavior";
|
|
6
7
|
export declare class SnappingBehavior extends TerraDrawModeBehavior {
|
|
7
8
|
readonly config: BehaviorConfig;
|
|
@@ -10,6 +11,6 @@ export declare class SnappingBehavior extends TerraDrawModeBehavior {
|
|
|
10
11
|
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, clickBoundingBox: ClickBoundingBoxBehavior);
|
|
11
12
|
/** Returns the nearest snappable coordinate - on first click there is no currentId so no need to provide */
|
|
12
13
|
getSnappableCoordinateFirstClick: (event: TerraDrawMouseEvent) => Position | undefined;
|
|
13
|
-
getSnappableCoordinate: (event: TerraDrawMouseEvent, currentFeatureId:
|
|
14
|
+
getSnappableCoordinate: (event: TerraDrawMouseEvent, currentFeatureId: FeatureId) => Position | undefined;
|
|
14
15
|
private getSnappable;
|
|
15
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GeoJSONStoreFeatures } from "../store";
|
|
1
|
+
import { FeatureId, GeoJSONStoreFeatures } from "../store";
|
|
2
2
|
export declare class SpatialIndex {
|
|
3
3
|
private tree;
|
|
4
4
|
private idToNode;
|
|
@@ -11,8 +11,8 @@ export declare class SpatialIndex {
|
|
|
11
11
|
insert(feature: GeoJSONStoreFeatures): void;
|
|
12
12
|
load(features: GeoJSONStoreFeatures[]): void;
|
|
13
13
|
update(feature: GeoJSONStoreFeatures): void;
|
|
14
|
-
remove(featureId:
|
|
14
|
+
remove(featureId: FeatureId): void;
|
|
15
15
|
clear(): void;
|
|
16
|
-
search(feature: GeoJSONStoreFeatures):
|
|
16
|
+
search(feature: GeoJSONStoreFeatures): FeatureId[];
|
|
17
17
|
collides(feature: GeoJSONStoreFeatures): boolean;
|
|
18
18
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { GeoJSONStoreFeatures } from "./store";
|
|
1
|
+
import { FeatureId, GeoJSONStoreFeatures, IdStrategy } from "./store";
|
|
2
2
|
export declare const StoreValidationErrors: {
|
|
3
3
|
readonly FeatureHasNoId: "Feature has no id";
|
|
4
4
|
readonly FeatureIsNotObject: "Feature is not object";
|
|
5
5
|
readonly InvalidTrackedProperties: "updatedAt and createdAt are not valid timestamps";
|
|
6
6
|
readonly FeatureHasNoMode: "Feature does not have a set mode";
|
|
7
|
-
readonly
|
|
7
|
+
readonly FeatureIdIsNotValidGeoJSON: "Feature must be string or number as per GeoJSON spec";
|
|
8
|
+
readonly FeatureIdIsNotValid: "Feature must match the id strategy (default is UUID4)";
|
|
8
9
|
readonly FeatureHasNoGeometry: "Feature has no geometry";
|
|
9
10
|
readonly FeatureHasNoProperties: "Feature has no properties";
|
|
10
11
|
readonly FeatureGeometryNotSupported: "Feature is not Point, LineString or Polygon";
|
|
@@ -12,4 +13,4 @@ export declare const StoreValidationErrors: {
|
|
|
12
13
|
readonly InvalidModeProperty: "Feature does not have a valid mode property";
|
|
13
14
|
};
|
|
14
15
|
export declare function isValidTimestamp(timestamp: unknown): boolean;
|
|
15
|
-
export declare function isValidStoreFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
16
|
+
export declare function isValidStoreFeature(feature: unknown, isValidId: IdStrategy<FeatureId>["isValidId"]): feature is GeoJSONStoreFeatures;
|
package/dist/store/store.d.ts
CHANGED
|
@@ -9,38 +9,49 @@ export type GeoJSONStoreGeometries = Polygon | LineString | Point;
|
|
|
9
9
|
export type BBoxPolygon = Feature<Polygon, DefinedProperties>;
|
|
10
10
|
export type GeoJSONStoreFeatures = Feature<GeoJSONStoreGeometries, DefinedProperties>;
|
|
11
11
|
export type StoreChangeEvents = "delete" | "create" | "update" | "styling";
|
|
12
|
-
export type StoreChangeHandler = (ids:
|
|
13
|
-
export type
|
|
12
|
+
export type StoreChangeHandler = (ids: FeatureId[], change: StoreChangeEvents) => void;
|
|
13
|
+
export type FeatureId = string | number;
|
|
14
|
+
export type IdStrategy<Id extends FeatureId> = {
|
|
15
|
+
isValidId: (id: Id) => boolean;
|
|
16
|
+
getId: () => Id;
|
|
17
|
+
};
|
|
18
|
+
export type GeoJSONStoreConfig<Id extends FeatureId> = {
|
|
19
|
+
idStrategy?: IdStrategy<Id>;
|
|
14
20
|
tracked?: boolean;
|
|
15
21
|
};
|
|
16
|
-
export declare
|
|
17
|
-
|
|
22
|
+
export declare const defaultIdStrategy: {
|
|
23
|
+
getId: <FeatureId_1>() => FeatureId_1;
|
|
24
|
+
isValidId: (id: FeatureId) => boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare class GeoJSONStore<Id extends FeatureId = FeatureId> {
|
|
27
|
+
constructor(config?: GeoJSONStoreConfig<Id>);
|
|
28
|
+
idStrategy: IdStrategy<Id>;
|
|
18
29
|
private tracked;
|
|
19
30
|
private spatialIndex;
|
|
20
31
|
private store;
|
|
21
32
|
private _onChange;
|
|
22
|
-
private getId;
|
|
23
33
|
private clone;
|
|
24
|
-
|
|
34
|
+
getId(): FeatureId;
|
|
35
|
+
has(id: FeatureId): boolean;
|
|
25
36
|
load(data: GeoJSONStoreFeatures[], featureValidation?: (feature: unknown, tracked?: boolean) => boolean): void;
|
|
26
37
|
search(bbox: BBoxPolygon, filter?: (feature: GeoJSONStoreFeatures) => boolean): GeoJSONStoreFeatures[];
|
|
27
38
|
registerOnChange(onChange: StoreChangeHandler): void;
|
|
28
|
-
getGeometryCopy<T extends GeoJSONStoreGeometries>(id:
|
|
29
|
-
getPropertiesCopy(id:
|
|
39
|
+
getGeometryCopy<T extends GeoJSONStoreGeometries>(id: FeatureId): T;
|
|
40
|
+
getPropertiesCopy(id: FeatureId): DefinedProperties;
|
|
30
41
|
updateProperty(propertiesToUpdate: {
|
|
31
|
-
id:
|
|
42
|
+
id: FeatureId;
|
|
32
43
|
property: string;
|
|
33
44
|
value: JSON;
|
|
34
45
|
}[]): void;
|
|
35
46
|
updateGeometry(geometriesToUpdate: {
|
|
36
|
-
id:
|
|
47
|
+
id: FeatureId;
|
|
37
48
|
geometry: GeoJSONStoreGeometries;
|
|
38
49
|
}[]): void;
|
|
39
|
-
create(features: {
|
|
50
|
+
create<Id extends FeatureId>(features: {
|
|
40
51
|
geometry: GeoJSONStoreGeometries;
|
|
41
52
|
properties?: JSONObject;
|
|
42
|
-
}[]):
|
|
43
|
-
delete(ids:
|
|
53
|
+
}[]): Id[];
|
|
54
|
+
delete(ids: FeatureId[]): void;
|
|
44
55
|
copyAll(): GeoJSONStoreFeatures[];
|
|
45
56
|
clear(): void;
|
|
46
57
|
size(): number;
|