@any-routing/annotation-plugin 0.0.0 → 1.0.0-rc.1
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 -1
- package/package.json +52 -20
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -2
- package/src/index.js.map +0 -1
- package/src/lib/annotation-plugin.d.ts +0 -31
- package/src/lib/annotation-plugin.js +0 -127
- package/src/lib/annotation-plugin.js.map +0 -1
- package/src/lib/annotation.worker.d.ts +0 -15
- package/src/lib/annotation.worker.js +0 -23
- package/src/lib/annotation.worker.js.map +0 -1
- package/src/lib/line-diff.d.ts +0 -8
- package/src/lib/line-diff.js +0 -124
- package/src/lib/line-diff.js.map +0 -1
- package/src/lib/popup-component.d.ts +0 -20
- package/src/lib/popup-component.js +0 -41
- package/src/lib/popup-component.js.map +0 -1
- package/src/lib/utils.d.ts +0 -1
- package/src/lib/utils.js +0 -13
- package/src/lib/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This library was generated with [Nx](https://nx.dev).
|
|
4
4
|
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build annotation-plugin` to build the library.
|
|
8
|
+
|
|
5
9
|
## Running unit tests
|
|
6
10
|
|
|
7
|
-
Run `nx test annotation-plugin` to execute the unit tests via [
|
|
11
|
+
Run `nx test annotation-plugin` to execute the unit tests via [Vitest](https://vitest.dev/).
|
package/package.json
CHANGED
|
@@ -1,25 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@any-routing/annotation-plugin",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"*.js",
|
|
10
|
+
"*.d.ts",
|
|
11
|
+
"assets",
|
|
12
|
+
"README.md",
|
|
13
|
+
"package.json"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./index.d.ts",
|
|
18
|
+
"import": "./index.js"
|
|
19
|
+
},
|
|
20
|
+
"./maplibre": {
|
|
21
|
+
"types": "./maplibre.d.ts",
|
|
22
|
+
"import": "./maplibre.js"
|
|
23
|
+
},
|
|
24
|
+
"./leaflet": {
|
|
25
|
+
"types": "./leaflet.d.ts",
|
|
26
|
+
"import": "./leaflet.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
5
30
|
"peerDependencies": {
|
|
6
|
-
"@any-routing/core": "^0
|
|
7
|
-
"maplibre-gl": "^
|
|
8
|
-
"
|
|
9
|
-
"tslib": "2.5.0"
|
|
31
|
+
"@any-routing/core": "^0.0.1",
|
|
32
|
+
"maplibre-gl": "^6.8.0",
|
|
33
|
+
"leaflet": "^1.9.4"
|
|
10
34
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"@turf/length": "6.5.0",
|
|
19
|
-
"@turf/meta": "6.5.0",
|
|
20
|
-
"comlink": "4.3.1",
|
|
21
|
-
"parse-ms": "3.0.0"
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"leaflet": {
|
|
37
|
+
"optional": true
|
|
38
|
+
},
|
|
39
|
+
"maplibre-gl": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
22
42
|
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@turf/along": "^7.4.0",
|
|
45
|
+
"@turf/bbox": "7.4.0",
|
|
46
|
+
"@turf/bbox-clip": "^7.4.0",
|
|
47
|
+
"@turf/bearing": "^7.4.0",
|
|
48
|
+
"@turf/helpers": "7.4.0",
|
|
49
|
+
"@turf/invariant": "^7.4.0",
|
|
50
|
+
"@turf/length": "^7.4.0",
|
|
51
|
+
"@turf/meta": "^7.4.0",
|
|
52
|
+
"@types/geojson": "7946.0.16",
|
|
53
|
+
"@types/leaflet": "^1.9.22",
|
|
54
|
+
"comlink": "4.4.2",
|
|
55
|
+
"parse-ms": "^4.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/annotation-plugin';
|
package/src/index.js
DELETED
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/annotation-plugin/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Map } from 'maplibre-gl';
|
|
2
|
-
import type { AnyRouting, AnyRoutingPlugin } from '@any-routing/core';
|
|
3
|
-
import type { HereRoutingData } from '@any-routing/here-data-provider';
|
|
4
|
-
import { AnnotationPopupComponentI } from './popup-component';
|
|
5
|
-
export interface AnnotationPluginOptions {
|
|
6
|
-
routeLayerIds: string[];
|
|
7
|
-
calculatePopupOnFly: boolean;
|
|
8
|
-
componentFactory(id: any, routeData: any, ctx: AnyRouting): AnnotationPopupComponentI;
|
|
9
|
-
}
|
|
10
|
-
export declare class AnnotationPlugin implements AnyRoutingPlugin {
|
|
11
|
-
private map;
|
|
12
|
-
private mapBounds;
|
|
13
|
-
private bounds?;
|
|
14
|
-
private worker;
|
|
15
|
-
private popups;
|
|
16
|
-
private allInBbox;
|
|
17
|
-
private ctx;
|
|
18
|
-
private options;
|
|
19
|
-
private workerApi;
|
|
20
|
-
private data;
|
|
21
|
-
private components;
|
|
22
|
-
private clearMapHandler;
|
|
23
|
-
private routeCalculatedHandler;
|
|
24
|
-
private mapMoveEndHandler;
|
|
25
|
-
constructor(options?: {});
|
|
26
|
-
onAdd(ctx: AnyRouting<HereRoutingData, Map>): void;
|
|
27
|
-
onRemove(): void;
|
|
28
|
-
private routeCalculated;
|
|
29
|
-
recalculate(force?: boolean): Promise<void>;
|
|
30
|
-
private destroyView;
|
|
31
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { Popup } from 'maplibre-gl';
|
|
3
|
-
import { featureCollection, point } from '@turf/helpers';
|
|
4
|
-
import { wrap } from 'comlink';
|
|
5
|
-
import bbox from '@turf/bbox';
|
|
6
|
-
import { AnnotationPopupComponent } from './popup-component';
|
|
7
|
-
const defaultConfig = {
|
|
8
|
-
routeLayerIds: [],
|
|
9
|
-
calculatePopupOnFly: true,
|
|
10
|
-
componentFactory(routeId, data, ctx) {
|
|
11
|
-
return new AnnotationPopupComponent(routeId, data, ctx);
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
const resolveOptions = (ctx, options) => {
|
|
15
|
-
return Object.assign(Object.assign({}, options), { routeLayerIds: options.routeLayerIds.map((id) => ctx.getUniqueName(id)) });
|
|
16
|
-
};
|
|
17
|
-
export class AnnotationPlugin {
|
|
18
|
-
constructor(options = {}) {
|
|
19
|
-
this.popups = [];
|
|
20
|
-
this.allInBbox = false;
|
|
21
|
-
this.components = [];
|
|
22
|
-
this.clearMapHandler = () => {
|
|
23
|
-
this.data = undefined;
|
|
24
|
-
this.destroyView();
|
|
25
|
-
};
|
|
26
|
-
this.routeCalculatedHandler = this.routeCalculated.bind(this);
|
|
27
|
-
this.mapMoveEndHandler = this.recalculate.bind(this);
|
|
28
|
-
this.options = Object.assign(Object.assign({}, defaultConfig), options);
|
|
29
|
-
this.worker = new Worker(new URL('./annotation.worker', import.meta.url), {
|
|
30
|
-
type: 'module',
|
|
31
|
-
});
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
this.workerApi = wrap(this.worker);
|
|
34
|
-
}
|
|
35
|
-
onAdd(ctx) {
|
|
36
|
-
this.options = resolveOptions(ctx, this.options);
|
|
37
|
-
this.ctx = ctx;
|
|
38
|
-
this.map = ctx.map;
|
|
39
|
-
this.ctx.on('routesFound', this.routeCalculatedHandler);
|
|
40
|
-
this.ctx.on('calculationStarted', this.clearMapHandler);
|
|
41
|
-
this.map.on(this.options.calculatePopupOnFly ? 'render' : 'idle', this.mapMoveEndHandler);
|
|
42
|
-
}
|
|
43
|
-
onRemove() {
|
|
44
|
-
this.ctx.off('routesFound', this.routeCalculatedHandler);
|
|
45
|
-
this.ctx.off('calculationStarted', this.clearMapHandler);
|
|
46
|
-
this.worker.terminate();
|
|
47
|
-
this.destroyView();
|
|
48
|
-
}
|
|
49
|
-
routeCalculated() {
|
|
50
|
-
var _a, _b;
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const data = this.ctx.data;
|
|
53
|
-
if (!data) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (((_a = this.data) === null || _a === void 0 ? void 0 : _a.version) === data.version || !data.latest) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
this.data = data;
|
|
60
|
-
this.destroyView();
|
|
61
|
-
if ((_b = this.ctx.state.data) === null || _b === void 0 ? void 0 : _b.latest) {
|
|
62
|
-
yield this.workerApi.createChunks(this.data);
|
|
63
|
-
yield this.recalculate(true);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
recalculate(force = false) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
this.mapBounds = this.map.getBounds();
|
|
70
|
-
if (!this.data) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (this.bounds &&
|
|
74
|
-
this.bounds.length === 4 &&
|
|
75
|
-
this.mapBounds.contains([this.bounds[0], this.bounds[1]]) &&
|
|
76
|
-
this.mapBounds.contains([this.bounds[2], this.bounds[3]]) &&
|
|
77
|
-
this.allInBbox &&
|
|
78
|
-
!force) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const sw = this.mapBounds.getSouthWest();
|
|
82
|
-
const ne = this.mapBounds.getNorthEast();
|
|
83
|
-
const { points, allInBbox } = yield this.workerApi.recalculatePos({
|
|
84
|
-
bbox: { sw, ne },
|
|
85
|
-
});
|
|
86
|
-
if (!points.length)
|
|
87
|
-
return;
|
|
88
|
-
if (this.bounds &&
|
|
89
|
-
this.bounds.length === 4 &&
|
|
90
|
-
this.mapBounds.contains([this.bounds[0], this.bounds[1]]) &&
|
|
91
|
-
this.mapBounds.contains([this.bounds[2], this.bounds[3]]) &&
|
|
92
|
-
!force) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
this.destroyView();
|
|
96
|
-
this.allInBbox = allInBbox;
|
|
97
|
-
this.bounds = bbox(featureCollection(points.map((p) => point(p.lngLat))));
|
|
98
|
-
this.components = [];
|
|
99
|
-
points.forEach((point) => {
|
|
100
|
-
const component = this.options.componentFactory(point.properties.routeId, this.data, this.ctx);
|
|
101
|
-
const popup = new Popup({
|
|
102
|
-
closeButton: false,
|
|
103
|
-
closeOnClick: false,
|
|
104
|
-
className: 'no-mouse-events',
|
|
105
|
-
})
|
|
106
|
-
.setLngLat(point.lngLat)
|
|
107
|
-
.setDOMContent(component.container)
|
|
108
|
-
.addTo(this.map);
|
|
109
|
-
if ('onAttach' in component) {
|
|
110
|
-
component.onAttach(popup);
|
|
111
|
-
}
|
|
112
|
-
const popupElem = popup.getElement();
|
|
113
|
-
popupElem.querySelector('.maplibregl-popup-content').style.padding = '0';
|
|
114
|
-
this.components.push(component);
|
|
115
|
-
this.popups.push(popup);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
destroyView() {
|
|
120
|
-
this.allInBbox = false;
|
|
121
|
-
this.components.forEach((c) => c.destroy());
|
|
122
|
-
this.popups.forEach((p) => p.remove());
|
|
123
|
-
this.popups = [];
|
|
124
|
-
this.components = [];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
//# sourceMappingURL=annotation-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-plugin.js","sourceRoot":"","sources":["../../../../../packages/annotation-plugin/src/lib/annotation-plugin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAQ,iBAAiB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,OAAO,EAAE,wBAAwB,EAAuC,MAAM,mBAAmB,CAAC;AAQlG,MAAM,aAAa,GAA4B;IAC7C,aAAa,EAAE,EAAE;IACjB,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG;QACjC,OAAO,IAAI,wBAAwB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,GAAe,EAAE,OAAgC,EAA2B,EAAE;IACpG,uCACK,OAAO,KACV,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,IACvE;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,gBAAgB;IAmB3B,YAAY,OAAO,GAAG,EAAE;QAdhB,WAAM,GAAY,EAAE,CAAC;QACrB,cAAS,GAAG,KAAK,CAAC;QAKlB,eAAU,GAAgC,EAAE,CAAC;QAC7C,oBAAe,GAAG,GAAG,EAAE;YAC7B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC,CAAC;QACM,2BAAsB,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,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EAAE,KAAK;oBAClB,YAAY,EAAE,KAAK;oBACnB,SAAS,EAAE,iBAAiB;iBAC7B,CAAC;qBACC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;qBACvB,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC;qBAClC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAEnB,IAAI,UAAU,IAAI,SAAS,EAAE;oBAC1B,SAAkD,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBACrE;gBAED,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;gBACpC,SAAS,CAAC,aAAa,CAAC,2BAA2B,CAAS,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;gBAElF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;IAEO,WAAW;QACjB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AnyRoutingDataResponse } from '@any-routing/core';
|
|
2
|
-
declare const api: {
|
|
3
|
-
createChunks(data: AnyRoutingDataResponse): void;
|
|
4
|
-
recalculatePos({ bbox: { ne, sw } }: {
|
|
5
|
-
bbox: {
|
|
6
|
-
ne: any;
|
|
7
|
-
sw: any;
|
|
8
|
-
};
|
|
9
|
-
}): {
|
|
10
|
-
points: any;
|
|
11
|
-
allInBbox: boolean;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export type AnnotationWorkerApi = typeof api;
|
|
15
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import bboxClip from '@turf/bbox-clip';
|
|
2
|
-
import { expose } from 'comlink';
|
|
3
|
-
import { calculatePos, getDistinctSegments } from './line-diff';
|
|
4
|
-
let chunks = [];
|
|
5
|
-
const api = {
|
|
6
|
-
createChunks(data) {
|
|
7
|
-
const fc = data.routesShapeGeojson;
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
chunks = getDistinctSegments(fc.features);
|
|
10
|
-
},
|
|
11
|
-
recalculatePos({ bbox: { ne, sw } }) {
|
|
12
|
-
const bboxChunks = chunks
|
|
13
|
-
.map((chunk) => {
|
|
14
|
-
return bboxClip(chunk, [sw.lng, sw.lat, ne.lng, ne.lat]);
|
|
15
|
-
})
|
|
16
|
-
.filter(({ geometry: { coordinates } }) => coordinates.length > 0);
|
|
17
|
-
const points = calculatePos(bboxChunks);
|
|
18
|
-
const allInBbox = points.length === chunks.length;
|
|
19
|
-
return { points, allInBbox };
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
expose(api);
|
|
23
|
-
//# sourceMappingURL=annotation.worker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"annotation.worker.js","sourceRoot":"","sources":["../../../../../packages/annotation-plugin/src/lib/annotation.worker.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEhE,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,MAAM,GAAG,GAAG;IACV,YAAY,CAAC,IAA4B;QACvC,MAAM,EAAE,GAAsB,IAAI,CAAC,kBAAkB,CAAC;QAEtD,aAAa;QACb,MAAM,GAAG,mBAAmB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED,cAAc,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QACjC,MAAM,UAAU,GAAG,MAAM;aACtB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAErE,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;QACxC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC;QAElD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC/B,CAAC;CACF,CAAC;AAIF,MAAM,CAAC,GAAG,CAAC,CAAC"}
|
package/src/lib/line-diff.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Feature } from '@turf/helpers';
|
|
2
|
-
export declare function findDistinctSegments(linestrings: Feature[]): Feature<import("@turf/helpers").Geometry | import("@turf/helpers").GeometryCollection, {
|
|
3
|
-
[name: string]: any;
|
|
4
|
-
}>[] | Feature<import("@turf/helpers").LineString, any>[];
|
|
5
|
-
export declare function getDistinctSegments(routes?: any[]): Feature<import("@turf/helpers").Geometry | import("@turf/helpers").GeometryCollection, {
|
|
6
|
-
[name: string]: any;
|
|
7
|
-
}>[] | Feature<import("@turf/helpers").LineString, any>[];
|
|
8
|
-
export declare function calculatePos(segments: any): any;
|
package/src/lib/line-diff.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { coordAll } from '@turf/meta';
|
|
3
|
-
import { lineString } from '@turf/helpers';
|
|
4
|
-
import { getCoord } from '@turf/invariant';
|
|
5
|
-
import along from '@turf/along';
|
|
6
|
-
import lineLength from '@turf/length';
|
|
7
|
-
import bearing from '@turf/bearing';
|
|
8
|
-
const TOLERANCE = 0.00001;
|
|
9
|
-
const floatEquals = (f1, f2) => Math.abs(f1 - f2) < TOLERANCE;
|
|
10
|
-
const coordEquals = (c1 = [], c2 = []) => floatEquals(c1[0], c2[0]) && floatEquals(c1[1], c2[1]);
|
|
11
|
-
const asKey = (coord) => `${coord[0].toFixed(6)},${coord[1].toFixed(6)}`;
|
|
12
|
-
const last = (array = []) => array[array.length - 1];
|
|
13
|
-
// find the point at the given distance ratio on the linestring
|
|
14
|
-
const project = (ratio) => (ls) => {
|
|
15
|
-
let line = ls;
|
|
16
|
-
if (ls.geometry.type === 'MultiLineString') {
|
|
17
|
-
line = lineString(ls.geometry.coordinates[0]);
|
|
18
|
-
ls.geometry.coordinates.forEach((cords, index) => {
|
|
19
|
-
if (index === 0)
|
|
20
|
-
return;
|
|
21
|
-
const cordsLine = lineString(cords);
|
|
22
|
-
if (lineLength(cordsLine) > lineLength(line)) {
|
|
23
|
-
line = cordsLine;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const length = lineLength(line);
|
|
28
|
-
const lngLat = getCoord(along(line, length * ratio));
|
|
29
|
-
// keep the local bearing of the line to later choose an anchor minimizing the portion of line covered.
|
|
30
|
-
const localLineBearing = bearing(along(line, length * (ratio - 0.1)), along(line, length * (ratio + 0.1)));
|
|
31
|
-
return { lngLat, localLineBearing, properties: ls.properties };
|
|
32
|
-
};
|
|
33
|
-
function distinctSegment(coordinates, coordCounts, properties) {
|
|
34
|
-
const adjacentCoordsUsedOnce = [[]];
|
|
35
|
-
coordinates.forEach((coord) => {
|
|
36
|
-
if (coordCounts.get(asKey(coord)) > 1) {
|
|
37
|
-
adjacentCoordsUsedOnce.push([]);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
last(adjacentCoordsUsedOnce).push(coord);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
const longestDistinctSegment = adjacentCoordsUsedOnce
|
|
44
|
-
.filter((a) => a.length > 0)
|
|
45
|
-
.reduce((longest, current) => (current.length > longest.length ? current : longest), []);
|
|
46
|
-
return lineString(longestDistinctSegment.length === 0 ? coordinates : longestDistinctSegment, properties);
|
|
47
|
-
}
|
|
48
|
-
// extract the longest segment of each linestring
|
|
49
|
-
// whose coordinates don't overlap with another feature
|
|
50
|
-
export function findDistinctSegments(linestrings) {
|
|
51
|
-
if (linestrings.length < 2) {
|
|
52
|
-
return linestrings;
|
|
53
|
-
}
|
|
54
|
-
// extract raw coordinates
|
|
55
|
-
const featuresCoords = linestrings.map(coordAll);
|
|
56
|
-
// count occurences of each coordinate accross all features
|
|
57
|
-
const coordCounts = new Map();
|
|
58
|
-
[].concat(...featuresCoords).forEach((coord) => {
|
|
59
|
-
coordCounts.set(asKey(coord), (coordCounts.get(asKey(coord)) || 0) + 1);
|
|
60
|
-
});
|
|
61
|
-
return featuresCoords.map((coordinates, index) => distinctSegment(coordinates, coordCounts, linestrings[index].properties));
|
|
62
|
-
}
|
|
63
|
-
function toSimpleLinestring(feature) {
|
|
64
|
-
const allCoordsWithNoDups = coordAll(feature).reduce((noDups, coord) => {
|
|
65
|
-
const prevCoord = last(noDups);
|
|
66
|
-
if (!prevCoord || !coordEquals(prevCoord, coord)) {
|
|
67
|
-
noDups.push(coord);
|
|
68
|
-
}
|
|
69
|
-
return noDups;
|
|
70
|
-
}, []);
|
|
71
|
-
return lineString(allCoordsWithNoDups, feature.properties);
|
|
72
|
-
}
|
|
73
|
-
// Reduce possibilities of collision by chosing anchors so that labels repulse each other
|
|
74
|
-
function optimizeAnchors(positions) {
|
|
75
|
-
return positions.map((position, index) => {
|
|
76
|
-
const others = positions.slice();
|
|
77
|
-
others.splice(index, 1);
|
|
78
|
-
const othersBearing = getBearingFromOtherPoints(position, others);
|
|
79
|
-
return {
|
|
80
|
-
lngLat: position.lngLat,
|
|
81
|
-
anchor: getAnchor(position, othersBearing),
|
|
82
|
-
properties: position.properties,
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function getBearingFromOtherPoints(position, others) {
|
|
87
|
-
return (others
|
|
88
|
-
.map((other) => bearing(other.lngLat, position.lngLat))
|
|
89
|
-
.reduce((avg, value, _index, { length }) => avg + value / length, 0) || // mean
|
|
90
|
-
0);
|
|
91
|
-
}
|
|
92
|
-
function getAnchor(position, otherBearing) {
|
|
93
|
-
const axis = Math.abs(position.localLineBearing) < 45 || Math.abs(position.localLineBearing) > 135 ? 'vertical' : 'horizontal';
|
|
94
|
-
if (axis === 'vertical') {
|
|
95
|
-
return otherBearing > 0 ? 'left' : 'right';
|
|
96
|
-
}
|
|
97
|
-
return Math.abs(otherBearing) < 90 ? 'bottom' : 'top';
|
|
98
|
-
}
|
|
99
|
-
// routes can be a FeatureCollection or an array of Feature or Geometry
|
|
100
|
-
export function getDistinctSegments(routes = []) {
|
|
101
|
-
const featuresOrGeoms = Array.isArray(routes) ? routes : routes.features;
|
|
102
|
-
const mergedRoutes = mergeRoutes(featuresOrGeoms);
|
|
103
|
-
const lineStrings = mergedRoutes.map(toSimpleLinestring);
|
|
104
|
-
return findDistinctSegments(lineStrings);
|
|
105
|
-
}
|
|
106
|
-
export function calculatePos(segments) {
|
|
107
|
-
const positions = segments.map(project(0.5));
|
|
108
|
-
return optimizeAnchors(positions);
|
|
109
|
-
}
|
|
110
|
-
function mergeRoutes(featureCollections) {
|
|
111
|
-
return featureCollections.reduce((acc, feature) => {
|
|
112
|
-
if (acc[feature.properties.routeId]) {
|
|
113
|
-
acc[feature.properties.routeId].geometry.coordinates = [
|
|
114
|
-
...acc[feature.properties.routeId].geometry.coordinates,
|
|
115
|
-
...feature.geometry.coordinates,
|
|
116
|
-
];
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
acc[feature.properties.routeId] = feature;
|
|
120
|
-
}
|
|
121
|
-
return acc;
|
|
122
|
-
}, []);
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=line-diff.js.map
|
package/src/lib/line-diff.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"line-diff.js","sourceRoot":"","sources":["../../../../../packages/annotation-plugin/src/lib/line-diff.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAW,UAAU,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC,MAAM,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,WAAW,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;AAC9D,MAAM,WAAW,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACjG,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,C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AG,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACzD,OAAO,oBAAoB,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAQ;IACnC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,WAAW,CAAC,kBAAkB;IACrC,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAChD,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YACnC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,GAAG;gBACrD,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW;gBACvD,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW;aAChC,CAAC;SACH;aAAM;YACL,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;SAC3C;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Popup } from 'maplibre-gl';
|
|
2
|
-
import type { AnyRouting } from '@any-routing/core';
|
|
3
|
-
export interface AnnotationPopupComponentI {
|
|
4
|
-
container: HTMLElement;
|
|
5
|
-
destroy(): void;
|
|
6
|
-
}
|
|
7
|
-
export interface OnAttach {
|
|
8
|
-
onAttach(popup: Popup): void;
|
|
9
|
-
}
|
|
10
|
-
export declare class AnnotationPopupComponent implements AnnotationPopupComponentI {
|
|
11
|
-
private routeId;
|
|
12
|
-
private ctx;
|
|
13
|
-
readonly container: any;
|
|
14
|
-
private routeSelectedHandler;
|
|
15
|
-
constructor(routeId: any, data: any, ctx: AnyRouting);
|
|
16
|
-
private render;
|
|
17
|
-
destroy(): void;
|
|
18
|
-
private routeSelected;
|
|
19
|
-
private applyColor;
|
|
20
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { formatMS } from './utils';
|
|
2
|
-
const icon = '<svg width="20" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="car" class="svg-inline--fa fa-car fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path id="car" fill="#40abf7" d="M499.99 176h-59.87l-16.64-41.6C406.38 91.63 365.57 64 319.5 64h-127c-46.06 0-86.88 27.63-103.99 70.4L71.87 176H12.01C4.2 176-1.53 183.34.37 190.91l6 24C7.7 220.25 12.5 224 18.01 224h20.07C24.65 235.73 16 252.78 16 272v48c0 16.12 6.16 30.67 16 41.93V416c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32v-32h256v32c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32v-54.07c9.84-11.25 16-25.8 16-41.93v-48c0-19.22-8.65-36.27-22.07-48H494c5.51 0 10.31-3.75 11.64-9.09l6-24c1.89-7.57-3.84-14.91-11.65-14.91zm-352.06-17.83c7.29-18.22 24.94-30.17 44.57-30.17h127c19.63 0 37.28 11.95 44.57 30.17L384 208H128l19.93-49.83zM96 319.8c-19.2 0-32-12.76-32-31.9S76.8 256 96 256s48 28.71 48 47.85-28.8 15.95-48 15.95zm320 0c-19.2 0-48 3.19-48-15.95S396.8 256 416 256s32 12.76 32 31.9-12.8 31.9-32 31.9z"></path></svg>';
|
|
3
|
-
export class AnnotationPopupComponent {
|
|
4
|
-
constructor(routeId, data, ctx) {
|
|
5
|
-
this.routeId = routeId;
|
|
6
|
-
this.ctx = ctx;
|
|
7
|
-
this.routeSelectedHandler = this.routeSelected.bind(this);
|
|
8
|
-
this.container = document.createElement('div');
|
|
9
|
-
this.container.onclick = () => {
|
|
10
|
-
ctx.selectRoute(routeId);
|
|
11
|
-
};
|
|
12
|
-
ctx.on('routeSelected', this.routeSelectedHandler);
|
|
13
|
-
this.render(routeId, data);
|
|
14
|
-
}
|
|
15
|
-
render(routeId, data) {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
this.container.style.padding = '4px 5px';
|
|
18
|
-
this.container.style.display = 'flex';
|
|
19
|
-
this.container.style.cursor = 'pointer';
|
|
20
|
-
this.container.innerHTML = `
|
|
21
|
-
${icon}
|
|
22
|
-
<div style="display: inline-block; line-height: initial;">
|
|
23
|
-
<div style="margin-left: 8px; font-size: .9rem">${formatMS(((_a = data.routes[routeId]) === null || _a === void 0 ? void 0 : _a.durationTime) * 1000)}</div>
|
|
24
|
-
<span style="margin-left: 8px; font-size: .7rem;">${(((_b = data.routes[routeId]) === null || _b === void 0 ? void 0 : _b.distance) / 1000).toFixed(1)} km</span>
|
|
25
|
-
</div>
|
|
26
|
-
`;
|
|
27
|
-
this.applyColor();
|
|
28
|
-
}
|
|
29
|
-
destroy() {
|
|
30
|
-
this.ctx.off('routeSelected', this.routeSelectedHandler);
|
|
31
|
-
}
|
|
32
|
-
routeSelected() {
|
|
33
|
-
this.applyColor();
|
|
34
|
-
}
|
|
35
|
-
applyColor() {
|
|
36
|
-
var _a;
|
|
37
|
-
const color = this.ctx.selectedRouteId === this.routeId ? '#e207ff' : '#33C9EB';
|
|
38
|
-
(_a = this.container.querySelector('svg #car')) === null || _a === void 0 ? void 0 : _a.setAttribute('fill', color);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=popup-component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"popup-component.js","sourceRoot":"","sources":["../../../../../packages/annotation-plugin/src/lib/popup-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,MAAM,IAAI,GACR,ogCAAogC,CAAC;AAWvgC,MAAM,OAAO,wBAAwB;IAKn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IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEO,UAAU;;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAEhF,MAAA,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,0CAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;CACF"}
|
package/src/lib/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function formatMS(ms: number): string;
|
package/src/lib/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import parseMilliseconds from 'parse-ms';
|
|
2
|
-
export function formatMS(ms) {
|
|
3
|
-
const { days, seconds, minutes, hours } = parseMilliseconds(ms);
|
|
4
|
-
if (days === 0 && hours === 0 && minutes === 0)
|
|
5
|
-
return `${seconds}s`;
|
|
6
|
-
else if (days === 0 && hours === 0)
|
|
7
|
-
return `${minutes}m ${seconds} s`;
|
|
8
|
-
else if (days === 0)
|
|
9
|
-
return `${hours}h ${minutes}m`;
|
|
10
|
-
else
|
|
11
|
-
return `${days * 24 + hours}h`;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=utils.js.map
|
package/src/lib/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../packages/annotation-plugin/src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAEhE,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,GAAG,OAAO,GAAG,CAAC;SAChE,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,GAAG,OAAO,KAAK,OAAO,IAAI,CAAC;SACjE,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,KAAK,KAAK,OAAO,GAAG,CAAC;;QAC/C,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;AACtC,CAAC"}
|