@loongbao-web-gis-utils/draw-utils-grid-core 0.1.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/LICENSE +21 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +162 -0
- package/dist/index.js +5989 -0
- package/package.json +54 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export declare type Coordinate = [number, number];
|
|
2
|
+
|
|
3
|
+
export declare interface DrawCallbacks {
|
|
4
|
+
insertBiz?: (info: FeatureInfo) => boolean;
|
|
5
|
+
delBiz?: (info: FeatureInfo) => boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare interface DrawOptions {
|
|
9
|
+
type?: GridType;
|
|
10
|
+
accuracy?: number;
|
|
11
|
+
drawNeighbor?: boolean;
|
|
12
|
+
lineWidth?: number;
|
|
13
|
+
primaryColor?: string;
|
|
14
|
+
lineOpacity?: number;
|
|
15
|
+
fillOpacity?: number;
|
|
16
|
+
enableDel?: boolean;
|
|
17
|
+
showLen?: boolean;
|
|
18
|
+
showArea?: boolean;
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
oldFeatures?: FeatureInfo[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare class DrawTool {
|
|
24
|
+
private adapter;
|
|
25
|
+
private callbacks;
|
|
26
|
+
private layerHandle;
|
|
27
|
+
private features;
|
|
28
|
+
private enableDel;
|
|
29
|
+
private _drawEnabled;
|
|
30
|
+
private options;
|
|
31
|
+
constructor(adapter: IMapAdapter, callbacks?: DrawCallbacks);
|
|
32
|
+
get drawEnabled(): boolean;
|
|
33
|
+
private log;
|
|
34
|
+
startDraw(options?: DrawOptions): void;
|
|
35
|
+
stopDraw(): void;
|
|
36
|
+
onDblClick(coordinate: Coordinate): void;
|
|
37
|
+
onClick(coordinate: Coordinate): void;
|
|
38
|
+
getFeatures(): FeatureInfo[];
|
|
39
|
+
getOptions(): Readonly<Required<Omit<DrawOptions, 'oldFeatures'>>>;
|
|
40
|
+
private executeDelete;
|
|
41
|
+
private showLengthLabel;
|
|
42
|
+
private showAreaLabel;
|
|
43
|
+
private getPolygonEdgeMidpoints;
|
|
44
|
+
private getGeoHashDimensions;
|
|
45
|
+
private parsePolygonVertices;
|
|
46
|
+
private getGridCenter;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare interface FeatureInfo {
|
|
50
|
+
id: number;
|
|
51
|
+
type: GridType;
|
|
52
|
+
grids: GridInfo[];
|
|
53
|
+
drawNeighbor: boolean;
|
|
54
|
+
accuracy: number;
|
|
55
|
+
primaryColor: string;
|
|
56
|
+
lineWidth: number;
|
|
57
|
+
lineOpacity: number;
|
|
58
|
+
fillOpacity: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare function generateId(): number;
|
|
62
|
+
|
|
63
|
+
export declare class GeoHashGridStrategy implements GridStrategy {
|
|
64
|
+
readonly type = GridType.GEOHASH;
|
|
65
|
+
latLngToGridKey(lng: number, lat: number, accuracy: number): string;
|
|
66
|
+
getNeighbors(gridKey: string, _accuracy: number): {
|
|
67
|
+
gridKey: string;
|
|
68
|
+
locationType: LocationType;
|
|
69
|
+
}[];
|
|
70
|
+
gridKeyToWKT(gridKey: string): string;
|
|
71
|
+
calculateEdgeLength(gridKey: string, _accuracy: number): number;
|
|
72
|
+
calculateArea(gridKey: string, _accuracy: number): number;
|
|
73
|
+
formatLength(meters: number): string;
|
|
74
|
+
formatArea(squareMeters: number): string;
|
|
75
|
+
buildFeature(id: number, lng: number, lat: number, accuracy: number, drawNeighbor: boolean, primaryColor: string, lineWidth: number, lineOpacity: number, fillOpacity: number): FeatureInfo;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export declare function getGridStrategy(type: GridType): GridStrategy;
|
|
79
|
+
|
|
80
|
+
export declare interface GridInfo {
|
|
81
|
+
primary: boolean;
|
|
82
|
+
gridKey: string;
|
|
83
|
+
wkt: string;
|
|
84
|
+
locationType: LocationType;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare interface GridStrategy {
|
|
88
|
+
readonly type: GridType;
|
|
89
|
+
latLngToGridKey(lng: number, lat: number, accuracy: number): string;
|
|
90
|
+
getNeighbors(gridKey: string, accuracy: number): {
|
|
91
|
+
gridKey: string;
|
|
92
|
+
locationType: LocationType;
|
|
93
|
+
}[];
|
|
94
|
+
gridKeyToWKT(gridKey: string): string;
|
|
95
|
+
calculateEdgeLength(gridKey: string, accuracy: number): number;
|
|
96
|
+
calculateArea(gridKey: string, accuracy: number): number;
|
|
97
|
+
formatLength(meters: number): string;
|
|
98
|
+
formatArea(squareMeters: number): string;
|
|
99
|
+
buildFeature(id: number, lng: number, lat: number, accuracy: number, drawNeighbor: boolean, primaryColor: string, lineWidth: number, lineOpacity: number, fillOpacity: number): FeatureInfo;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare enum GridType {
|
|
103
|
+
H3 = "h3",
|
|
104
|
+
GEOHASH = "geohash"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export declare class H3GridStrategy implements GridStrategy {
|
|
108
|
+
readonly type = GridType.H3;
|
|
109
|
+
latLngToGridKey(lng: number, lat: number, accuracy: number): string;
|
|
110
|
+
getNeighbors(gridKey: string, accuracy: number): {
|
|
111
|
+
gridKey: string;
|
|
112
|
+
locationType: LocationType;
|
|
113
|
+
}[];
|
|
114
|
+
gridKeyToWKT(gridKey: string): string;
|
|
115
|
+
calculateEdgeLength(_gridKey: string, accuracy: number): number;
|
|
116
|
+
calculateArea(gridKey: string, _accuracy: number): number;
|
|
117
|
+
formatLength(meters: number): string;
|
|
118
|
+
formatArea(squareMeters: number): string;
|
|
119
|
+
buildFeature(id: number, lng: number, lat: number, accuracy: number, drawNeighbor: boolean, primaryColor: string, lineWidth: number, lineOpacity: number, fillOpacity: number): FeatureInfo;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export declare interface ILayerHandle {
|
|
123
|
+
readonly id: symbol;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export declare interface IMapAdapter {
|
|
127
|
+
readonly mapInstance: unknown;
|
|
128
|
+
createLayer(): ILayerHandle;
|
|
129
|
+
addFeature(layer: ILayerHandle, feature: FeatureInfo): void;
|
|
130
|
+
removeFeature(layer: ILayerHandle, featureId: number): void;
|
|
131
|
+
clearLayer(layer: ILayerHandle): void;
|
|
132
|
+
destroyLayer(layer: ILayerHandle): void;
|
|
133
|
+
findFeatureIdAtCoordinate(layer: ILayerHandle, coordinate: Coordinate): number | null;
|
|
134
|
+
showDeleteWithConfirm(layer: ILayerHandle, feature: FeatureInfo, coordinate: Coordinate): Promise<boolean>;
|
|
135
|
+
hideDeleteIcon(layer: ILayerHandle): void;
|
|
136
|
+
showFeatureLabel(layer: ILayerHandle, featureId: number, text: string, coordinate: Coordinate, labelKind?: string, color?: string): void;
|
|
137
|
+
hideFeatureLabel(layer: ILayerHandle, featureId: number, labelKind?: string): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export declare function isDuplicateGrid(features: FeatureInfo[], type: GridType, accuracy: number, gridKey: string): boolean;
|
|
141
|
+
|
|
142
|
+
export declare enum LocationType {
|
|
143
|
+
CENTER = "CENTER",
|
|
144
|
+
NORTH = "NORTH",
|
|
145
|
+
SOUTH = "SOUTH",
|
|
146
|
+
EAST = "EAST",
|
|
147
|
+
WEST = "WEST",
|
|
148
|
+
NORTHEAST = "NORTHEAST",
|
|
149
|
+
NORTHWEST = "NORTHWEST",
|
|
150
|
+
SOUTHEAST = "SOUTHEAST",
|
|
151
|
+
SOUTHWEST = "SOUTHWEST"
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export declare interface NeighborInfo {
|
|
155
|
+
gridKey: string;
|
|
156
|
+
locationType: LocationType;
|
|
157
|
+
wkt: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export declare function resetIdGenerator(): void;
|
|
161
|
+
|
|
162
|
+
export { }
|