aur-openlayers 1.0.3 → 19.6.3
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 +63 -63
- package/fesm2022/aur-openlayers.mjs +99 -40
- package/fesm2022/aur-openlayers.mjs.map +1 -1
- package/lib/map-framework/public/types.d.ts +9 -0
- package/lib/map-framework/runtime/fit-layer.utils.d.ts +2 -1
- package/lib/map-framework/runtime/interaction-manager.d.ts +1 -0
- package/lib/map-framework/runtime/layer-manager.d.ts +3 -0
- package/lib/map-framework/runtime/scheduler.d.ts +1 -0
- package/lib/map-framework/runtime/vector-layer-base.d.ts +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# Lib
|
|
2
|
-
|
|
3
|
-
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
|
|
4
|
-
|
|
5
|
-
## Code scaffolding
|
|
6
|
-
|
|
7
|
-
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
ng generate component component-name
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
ng generate --help
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Building
|
|
20
|
-
|
|
21
|
-
To build the library, run:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
ng build lib
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
-
|
|
29
|
-
### Publishing the Library
|
|
30
|
-
|
|
31
|
-
Once the project is built, you can publish your library by following these steps:
|
|
32
|
-
|
|
33
|
-
1. Navigate to the `dist` directory:
|
|
34
|
-
```bash
|
|
35
|
-
cd dist/lib
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
39
|
-
```bash
|
|
40
|
-
npm publish
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Running unit tests
|
|
44
|
-
|
|
45
|
-
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
ng test
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Running end-to-end tests
|
|
52
|
-
|
|
53
|
-
For end-to-end (e2e) testing, run:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
ng e2e
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
60
|
-
|
|
61
|
-
## Additional Resources
|
|
62
|
-
|
|
63
|
-
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
1
|
+
# Lib
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build lib
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
```bash
|
|
35
|
+
cd dist/lib
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
39
|
+
```bash
|
|
40
|
+
npm publish
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Running unit tests
|
|
44
|
+
|
|
45
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
ng test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Running end-to-end tests
|
|
52
|
+
|
|
53
|
+
For end-to-end (e2e) testing, run:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
ng e2e
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
60
|
+
|
|
61
|
+
## Additional Resources
|
|
62
|
+
|
|
63
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -3,12 +3,12 @@ import { Injectable, Component } from '@angular/core';
|
|
|
3
3
|
import VectorLayer from 'ol/layer/Vector';
|
|
4
4
|
import ClusterSource from 'ol/source/Cluster';
|
|
5
5
|
import VectorSource from 'ol/source/Vector';
|
|
6
|
+
import { createEmpty, extend, isEmpty } from 'ol/extent';
|
|
6
7
|
import Feature from 'ol/Feature';
|
|
7
8
|
import Collection from 'ol/Collection';
|
|
8
9
|
import DragPan from 'ol/interaction/DragPan';
|
|
9
10
|
import Modify from 'ol/interaction/Modify';
|
|
10
11
|
import * as Observable from 'ol/Observable';
|
|
11
|
-
import { createEmpty, extend, isEmpty } from 'ol/extent';
|
|
12
12
|
|
|
13
13
|
class LibService {
|
|
14
14
|
constructor() { }
|
|
@@ -24,18 +24,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
24
24
|
|
|
25
25
|
class LibComponent {
|
|
26
26
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: LibComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
27
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: LibComponent, isStandalone: true, selector: "lib-lib", ngImport: i0, template: `
|
|
28
|
-
<p>
|
|
29
|
-
lib works!
|
|
30
|
-
</p>
|
|
27
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: LibComponent, isStandalone: true, selector: "lib-lib", ngImport: i0, template: `
|
|
28
|
+
<p>
|
|
29
|
+
lib works!
|
|
30
|
+
</p>
|
|
31
31
|
`, isInline: true, styles: [""] });
|
|
32
32
|
}
|
|
33
33
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: LibComponent, decorators: [{
|
|
34
34
|
type: Component,
|
|
35
|
-
args: [{ selector: 'lib-lib', imports: [], template: `
|
|
36
|
-
<p>
|
|
37
|
-
lib works!
|
|
38
|
-
</p>
|
|
35
|
+
args: [{ selector: 'lib-lib', imports: [], template: `
|
|
36
|
+
<p>
|
|
37
|
+
lib works!
|
|
38
|
+
</p>
|
|
39
39
|
` }]
|
|
40
40
|
}] });
|
|
41
41
|
|
|
@@ -150,35 +150,16 @@ class FlushScheduler {
|
|
|
150
150
|
shouldUpgradePolicy(current, next) {
|
|
151
151
|
return current === 'microtask' && next === 'raf';
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
map,
|
|
158
|
-
layers,
|
|
159
|
-
popupHost,
|
|
160
|
-
batch: (fn, options) => scheduler.batch(fn, options),
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const CLUSTER_FEATURES_KEY = 'features';
|
|
165
|
-
const getClusterFeatures = (feature) => {
|
|
166
|
-
const features = feature.get(CLUSTER_FEATURES_KEY);
|
|
167
|
-
if (!Array.isArray(features)) {
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
const items = features.filter((item) => {
|
|
171
|
-
if (!item || typeof item !== 'object') {
|
|
172
|
-
return false;
|
|
153
|
+
dispose() {
|
|
154
|
+
if (this.rafId !== null) {
|
|
155
|
+
cancelAnimationFrame(this.rafId);
|
|
156
|
+
this.rafId = null;
|
|
173
157
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (items.length === 0) {
|
|
178
|
-
return null;
|
|
158
|
+
this.scheduledToken++;
|
|
159
|
+
this.queue.clear();
|
|
160
|
+
this.pendingPolicy = null;
|
|
179
161
|
}
|
|
180
|
-
|
|
181
|
-
};
|
|
162
|
+
}
|
|
182
163
|
|
|
183
164
|
/**
|
|
184
165
|
* Default padding for View#fit in pixels.
|
|
@@ -209,6 +190,58 @@ function toOlFitOptions(opts) {
|
|
|
209
190
|
}
|
|
210
191
|
return fitOpts;
|
|
211
192
|
}
|
|
193
|
+
function collectLayersExtent(layers, layerIds) {
|
|
194
|
+
const extent = createEmpty();
|
|
195
|
+
const ids = layerIds ?? Object.keys(layers);
|
|
196
|
+
for (const id of ids) {
|
|
197
|
+
const layer = layers[id];
|
|
198
|
+
if (!layer || !layer.isVisible())
|
|
199
|
+
continue;
|
|
200
|
+
const layerExtent = layer.getExtent();
|
|
201
|
+
if (layerExtent) {
|
|
202
|
+
extend(extent, layerExtent);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return isEmpty(extent) ? null : extent;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const createMapContext = (map, layers, popupHost, scheduler = new FlushScheduler()) => {
|
|
209
|
+
return {
|
|
210
|
+
map,
|
|
211
|
+
layers,
|
|
212
|
+
popupHost,
|
|
213
|
+
batch: (fn, options) => scheduler.batch(fn, options),
|
|
214
|
+
centerOnAllLayers: (opts) => {
|
|
215
|
+
const extent = collectLayersExtent(layers);
|
|
216
|
+
if (extent)
|
|
217
|
+
map.getView().fit(extent, toOlFitOptions(opts));
|
|
218
|
+
},
|
|
219
|
+
centerOnLayers: (layerIds, opts) => {
|
|
220
|
+
const extent = collectLayersExtent(layers, layerIds);
|
|
221
|
+
if (extent)
|
|
222
|
+
map.getView().fit(extent, toOlFitOptions(opts));
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const CLUSTER_FEATURES_KEY = 'features';
|
|
228
|
+
const getClusterFeatures = (feature) => {
|
|
229
|
+
const features = feature.get(CLUSTER_FEATURES_KEY);
|
|
230
|
+
if (!Array.isArray(features)) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
const items = features.filter((item) => {
|
|
234
|
+
if (!item || typeof item !== 'object') {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
const candidate = item;
|
|
238
|
+
return typeof candidate.get === 'function' && typeof candidate.getGeometry === 'function';
|
|
239
|
+
});
|
|
240
|
+
if (items.length === 0) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
return items;
|
|
244
|
+
};
|
|
212
245
|
|
|
213
246
|
const STATES_KEY = '__mff_states__';
|
|
214
247
|
const getFeatureStates = (feature) => {
|
|
@@ -312,6 +345,7 @@ class InteractionManager {
|
|
|
312
345
|
const active = {
|
|
313
346
|
targetKey,
|
|
314
347
|
startCoordinate: event.coordinate,
|
|
348
|
+
startPixel: event.pixel,
|
|
315
349
|
lastCoordinate: event.coordinate,
|
|
316
350
|
lastItem: resolved,
|
|
317
351
|
moveThrottleMs: translate.moveThrottleMs ?? 0,
|
|
@@ -1074,8 +1108,9 @@ class InteractionManager {
|
|
|
1074
1108
|
nextCoordinate[1] - active.lastCoordinate[1],
|
|
1075
1109
|
];
|
|
1076
1110
|
if (!active.started) {
|
|
1077
|
-
const
|
|
1078
|
-
const
|
|
1111
|
+
const currentPixel = event.pixel;
|
|
1112
|
+
const offsetX = currentPixel[0] - active.startPixel[0];
|
|
1113
|
+
const offsetY = currentPixel[1] - active.startPixel[1];
|
|
1079
1114
|
const distance = Math.hypot(offsetX, offsetY);
|
|
1080
1115
|
if (distance < active.startThresholdPx) {
|
|
1081
1116
|
active.lastHandled = false;
|
|
@@ -1332,7 +1367,7 @@ class InteractionManager {
|
|
|
1332
1367
|
if (aZ !== bZ) {
|
|
1333
1368
|
return bZ - aZ;
|
|
1334
1369
|
}
|
|
1335
|
-
return
|
|
1370
|
+
return b.index - a.index;
|
|
1336
1371
|
});
|
|
1337
1372
|
}
|
|
1338
1373
|
getHitTolerance(hitTolerance) {
|
|
@@ -1525,6 +1560,16 @@ class InteractionManager {
|
|
|
1525
1560
|
shouldStopClusterPropagation() {
|
|
1526
1561
|
return true;
|
|
1527
1562
|
}
|
|
1563
|
+
dispose() {
|
|
1564
|
+
this.listenerKeys.forEach((key) => Observable.unByKey(key));
|
|
1565
|
+
this.listenerKeys.clear();
|
|
1566
|
+
Array.from(this.nativeModifies.keys()).forEach((id) => this.teardownNativeModify(id));
|
|
1567
|
+
this.hoverItems.clear();
|
|
1568
|
+
this.selectedItems.clear();
|
|
1569
|
+
this.activeTranslates.clear();
|
|
1570
|
+
this.activeModifies.clear();
|
|
1571
|
+
this.enabledState.clear();
|
|
1572
|
+
}
|
|
1528
1573
|
}
|
|
1529
1574
|
|
|
1530
1575
|
class StyleCache {
|
|
@@ -1872,6 +1917,10 @@ class VectorLayerBase {
|
|
|
1872
1917
|
}
|
|
1873
1918
|
this.ctx.map.getView().fit(extent, toOlFitOptions(opts));
|
|
1874
1919
|
}
|
|
1920
|
+
getExtent() {
|
|
1921
|
+
const extent = this.source.getExtent();
|
|
1922
|
+
return isEmpty(extent) ? null : extent;
|
|
1923
|
+
}
|
|
1875
1924
|
setVisible(visible) {
|
|
1876
1925
|
this.layer.setVisible(visible);
|
|
1877
1926
|
}
|
|
@@ -2016,7 +2065,7 @@ class ClusteredVectorLayer extends VectorLayerBase {
|
|
|
2016
2065
|
this.layer.setSource(this.clusteringEnabled ? this.clusterSource : this.source);
|
|
2017
2066
|
}
|
|
2018
2067
|
setModels(models) {
|
|
2019
|
-
|
|
2068
|
+
super.setModels(models);
|
|
2020
2069
|
this.scheduleInvalidate();
|
|
2021
2070
|
}
|
|
2022
2071
|
setClusteringEnabled(enabled) {
|
|
@@ -2245,11 +2294,15 @@ class LayerManager {
|
|
|
2245
2294
|
layers = {};
|
|
2246
2295
|
apis = {};
|
|
2247
2296
|
interactions;
|
|
2297
|
+
scheduler;
|
|
2298
|
+
popupHost;
|
|
2248
2299
|
ctx;
|
|
2249
2300
|
constructor(map, schema) {
|
|
2250
2301
|
this.map = map;
|
|
2251
2302
|
const popupHost = schema.options?.popupHost ? new PopupHost(schema.options.popupHost) : undefined;
|
|
2252
2303
|
const scheduler = new FlushScheduler(schema.options?.scheduler?.policy ?? 'microtask');
|
|
2304
|
+
this.scheduler = scheduler;
|
|
2305
|
+
this.popupHost = popupHost;
|
|
2253
2306
|
const ctx = createMapContext(this.map, this.apis, popupHost, scheduler);
|
|
2254
2307
|
this.ctx = ctx;
|
|
2255
2308
|
schema.layers.forEach((descriptor) => {
|
|
@@ -2318,6 +2371,12 @@ class LayerManager {
|
|
|
2318
2371
|
refreshEnabled() {
|
|
2319
2372
|
this.interactions.refreshEnabled();
|
|
2320
2373
|
}
|
|
2374
|
+
dispose() {
|
|
2375
|
+
this.interactions.dispose();
|
|
2376
|
+
this.popupHost?.dispose();
|
|
2377
|
+
this.scheduler.dispose();
|
|
2378
|
+
Object.values(this.layers).forEach((layer) => this.map.removeLayer(layer));
|
|
2379
|
+
}
|
|
2321
2380
|
}
|
|
2322
2381
|
|
|
2323
2382
|
/*
|