109 lines
4.2 KiB
TypeScript
109 lines
4.2 KiB
TypeScript
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, DrawInteractions } from "../../common";
|
|
import { BaseModeOptions, CustomStyling, ModeUpdateOptions, TerraDrawBaseDrawMode } from "../base.mode";
|
|
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
import { BehaviorConfig } from "../base.behavior";
|
|
type TerraDrawFreehandModeKeyEvents = {
|
|
cancel: KeyboardEvent["key"] | null;
|
|
finish: KeyboardEvent["key"] | null;
|
|
};
|
|
type FreehandPolygonStyling = {
|
|
fillColor: HexColorStyling;
|
|
fillOpacity: NumericStyling;
|
|
outlineColor: HexColorStyling;
|
|
outlineOpacity: NumericStyling;
|
|
outlineWidth: NumericStyling;
|
|
coordinatePointWidth: NumericStyling;
|
|
coordinatePointColor: HexColorStyling;
|
|
coordinatePointOpacity: NumericStyling;
|
|
coordinatePointOutlineWidth: NumericStyling;
|
|
coordinatePointOutlineColor: HexColorStyling;
|
|
coordinatePointOutlineOpacity: NumericStyling;
|
|
closingPointColor: HexColorStyling;
|
|
closingPointOpacity: NumericStyling;
|
|
closingPointWidth: NumericStyling;
|
|
closingPointOutlineColor: HexColorStyling;
|
|
closingPointOutlineOpacity: NumericStyling;
|
|
closingPointOutlineWidth: NumericStyling;
|
|
};
|
|
interface Cursors {
|
|
start?: Cursor;
|
|
close?: Cursor;
|
|
}
|
|
interface TerraDrawFreehandModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
minDistance?: number;
|
|
smoothing?: number;
|
|
preventPointsNearClose?: boolean;
|
|
autoClose?: boolean;
|
|
autoCloseTimeout?: number;
|
|
keyEvents?: TerraDrawFreehandModeKeyEvents | null;
|
|
cursors?: Cursors;
|
|
drawInteraction?: DrawInteractions;
|
|
showCoordinatePoints?: boolean;
|
|
}
|
|
export declare class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<FreehandPolygonStyling> {
|
|
mode: string;
|
|
private canClose;
|
|
private currentId;
|
|
private closingPointId;
|
|
private minDistance;
|
|
private keyEvents;
|
|
private cursors;
|
|
private preventPointsNearClose;
|
|
private autoClose;
|
|
private autoCloseTimeout;
|
|
private hasLeftStartingPoint;
|
|
private preventNewFeature;
|
|
private drawInteraction;
|
|
private drawType;
|
|
private smoothing;
|
|
private showCoordinatePoints;
|
|
private coordinatePoints;
|
|
private mutateFeature;
|
|
private readFeature;
|
|
constructor(options?: TerraDrawFreehandModeOptions<FreehandPolygonStyling>);
|
|
updateOptions(options?: ModeUpdateOptions<TerraDrawFreehandModeOptions<FreehandPolygonStyling>>): void;
|
|
private moveDrawAllowed;
|
|
private dragDrawAllowed;
|
|
private beginDrawing;
|
|
private addCoordinate;
|
|
/**
|
|
* Uses a simple linear interpolation to smooth the coordinates. The smoothing factor determines how
|
|
* much influence the previous coordinate has on the new coordinate. A smoothing factor of 0 means
|
|
* no smoothing (the target coordinate is used as is), while a smoothing factor close to 1 means a
|
|
* lot of smoothing (the new coordinate will be very close to the previous coordinate).
|
|
* The default value is 0, which means no smoothing.
|
|
* @param previousCoordinate
|
|
* @param targetCoordinate
|
|
* @returns
|
|
*/
|
|
private getSmoothedCoordinate;
|
|
private close;
|
|
/** @internal */
|
|
start(): void;
|
|
/** @internal */
|
|
stop(): void;
|
|
/** @internal */
|
|
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
/** @internal */
|
|
onClick(event: TerraDrawMouseEvent): void;
|
|
/** @internal */
|
|
onKeyDown(): void;
|
|
/** @internal */
|
|
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
/** @internal */
|
|
onDragStart(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
/** @internal */
|
|
onDrag(event: TerraDrawMouseEvent, _setMapDraggability: (enabled: boolean) => void): void;
|
|
/** @internal */
|
|
onDragEnd(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
/** @internal */
|
|
cleanUp(): void;
|
|
/** @internal */
|
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
validateFeature(feature: unknown): StoreValidation;
|
|
afterFeatureUpdated(feature: GeoJSONStoreFeatures): void;
|
|
afterFeatureAdded(feature: GeoJSONStoreFeatures): void;
|
|
registerBehaviors(config: BehaviorConfig): void;
|
|
}
|
|
export {};
|