@honua/sdk-esri-compat 0.0.6-alpha.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/README.md +5 -0
- package/contract/edit-session.d.ts +203 -0
- package/contract/edit-session.d.ts.map +1 -0
- package/contract/edit-session.js +717 -0
- package/contract/index.d.ts +20 -0
- package/contract/index.d.ts.map +1 -0
- package/contract/index.js +15 -0
- package/contract/jobs.d.ts +115 -0
- package/contract/jobs.d.ts.map +1 -0
- package/contract/jobs.js +22 -0
- package/contract/source.d.ts +138 -0
- package/contract/source.d.ts.map +1 -0
- package/contract/source.js +3364 -0
- package/contract/spatial-aggregation.d.ts +312 -0
- package/contract/spatial-aggregation.d.ts.map +1 -0
- package/contract/spatial-aggregation.js +196 -0
- package/contract/types.d.ts +542 -0
- package/contract/types.d.ts.map +1 -0
- package/contract/types.js +171 -0
- package/core/batch.d.ts +37 -0
- package/core/batch.d.ts.map +1 -0
- package/core/batch.js +78 -0
- package/core/cache-state.d.ts +76 -0
- package/core/cache-state.d.ts.map +1 -0
- package/core/cache-state.js +84 -0
- package/core/client.d.ts +289 -0
- package/core/client.d.ts.map +1 -0
- package/core/client.js +2625 -0
- package/core/errors.d.ts +68 -0
- package/core/errors.d.ts.map +1 -0
- package/core/errors.js +116 -0
- package/core/grpc-adapter.d.ts +23 -0
- package/core/grpc-adapter.d.ts.map +1 -0
- package/core/grpc-adapter.js +704 -0
- package/core/odata.d.ts +347 -0
- package/core/odata.d.ts.map +1 -0
- package/core/odata.js +837 -0
- package/core/ogc-conformance.d.ts +35 -0
- package/core/ogc-conformance.d.ts.map +1 -0
- package/core/ogc-conformance.js +121 -0
- package/core/ogc-maps.d.ts +45 -0
- package/core/ogc-maps.d.ts.map +1 -0
- package/core/ogc-maps.js +53 -0
- package/core/ogc-processes.d.ts +92 -0
- package/core/ogc-processes.d.ts.map +1 -0
- package/core/ogc-processes.js +325 -0
- package/core/ogc-tiles.d.ts +55 -0
- package/core/ogc-tiles.d.ts.map +1 -0
- package/core/ogc-tiles.js +81 -0
- package/core/pbf-decoder.d.ts +28 -0
- package/core/pbf-decoder.d.ts.map +1 -0
- package/core/pbf-decoder.js +627 -0
- package/core/query-builder.d.ts +261 -0
- package/core/query-builder.d.ts.map +1 -0
- package/core/query-builder.js +538 -0
- package/core/spatial-filter.d.ts +93 -0
- package/core/spatial-filter.d.ts.map +1 -0
- package/core/spatial-filter.js +153 -0
- package/core/stac.d.ts +43 -0
- package/core/stac.d.ts.map +1 -0
- package/core/stac.js +116 -0
- package/core/surfaces.d.ts +464 -0
- package/core/surfaces.d.ts.map +1 -0
- package/core/surfaces.js +1322 -0
- package/core/types.d.ts +1238 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +13 -0
- package/core/wfs-capabilities.d.ts +143 -0
- package/core/wfs-capabilities.d.ts.map +1 -0
- package/core/wfs-capabilities.js +478 -0
- package/core/wfs-filter.d.ts +118 -0
- package/core/wfs-filter.d.ts.map +1 -0
- package/core/wfs-filter.js +586 -0
- package/core/wfs.d.ts +219 -0
- package/core/wfs.d.ts.map +1 -0
- package/core/wfs.js +406 -0
- package/core/wms-capabilities.d.ts +110 -0
- package/core/wms-capabilities.d.ts.map +1 -0
- package/core/wms-capabilities.js +566 -0
- package/core/wms-types.d.ts +128 -0
- package/core/wms-types.d.ts.map +1 -0
- package/core/wms-types.js +32 -0
- package/core/wms.d.ts +108 -0
- package/core/wms.d.ts.map +1 -0
- package/core/wms.js +182 -0
- package/core/wmts-capabilities.d.ts +82 -0
- package/core/wmts-capabilities.d.ts.map +1 -0
- package/core/wmts-capabilities.js +409 -0
- package/core/wmts.d.ts +80 -0
- package/core/wmts.d.ts.map +1 -0
- package/core/wmts.js +173 -0
- package/esri-compat/basemap-gallery.d.ts +38 -0
- package/esri-compat/basemap-gallery.d.ts.map +1 -0
- package/esri-compat/basemap-gallery.js +159 -0
- package/esri-compat/basemap-layer-list.d.ts +35 -0
- package/esri-compat/basemap-layer-list.d.ts.map +1 -0
- package/esri-compat/basemap-layer-list.js +139 -0
- package/esri-compat/basemap.d.ts +32 -0
- package/esri-compat/basemap.d.ts.map +1 -0
- package/esri-compat/basemap.js +84 -0
- package/esri-compat/bookmarks.d.ts +36 -0
- package/esri-compat/bookmarks.d.ts.map +1 -0
- package/esri-compat/bookmarks.js +108 -0
- package/esri-compat/class-breaks-renderer.d.ts +50 -0
- package/esri-compat/class-breaks-renderer.d.ts.map +1 -0
- package/esri-compat/class-breaks-renderer.js +164 -0
- package/esri-compat/color.d.ts +22 -0
- package/esri-compat/color.d.ts.map +1 -0
- package/esri-compat/color.js +106 -0
- package/esri-compat/controls.d.ts +174 -0
- package/esri-compat/controls.d.ts.map +1 -0
- package/esri-compat/controls.js +479 -0
- package/esri-compat/coordinate-conversion.d.ts +41 -0
- package/esri-compat/coordinate-conversion.d.ts.map +1 -0
- package/esri-compat/coordinate-conversion.js +125 -0
- package/esri-compat/directions.d.ts +45 -0
- package/esri-compat/directions.d.ts.map +1 -0
- package/esri-compat/directions.js +123 -0
- package/esri-compat/editor.d.ts +47 -0
- package/esri-compat/editor.d.ts.map +1 -0
- package/esri-compat/editor.js +170 -0
- package/esri-compat/esri-config.d.ts +16 -0
- package/esri-compat/esri-config.d.ts.map +1 -0
- package/esri-compat/esri-config.js +23 -0
- package/esri-compat/esri-request.d.ts +17 -0
- package/esri-compat/esri-request.d.ts.map +1 -0
- package/esri-compat/esri-request.js +66 -0
- package/esri-compat/event-bus.d.ts +106 -0
- package/esri-compat/event-bus.d.ts.map +1 -0
- package/esri-compat/event-bus.js +90 -0
- package/esri-compat/expand.d.ts +36 -0
- package/esri-compat/expand.d.ts.map +1 -0
- package/esri-compat/expand.js +97 -0
- package/esri-compat/extent.d.ts +43 -0
- package/esri-compat/extent.d.ts.map +1 -0
- package/esri-compat/extent.js +140 -0
- package/esri-compat/feature-form.d.ts +64 -0
- package/esri-compat/feature-form.d.ts.map +1 -0
- package/esri-compat/feature-form.js +137 -0
- package/esri-compat/feature-layer.d.ts +173 -0
- package/esri-compat/feature-layer.d.ts.map +1 -0
- package/esri-compat/feature-layer.js +655 -0
- package/esri-compat/feature-set.d.ts +32 -0
- package/esri-compat/feature-set.d.ts.map +1 -0
- package/esri-compat/feature-set.js +80 -0
- package/esri-compat/feature-table.d.ts +141 -0
- package/esri-compat/feature-table.d.ts.map +1 -0
- package/esri-compat/feature-table.js +500 -0
- package/esri-compat/feature-templates.d.ts +41 -0
- package/esri-compat/feature-templates.d.ts.map +1 -0
- package/esri-compat/feature-templates.js +97 -0
- package/esri-compat/feature.d.ts +33 -0
- package/esri-compat/feature.d.ts.map +1 -0
- package/esri-compat/feature.js +83 -0
- package/esri-compat/graphic.d.ts +46 -0
- package/esri-compat/graphic.d.ts.map +1 -0
- package/esri-compat/graphic.js +103 -0
- package/esri-compat/graphics-layer.d.ts +49 -0
- package/esri-compat/graphics-layer.d.ts.map +1 -0
- package/esri-compat/graphics-layer.js +185 -0
- package/esri-compat/group-layer.d.ts +48 -0
- package/esri-compat/group-layer.d.ts.map +1 -0
- package/esri-compat/group-layer.js +212 -0
- package/esri-compat/identify.d.ts +71 -0
- package/esri-compat/identify.d.ts.map +1 -0
- package/esri-compat/identify.js +299 -0
- package/esri-compat/identity-manager.d.ts +31 -0
- package/esri-compat/identity-manager.d.ts.map +1 -0
- package/esri-compat/identity-manager.js +115 -0
- package/esri-compat/label-class.d.ts +31 -0
- package/esri-compat/label-class.d.ts.map +1 -0
- package/esri-compat/label-class.js +102 -0
- package/esri-compat/layer-list.d.ts +77 -0
- package/esri-compat/layer-list.d.ts.map +1 -0
- package/esri-compat/layer-list.js +342 -0
- package/esri-compat/legend.d.ts +53 -0
- package/esri-compat/legend.d.ts.map +1 -0
- package/esri-compat/legend.js +254 -0
- package/esri-compat/map-image-layer.d.ts +162 -0
- package/esri-compat/map-image-layer.d.ts.map +1 -0
- package/esri-compat/map-image-layer.js +704 -0
- package/esri-compat/map-view.d.ts +315 -0
- package/esri-compat/map-view.d.ts.map +1 -0
- package/esri-compat/map-view.js +1110 -0
- package/esri-compat/map.d.ts +47 -0
- package/esri-compat/map.d.ts.map +1 -0
- package/esri-compat/map.js +209 -0
- package/esri-compat/measurement-2d.d.ts +61 -0
- package/esri-compat/measurement-2d.d.ts.map +1 -0
- package/esri-compat/measurement-2d.js +184 -0
- package/esri-compat/measurement.d.ts +45 -0
- package/esri-compat/measurement.d.ts.map +1 -0
- package/esri-compat/measurement.js +193 -0
- package/esri-compat/oauth-info.d.ts +35 -0
- package/esri-compat/oauth-info.d.ts.map +1 -0
- package/esri-compat/oauth-info.js +115 -0
- package/esri-compat/picture-marker-symbol.d.ts +35 -0
- package/esri-compat/picture-marker-symbol.d.ts.map +1 -0
- package/esri-compat/picture-marker-symbol.js +126 -0
- package/esri-compat/point.d.ts +31 -0
- package/esri-compat/point.d.ts.map +1 -0
- package/esri-compat/point.js +102 -0
- package/esri-compat/polygon.d.ts +31 -0
- package/esri-compat/polygon.d.ts.map +1 -0
- package/esri-compat/polygon.js +107 -0
- package/esri-compat/polyline.d.ts +31 -0
- package/esri-compat/polyline.d.ts.map +1 -0
- package/esri-compat/polyline.js +107 -0
- package/esri-compat/popup-template.d.ts +55 -0
- package/esri-compat/popup-template.d.ts.map +1 -0
- package/esri-compat/popup-template.js +128 -0
- package/esri-compat/popup.d.ts +54 -0
- package/esri-compat/popup.d.ts.map +1 -0
- package/esri-compat/popup.js +312 -0
- package/esri-compat/print.d.ts +47 -0
- package/esri-compat/print.d.ts.map +1 -0
- package/esri-compat/print.js +105 -0
- package/esri-compat/query.d.ts +46 -0
- package/esri-compat/query.d.ts.map +1 -0
- package/esri-compat/query.js +119 -0
- package/esri-compat/reactive-utils.d.ts +23 -0
- package/esri-compat/reactive-utils.d.ts.map +1 -0
- package/esri-compat/reactive-utils.js +178 -0
- package/esri-compat/request.d.ts +41 -0
- package/esri-compat/request.d.ts.map +1 -0
- package/esri-compat/request.js +253 -0
- package/esri-compat/route-layer.d.ts +59 -0
- package/esri-compat/route-layer.d.ts.map +1 -0
- package/esri-compat/route-layer.js +223 -0
- package/esri-compat/route-task.d.ts +88 -0
- package/esri-compat/route-task.d.ts.map +1 -0
- package/esri-compat/route-task.js +225 -0
- package/esri-compat/scene-view.d.ts +41 -0
- package/esri-compat/scene-view.d.ts.map +1 -0
- package/esri-compat/scene-view.js +68 -0
- package/esri-compat/search.d.ts +112 -0
- package/esri-compat/search.d.ts.map +1 -0
- package/esri-compat/search.js +820 -0
- package/esri-compat/simple-fill-symbol.d.ts +27 -0
- package/esri-compat/simple-fill-symbol.d.ts.map +1 -0
- package/esri-compat/simple-fill-symbol.js +85 -0
- package/esri-compat/simple-line-symbol.d.ts +27 -0
- package/esri-compat/simple-line-symbol.d.ts.map +1 -0
- package/esri-compat/simple-line-symbol.js +85 -0
- package/esri-compat/simple-marker-symbol.d.ts +29 -0
- package/esri-compat/simple-marker-symbol.d.ts.map +1 -0
- package/esri-compat/simple-marker-symbol.js +92 -0
- package/esri-compat/simple-renderer.d.ts +29 -0
- package/esri-compat/simple-renderer.d.ts.map +1 -0
- package/esri-compat/simple-renderer.js +92 -0
- package/esri-compat/sketch.d.ts +64 -0
- package/esri-compat/sketch.d.ts.map +1 -0
- package/esri-compat/sketch.js +227 -0
- package/esri-compat/spatial-reference.d.ts +31 -0
- package/esri-compat/spatial-reference.d.ts.map +1 -0
- package/esri-compat/spatial-reference.js +102 -0
- package/esri-compat/swipe.d.ts +34 -0
- package/esri-compat/swipe.d.ts.map +1 -0
- package/esri-compat/swipe.js +93 -0
- package/esri-compat/table-list.d.ts +36 -0
- package/esri-compat/table-list.d.ts.map +1 -0
- package/esri-compat/table-list.js +126 -0
- package/esri-compat/text-symbol.d.ts +37 -0
- package/esri-compat/text-symbol.d.ts.map +1 -0
- package/esri-compat/text-symbol.js +123 -0
- package/esri-compat/tile-layer.d.ts +52 -0
- package/esri-compat/tile-layer.d.ts.map +1 -0
- package/esri-compat/tile-layer.js +167 -0
- package/esri-compat/time-slider.d.ts +70 -0
- package/esri-compat/time-slider.d.ts.map +1 -0
- package/esri-compat/time-slider.js +208 -0
- package/esri-compat/track.d.ts +51 -0
- package/esri-compat/track.d.ts.map +1 -0
- package/esri-compat/track.js +174 -0
- package/esri-compat/unique-value-renderer.d.ts +41 -0
- package/esri-compat/unique-value-renderer.d.ts.map +1 -0
- package/esri-compat/unique-value-renderer.js +127 -0
- package/esri-compat/url.d.ts +12 -0
- package/esri-compat/url.d.ts.map +1 -0
- package/esri-compat/url.js +54 -0
- package/esri-compat/web-map.d.ts +14 -0
- package/esri-compat/web-map.d.ts.map +1 -0
- package/esri-compat/web-map.js +24 -0
- package/gen/honua/v1/feature_service_pb.d.ts +918 -0
- package/gen/honua/v1/feature_service_pb.d.ts.map +1 -0
- package/gen/honua/v1/feature_service_pb.js +375 -0
- package/index.d.ts +130 -0
- package/index.js +65 -0
- package/package.json +22 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class MeasurementCompat {
|
|
3
|
+
view;
|
|
4
|
+
container;
|
|
5
|
+
eventBus;
|
|
6
|
+
loaded;
|
|
7
|
+
loadStatus;
|
|
8
|
+
activeTool;
|
|
9
|
+
linearUnit;
|
|
10
|
+
areaUnit;
|
|
11
|
+
lastMeasurement;
|
|
12
|
+
watchListeners;
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.view = options.view;
|
|
15
|
+
this.container = options.container;
|
|
16
|
+
this.eventBus = options.eventBus ?? resolveCompatEventBus(options.view) ?? new CompatEventBus();
|
|
17
|
+
this.loaded = false;
|
|
18
|
+
this.loadStatus = "not-loaded";
|
|
19
|
+
this.activeTool = options.activeTool;
|
|
20
|
+
this.linearUnit = options.linearUnit ?? "meters";
|
|
21
|
+
this.areaUnit = options.areaUnit ?? "square-meters";
|
|
22
|
+
this.lastMeasurement = undefined;
|
|
23
|
+
this.watchListeners = new Map();
|
|
24
|
+
}
|
|
25
|
+
async load() {
|
|
26
|
+
if (this.loaded) {
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
this.loadStatus = "loading";
|
|
30
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
31
|
+
this.eventBus.emit("measurement.loading", undefined, this);
|
|
32
|
+
this.loaded = true;
|
|
33
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
34
|
+
this.loadStatus = "loaded";
|
|
35
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
36
|
+
this.eventBus.emit("measurement.loaded", undefined, this);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
async when(callback) {
|
|
40
|
+
const widget = await this.load();
|
|
41
|
+
if (callback) {
|
|
42
|
+
callback(widget);
|
|
43
|
+
}
|
|
44
|
+
return widget;
|
|
45
|
+
}
|
|
46
|
+
watch(propertyName, listener) {
|
|
47
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
48
|
+
if (!listeners) {
|
|
49
|
+
listeners = new Set();
|
|
50
|
+
this.watchListeners.set(propertyName, listeners);
|
|
51
|
+
}
|
|
52
|
+
listeners.add(listener);
|
|
53
|
+
return {
|
|
54
|
+
remove: () => {
|
|
55
|
+
listeners?.delete(listener);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
start(tool) {
|
|
60
|
+
this.activeTool = tool;
|
|
61
|
+
this.notifyWatchers("activeTool", this.activeTool);
|
|
62
|
+
this.eventBus.emit("measurement.started", { tool }, this);
|
|
63
|
+
}
|
|
64
|
+
stop() {
|
|
65
|
+
if (!this.activeTool) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const tool = this.activeTool;
|
|
69
|
+
this.activeTool = undefined;
|
|
70
|
+
this.notifyWatchers("activeTool", this.activeTool);
|
|
71
|
+
this.eventBus.emit("measurement.stopped", { tool }, this);
|
|
72
|
+
}
|
|
73
|
+
clear() {
|
|
74
|
+
this.lastMeasurement = undefined;
|
|
75
|
+
this.notifyWatchers("lastMeasurement", this.lastMeasurement);
|
|
76
|
+
this.eventBus.emit("measurement.cleared", undefined, this);
|
|
77
|
+
}
|
|
78
|
+
measureDistance(points) {
|
|
79
|
+
const meters = measureLineInMeters(points);
|
|
80
|
+
const value = convertLinearUnit(meters, this.linearUnit);
|
|
81
|
+
const result = {
|
|
82
|
+
tool: "distance",
|
|
83
|
+
value,
|
|
84
|
+
unit: this.linearUnit,
|
|
85
|
+
};
|
|
86
|
+
this.lastMeasurement = result;
|
|
87
|
+
this.notifyWatchers("lastMeasurement", this.lastMeasurement);
|
|
88
|
+
this.eventBus.emit("measurement.updated", result, this);
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
measureArea(ring) {
|
|
92
|
+
const squareMeters = measurePolygonInSquareMeters(ring);
|
|
93
|
+
const value = convertAreaUnit(squareMeters, this.areaUnit);
|
|
94
|
+
const result = {
|
|
95
|
+
tool: "area",
|
|
96
|
+
value,
|
|
97
|
+
unit: this.areaUnit,
|
|
98
|
+
};
|
|
99
|
+
this.lastMeasurement = result;
|
|
100
|
+
this.notifyWatchers("lastMeasurement", this.lastMeasurement);
|
|
101
|
+
this.eventBus.emit("measurement.updated", result, this);
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
destroy() {
|
|
105
|
+
this.watchListeners.clear();
|
|
106
|
+
}
|
|
107
|
+
notifyWatchers(propertyName, value) {
|
|
108
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
109
|
+
if (!listeners) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
for (const listener of listeners) {
|
|
113
|
+
safeInvokeCompatListener(listener, value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function measureLineInMeters(points) {
|
|
118
|
+
if (points.length < 2) {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
let total = 0;
|
|
122
|
+
for (let i = 1; i < points.length; i += 1) {
|
|
123
|
+
total += haversineDistanceMeters(points[i - 1], points[i]);
|
|
124
|
+
}
|
|
125
|
+
return total;
|
|
126
|
+
}
|
|
127
|
+
function haversineDistanceMeters(a, b) {
|
|
128
|
+
const [lonA, latA] = a;
|
|
129
|
+
const [lonB, latB] = b;
|
|
130
|
+
const dLat = toRadians(latB - latA);
|
|
131
|
+
const dLon = toRadians(lonB - lonA);
|
|
132
|
+
const latARad = toRadians(latA);
|
|
133
|
+
const latBRad = toRadians(latB);
|
|
134
|
+
const h = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
135
|
+
Math.cos(latARad) * Math.cos(latBRad) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
136
|
+
const c = 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h));
|
|
137
|
+
return 6371008.8 * c;
|
|
138
|
+
}
|
|
139
|
+
function measurePolygonInSquareMeters(ring) {
|
|
140
|
+
if (ring.length < 3) {
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
const closed = isClosedRing(ring) ? ring : [...ring, ring[0]];
|
|
144
|
+
const lat0 = closed.reduce((sum, [, lat]) => sum + lat, 0) / closed.length;
|
|
145
|
+
const metersPerDegLat = 111132.92;
|
|
146
|
+
const metersPerDegLon = 111412.84 * Math.cos(toRadians(lat0));
|
|
147
|
+
let sum = 0;
|
|
148
|
+
for (let i = 1; i < closed.length; i += 1) {
|
|
149
|
+
const [lonA, latA] = closed[i - 1];
|
|
150
|
+
const [lonB, latB] = closed[i];
|
|
151
|
+
const xA = lonA * metersPerDegLon;
|
|
152
|
+
const yA = latA * metersPerDegLat;
|
|
153
|
+
const xB = lonB * metersPerDegLon;
|
|
154
|
+
const yB = latB * metersPerDegLat;
|
|
155
|
+
sum += xA * yB - xB * yA;
|
|
156
|
+
}
|
|
157
|
+
return Math.abs(sum) / 2;
|
|
158
|
+
}
|
|
159
|
+
function isClosedRing(ring) {
|
|
160
|
+
if (ring.length < 2) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const first = ring[0];
|
|
164
|
+
const last = ring[ring.length - 1];
|
|
165
|
+
return first[0] === last[0] && first[1] === last[1];
|
|
166
|
+
}
|
|
167
|
+
function convertLinearUnit(valueMeters, unit) {
|
|
168
|
+
switch (unit) {
|
|
169
|
+
case "meters":
|
|
170
|
+
return valueMeters;
|
|
171
|
+
case "kilometers":
|
|
172
|
+
return valueMeters / 1000;
|
|
173
|
+
case "feet":
|
|
174
|
+
return valueMeters * 3.280839895;
|
|
175
|
+
case "miles":
|
|
176
|
+
return valueMeters / 1609.344;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function convertAreaUnit(valueSquareMeters, unit) {
|
|
180
|
+
switch (unit) {
|
|
181
|
+
case "square-meters":
|
|
182
|
+
return valueSquareMeters;
|
|
183
|
+
case "square-kilometers":
|
|
184
|
+
return valueSquareMeters / 1_000_000;
|
|
185
|
+
case "square-feet":
|
|
186
|
+
return valueSquareMeters * 10.763910417;
|
|
187
|
+
case "square-miles":
|
|
188
|
+
return valueSquareMeters / 2_589_988.110336;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function toRadians(value) {
|
|
192
|
+
return (value * Math.PI) / 180;
|
|
193
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface OAuthInfoCompatOptions {
|
|
2
|
+
appId?: string;
|
|
3
|
+
portalUrl?: string;
|
|
4
|
+
popup?: boolean;
|
|
5
|
+
flowType?: "auto" | "implicit" | "authorization-code" | string;
|
|
6
|
+
expiration?: number;
|
|
7
|
+
authNamespace?: string;
|
|
8
|
+
preserveUrlHash?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type OAuthInfoLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
11
|
+
export interface OAuthInfoHandleCompat {
|
|
12
|
+
remove(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class OAuthInfoCompat {
|
|
15
|
+
loaded: boolean;
|
|
16
|
+
loadStatus: OAuthInfoLoadStatusCompat;
|
|
17
|
+
appId: string | undefined;
|
|
18
|
+
portalUrl: string;
|
|
19
|
+
popup: boolean;
|
|
20
|
+
flowType: string;
|
|
21
|
+
expiration: number | undefined;
|
|
22
|
+
authNamespace: string | undefined;
|
|
23
|
+
preserveUrlHash: boolean;
|
|
24
|
+
private readonly watchListeners;
|
|
25
|
+
constructor(options?: OAuthInfoCompatOptions);
|
|
26
|
+
load(): Promise<OAuthInfoCompat>;
|
|
27
|
+
when(callback?: (info: OAuthInfoCompat) => void): Promise<OAuthInfoCompat>;
|
|
28
|
+
watch(propertyName: string, listener: (value: unknown) => void): OAuthInfoHandleCompat;
|
|
29
|
+
update(options: OAuthInfoCompatOptions): void;
|
|
30
|
+
clone(): OAuthInfoCompat;
|
|
31
|
+
toJSON(): OAuthInfoCompatOptions;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
private notifyWatchers;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=oauth-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-info.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/oauth-info.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,oBAAoB,GAAG,MAAM,CAAC;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,MAAM,yBAAyB,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5E,MAAM,WAAW,qBAAqB;IACpC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,eAAe;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,yBAAyB,CAAC;IACtC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;gBAEzD,OAAO,GAAE,sBAA2B;IAc1C,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAchC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC;IAQhF,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,qBAAqB;IAetF,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI;IAgC7C,KAAK,IAAI,eAAe;IAIxB,MAAM,IAAI,sBAAsB;IAYhC,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class OAuthInfoCompat {
|
|
3
|
+
loaded;
|
|
4
|
+
loadStatus;
|
|
5
|
+
appId;
|
|
6
|
+
portalUrl;
|
|
7
|
+
popup;
|
|
8
|
+
flowType;
|
|
9
|
+
expiration;
|
|
10
|
+
authNamespace;
|
|
11
|
+
preserveUrlHash;
|
|
12
|
+
watchListeners;
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.loaded = false;
|
|
15
|
+
this.loadStatus = "not-loaded";
|
|
16
|
+
this.appId = options.appId;
|
|
17
|
+
this.portalUrl = options.portalUrl ?? "https://www.arcgis.com";
|
|
18
|
+
this.popup = options.popup ?? false;
|
|
19
|
+
this.flowType = options.flowType ?? "auto";
|
|
20
|
+
this.expiration =
|
|
21
|
+
typeof options.expiration === "number" && Number.isFinite(options.expiration) ? options.expiration : undefined;
|
|
22
|
+
this.authNamespace = options.authNamespace;
|
|
23
|
+
this.preserveUrlHash = options.preserveUrlHash ?? false;
|
|
24
|
+
this.watchListeners = new Map();
|
|
25
|
+
}
|
|
26
|
+
async load() {
|
|
27
|
+
if (this.loaded) {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
this.loadStatus = "loading";
|
|
31
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
32
|
+
this.loaded = true;
|
|
33
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
34
|
+
this.loadStatus = "loaded";
|
|
35
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
async when(callback) {
|
|
39
|
+
const info = await this.load();
|
|
40
|
+
if (callback) {
|
|
41
|
+
callback(info);
|
|
42
|
+
}
|
|
43
|
+
return info;
|
|
44
|
+
}
|
|
45
|
+
watch(propertyName, listener) {
|
|
46
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
47
|
+
if (!listeners) {
|
|
48
|
+
listeners = new Set();
|
|
49
|
+
this.watchListeners.set(propertyName, listeners);
|
|
50
|
+
}
|
|
51
|
+
listeners.add(listener);
|
|
52
|
+
return {
|
|
53
|
+
remove: () => {
|
|
54
|
+
listeners?.delete(listener);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
update(options) {
|
|
59
|
+
if (options.appId !== undefined) {
|
|
60
|
+
this.appId = options.appId;
|
|
61
|
+
this.notifyWatchers("appId", this.appId);
|
|
62
|
+
}
|
|
63
|
+
if (options.portalUrl !== undefined) {
|
|
64
|
+
this.portalUrl = options.portalUrl;
|
|
65
|
+
this.notifyWatchers("portalUrl", this.portalUrl);
|
|
66
|
+
}
|
|
67
|
+
if (options.popup !== undefined) {
|
|
68
|
+
this.popup = options.popup;
|
|
69
|
+
this.notifyWatchers("popup", this.popup);
|
|
70
|
+
}
|
|
71
|
+
if (options.flowType !== undefined) {
|
|
72
|
+
this.flowType = options.flowType;
|
|
73
|
+
this.notifyWatchers("flowType", this.flowType);
|
|
74
|
+
}
|
|
75
|
+
if (options.expiration !== undefined) {
|
|
76
|
+
this.expiration =
|
|
77
|
+
typeof options.expiration === "number" && Number.isFinite(options.expiration) ? options.expiration : undefined;
|
|
78
|
+
this.notifyWatchers("expiration", this.expiration);
|
|
79
|
+
}
|
|
80
|
+
if (options.authNamespace !== undefined) {
|
|
81
|
+
this.authNamespace = options.authNamespace;
|
|
82
|
+
this.notifyWatchers("authNamespace", this.authNamespace);
|
|
83
|
+
}
|
|
84
|
+
if (options.preserveUrlHash !== undefined) {
|
|
85
|
+
this.preserveUrlHash = options.preserveUrlHash;
|
|
86
|
+
this.notifyWatchers("preserveUrlHash", this.preserveUrlHash);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
clone() {
|
|
90
|
+
return new OAuthInfoCompat(this.toJSON());
|
|
91
|
+
}
|
|
92
|
+
toJSON() {
|
|
93
|
+
return {
|
|
94
|
+
appId: this.appId,
|
|
95
|
+
portalUrl: this.portalUrl,
|
|
96
|
+
popup: this.popup,
|
|
97
|
+
flowType: this.flowType,
|
|
98
|
+
expiration: this.expiration,
|
|
99
|
+
authNamespace: this.authNamespace,
|
|
100
|
+
preserveUrlHash: this.preserveUrlHash,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
destroy() {
|
|
104
|
+
this.watchListeners.clear();
|
|
105
|
+
}
|
|
106
|
+
notifyWatchers(propertyName, value) {
|
|
107
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
108
|
+
if (!listeners) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
for (const listener of listeners) {
|
|
112
|
+
safeInvokeCompatListener(listener, value);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface PictureMarkerSymbolCompatOptions {
|
|
2
|
+
url?: string;
|
|
3
|
+
width?: number | string;
|
|
4
|
+
height?: number | string;
|
|
5
|
+
xoffset?: number;
|
|
6
|
+
yoffset?: number;
|
|
7
|
+
angle?: number;
|
|
8
|
+
opacity?: number;
|
|
9
|
+
}
|
|
10
|
+
export type PictureMarkerSymbolLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
11
|
+
export interface PictureMarkerSymbolHandleCompat {
|
|
12
|
+
remove(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class PictureMarkerSymbolCompat {
|
|
15
|
+
loaded: boolean;
|
|
16
|
+
loadStatus: PictureMarkerSymbolLoadStatusCompat;
|
|
17
|
+
url: string | undefined;
|
|
18
|
+
width: number | string | undefined;
|
|
19
|
+
height: number | string | undefined;
|
|
20
|
+
xoffset: number;
|
|
21
|
+
yoffset: number;
|
|
22
|
+
angle: number;
|
|
23
|
+
opacity: number;
|
|
24
|
+
private readonly watchListeners;
|
|
25
|
+
constructor(options?: PictureMarkerSymbolCompatOptions);
|
|
26
|
+
load(): Promise<PictureMarkerSymbolCompat>;
|
|
27
|
+
when(callback?: (symbol: PictureMarkerSymbolCompat) => void): Promise<PictureMarkerSymbolCompat>;
|
|
28
|
+
watch(propertyName: string, listener: (value: unknown) => void): PictureMarkerSymbolHandleCompat;
|
|
29
|
+
update(options: PictureMarkerSymbolCompatOptions): void;
|
|
30
|
+
clone(): PictureMarkerSymbolCompat;
|
|
31
|
+
toJSON(): PictureMarkerSymbolCompatOptions;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
private notifyWatchers;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=picture-marker-symbol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picture-marker-symbol.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/picture-marker-symbol.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,gCAAgC;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,mCAAmC,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtF,MAAM,WAAW,+BAA+B;IAC9C,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,yBAAyB;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,mCAAmC,CAAC;IAChD,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;gBAEzD,OAAO,GAAE,gCAAqC;IAapD,IAAI,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAc1C,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,yBAAyB,KAAK,IAAI,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAQtG,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,+BAA+B;IAehG,MAAM,CAAC,OAAO,EAAE,gCAAgC,GAAG,IAAI;IA+BvD,KAAK,IAAI,yBAAyB;IAIlC,MAAM,IAAI,gCAAgC;IAY1C,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class PictureMarkerSymbolCompat {
|
|
3
|
+
loaded;
|
|
4
|
+
loadStatus;
|
|
5
|
+
url;
|
|
6
|
+
width;
|
|
7
|
+
height;
|
|
8
|
+
xoffset;
|
|
9
|
+
yoffset;
|
|
10
|
+
angle;
|
|
11
|
+
opacity;
|
|
12
|
+
watchListeners;
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.loaded = false;
|
|
15
|
+
this.loadStatus = "not-loaded";
|
|
16
|
+
this.url = options.url;
|
|
17
|
+
this.width = options.width;
|
|
18
|
+
this.height = options.height;
|
|
19
|
+
this.xoffset = finiteNumber(options.xoffset, 0);
|
|
20
|
+
this.yoffset = finiteNumber(options.yoffset, 0);
|
|
21
|
+
this.angle = finiteNumber(options.angle, 0);
|
|
22
|
+
this.opacity = clampOpacity(options.opacity);
|
|
23
|
+
this.watchListeners = new Map();
|
|
24
|
+
}
|
|
25
|
+
async load() {
|
|
26
|
+
if (this.loaded) {
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
this.loadStatus = "loading";
|
|
30
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
31
|
+
this.loaded = true;
|
|
32
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
33
|
+
this.loadStatus = "loaded";
|
|
34
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
async when(callback) {
|
|
38
|
+
const symbol = await this.load();
|
|
39
|
+
if (callback) {
|
|
40
|
+
callback(symbol);
|
|
41
|
+
}
|
|
42
|
+
return symbol;
|
|
43
|
+
}
|
|
44
|
+
watch(propertyName, listener) {
|
|
45
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
46
|
+
if (!listeners) {
|
|
47
|
+
listeners = new Set();
|
|
48
|
+
this.watchListeners.set(propertyName, listeners);
|
|
49
|
+
}
|
|
50
|
+
listeners.add(listener);
|
|
51
|
+
return {
|
|
52
|
+
remove: () => {
|
|
53
|
+
listeners?.delete(listener);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
update(options) {
|
|
58
|
+
if (options.url !== undefined) {
|
|
59
|
+
this.url = options.url;
|
|
60
|
+
this.notifyWatchers("url", this.url);
|
|
61
|
+
}
|
|
62
|
+
if (options.width !== undefined) {
|
|
63
|
+
this.width = options.width;
|
|
64
|
+
this.notifyWatchers("width", this.width);
|
|
65
|
+
}
|
|
66
|
+
if (options.height !== undefined) {
|
|
67
|
+
this.height = options.height;
|
|
68
|
+
this.notifyWatchers("height", this.height);
|
|
69
|
+
}
|
|
70
|
+
if (options.xoffset !== undefined) {
|
|
71
|
+
this.xoffset = finiteNumber(options.xoffset, this.xoffset);
|
|
72
|
+
this.notifyWatchers("xoffset", this.xoffset);
|
|
73
|
+
}
|
|
74
|
+
if (options.yoffset !== undefined) {
|
|
75
|
+
this.yoffset = finiteNumber(options.yoffset, this.yoffset);
|
|
76
|
+
this.notifyWatchers("yoffset", this.yoffset);
|
|
77
|
+
}
|
|
78
|
+
if (options.angle !== undefined) {
|
|
79
|
+
this.angle = finiteNumber(options.angle, this.angle);
|
|
80
|
+
this.notifyWatchers("angle", this.angle);
|
|
81
|
+
}
|
|
82
|
+
if (options.opacity !== undefined) {
|
|
83
|
+
this.opacity = clampOpacity(options.opacity);
|
|
84
|
+
this.notifyWatchers("opacity", this.opacity);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
clone() {
|
|
88
|
+
return new PictureMarkerSymbolCompat(this.toJSON());
|
|
89
|
+
}
|
|
90
|
+
toJSON() {
|
|
91
|
+
return {
|
|
92
|
+
url: this.url,
|
|
93
|
+
width: this.width,
|
|
94
|
+
height: this.height,
|
|
95
|
+
xoffset: this.xoffset,
|
|
96
|
+
yoffset: this.yoffset,
|
|
97
|
+
angle: this.angle,
|
|
98
|
+
opacity: this.opacity,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
destroy() {
|
|
102
|
+
this.watchListeners.clear();
|
|
103
|
+
}
|
|
104
|
+
notifyWatchers(propertyName, value) {
|
|
105
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
106
|
+
if (!listeners) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
for (const listener of listeners) {
|
|
110
|
+
safeInvokeCompatListener(listener, value);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function finiteNumber(value, fallback) {
|
|
115
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
116
|
+
}
|
|
117
|
+
function clampOpacity(value) {
|
|
118
|
+
const numeric = finiteNumber(value, 1);
|
|
119
|
+
if (numeric < 0) {
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
if (numeric > 1) {
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
return numeric;
|
|
126
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface PointCompatOptions {
|
|
2
|
+
x?: number;
|
|
3
|
+
y?: number;
|
|
4
|
+
z?: number;
|
|
5
|
+
m?: number;
|
|
6
|
+
spatialReference?: unknown;
|
|
7
|
+
}
|
|
8
|
+
export type PointLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
9
|
+
export interface PointHandleCompat {
|
|
10
|
+
remove(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class PointCompat {
|
|
13
|
+
loaded: boolean;
|
|
14
|
+
loadStatus: PointLoadStatusCompat;
|
|
15
|
+
x: number | undefined;
|
|
16
|
+
y: number | undefined;
|
|
17
|
+
z: number | undefined;
|
|
18
|
+
m: number | undefined;
|
|
19
|
+
spatialReference: unknown;
|
|
20
|
+
private readonly watchListeners;
|
|
21
|
+
constructor(options?: PointCompatOptions);
|
|
22
|
+
load(): Promise<PointCompat>;
|
|
23
|
+
when(callback?: (point: PointCompat) => void): Promise<PointCompat>;
|
|
24
|
+
watch(propertyName: string, listener: (value: unknown) => void): PointHandleCompat;
|
|
25
|
+
update(options: PointCompatOptions): void;
|
|
26
|
+
clone(): PointCompat;
|
|
27
|
+
toJSON(): PointCompatOptions;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
private notifyWatchers;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=point.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/point.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,kBAAkB;IACjC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,WAAW;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,qBAAqB,CAAC;IAClC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;gBAEzD,OAAO,GAAE,kBAAuB;IAWtC,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IAc5B,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;IAQzE,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,iBAAiB;IAelF,MAAM,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAuBzC,KAAK,IAAI,WAAW;IAIpB,MAAM,IAAI,kBAAkB;IAU5B,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class PointCompat {
|
|
3
|
+
loaded;
|
|
4
|
+
loadStatus;
|
|
5
|
+
x;
|
|
6
|
+
y;
|
|
7
|
+
z;
|
|
8
|
+
m;
|
|
9
|
+
spatialReference;
|
|
10
|
+
watchListeners;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.loaded = false;
|
|
13
|
+
this.loadStatus = "not-loaded";
|
|
14
|
+
this.x = normalizeFiniteNumber(options.x);
|
|
15
|
+
this.y = normalizeFiniteNumber(options.y);
|
|
16
|
+
this.z = normalizeFiniteNumber(options.z);
|
|
17
|
+
this.m = normalizeFiniteNumber(options.m);
|
|
18
|
+
this.spatialReference = options.spatialReference;
|
|
19
|
+
this.watchListeners = new Map();
|
|
20
|
+
}
|
|
21
|
+
async load() {
|
|
22
|
+
if (this.loaded) {
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
this.loadStatus = "loading";
|
|
26
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
27
|
+
this.loaded = true;
|
|
28
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
29
|
+
this.loadStatus = "loaded";
|
|
30
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
async when(callback) {
|
|
34
|
+
const point = await this.load();
|
|
35
|
+
if (callback) {
|
|
36
|
+
callback(point);
|
|
37
|
+
}
|
|
38
|
+
return point;
|
|
39
|
+
}
|
|
40
|
+
watch(propertyName, listener) {
|
|
41
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
42
|
+
if (!listeners) {
|
|
43
|
+
listeners = new Set();
|
|
44
|
+
this.watchListeners.set(propertyName, listeners);
|
|
45
|
+
}
|
|
46
|
+
listeners.add(listener);
|
|
47
|
+
return {
|
|
48
|
+
remove: () => {
|
|
49
|
+
listeners?.delete(listener);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
update(options) {
|
|
54
|
+
if (options.x !== undefined) {
|
|
55
|
+
this.x = normalizeFiniteNumber(options.x);
|
|
56
|
+
this.notifyWatchers("x", this.x);
|
|
57
|
+
}
|
|
58
|
+
if (options.y !== undefined) {
|
|
59
|
+
this.y = normalizeFiniteNumber(options.y);
|
|
60
|
+
this.notifyWatchers("y", this.y);
|
|
61
|
+
}
|
|
62
|
+
if (options.z !== undefined) {
|
|
63
|
+
this.z = normalizeFiniteNumber(options.z);
|
|
64
|
+
this.notifyWatchers("z", this.z);
|
|
65
|
+
}
|
|
66
|
+
if (options.m !== undefined) {
|
|
67
|
+
this.m = normalizeFiniteNumber(options.m);
|
|
68
|
+
this.notifyWatchers("m", this.m);
|
|
69
|
+
}
|
|
70
|
+
if (options.spatialReference !== undefined) {
|
|
71
|
+
this.spatialReference = options.spatialReference;
|
|
72
|
+
this.notifyWatchers("spatialReference", this.spatialReference);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
clone() {
|
|
76
|
+
return new PointCompat(this.toJSON());
|
|
77
|
+
}
|
|
78
|
+
toJSON() {
|
|
79
|
+
return {
|
|
80
|
+
x: this.x,
|
|
81
|
+
y: this.y,
|
|
82
|
+
z: this.z,
|
|
83
|
+
m: this.m,
|
|
84
|
+
spatialReference: this.spatialReference,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
destroy() {
|
|
88
|
+
this.watchListeners.clear();
|
|
89
|
+
}
|
|
90
|
+
notifyWatchers(propertyName, value) {
|
|
91
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
92
|
+
if (!listeners) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
for (const listener of listeners) {
|
|
96
|
+
safeInvokeCompatListener(listener, value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function normalizeFiniteNumber(value) {
|
|
101
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
102
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface PolygonCompatOptions {
|
|
2
|
+
rings?: unknown[][][];
|
|
3
|
+
spatialReference?: unknown;
|
|
4
|
+
hasZ?: boolean;
|
|
5
|
+
hasM?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type PolygonLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
8
|
+
export interface PolygonHandleCompat {
|
|
9
|
+
remove(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class PolygonCompat {
|
|
12
|
+
loaded: boolean;
|
|
13
|
+
loadStatus: PolygonLoadStatusCompat;
|
|
14
|
+
rings: unknown[][][];
|
|
15
|
+
spatialReference: unknown;
|
|
16
|
+
hasZ: boolean;
|
|
17
|
+
hasM: boolean;
|
|
18
|
+
private readonly watchListeners;
|
|
19
|
+
constructor(options?: PolygonCompatOptions);
|
|
20
|
+
load(): Promise<PolygonCompat>;
|
|
21
|
+
when(callback?: (polygon: PolygonCompat) => void): Promise<PolygonCompat>;
|
|
22
|
+
watch(propertyName: string, listener: (value: unknown) => void): PolygonHandleCompat;
|
|
23
|
+
addRing(ring: unknown[][]): void;
|
|
24
|
+
removeRing(index: number): boolean;
|
|
25
|
+
update(options: PolygonCompatOptions): void;
|
|
26
|
+
clone(): PolygonCompat;
|
|
27
|
+
toJSON(): PolygonCompatOptions;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
private notifyWatchers;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=polygon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/polygon.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1E,MAAM,WAAW,mBAAmB;IAClC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,aAAa;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,uBAAuB,CAAC;IACpC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;gBAEzD,OAAO,GAAE,oBAAyB;IAUxC,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;IAc9B,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ/E,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,mBAAmB;IAepF,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI;IAKhC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IASlC,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAmB3C,KAAK,IAAI,aAAa;IAItB,MAAM,IAAI,oBAAoB;IAS9B,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,cAAc;CAUvB"}
|