@wemap/geo 11.5.0 → 11.7.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/dist/index.js +200 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +198 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/graph/GeoGraph.ts +14 -5
- package/src/types.ts +3 -2
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/geo"
|
|
14
14
|
},
|
|
15
15
|
"name": "@wemap/geo",
|
|
16
|
-
"version": "11.
|
|
16
|
+
"version": "11.7.0",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
19
19
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
},
|
|
46
46
|
"./tests/*": "./tests/*"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "e06f16f4114b6e8da0c0f6bbda65c1ad1a3f45ce"
|
|
49
49
|
}
|
package/src/graph/GeoGraph.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Graph } from '@wemap/utils';
|
|
|
3
3
|
import BoundingBox from '../coordinates/BoundingBox.js';
|
|
4
4
|
import Coordinates from '../coordinates/Coordinates.js';
|
|
5
5
|
import Level from '../coordinates/Level.js';
|
|
6
|
-
import { Level_t, GeoGraphJson } from '../types.js';
|
|
6
|
+
import { Level_t, GeoGraphJson, GeoGraphEdgeExtras } from '../types.js';
|
|
7
7
|
|
|
8
8
|
import GeoGraphEdge from './GeoGraphEdge.js';
|
|
9
9
|
import GeoGraphVertex from './GeoGraphVertex.js';
|
|
@@ -50,13 +50,21 @@ class GeoGraph<VertexData = unknown, EdgeData = unknown> extends Graph<VertexDat
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
toCompressedJson(): GeoGraphJson {
|
|
53
|
+
|
|
54
|
+
const createEdgeExtras = (edge: GeoGraphEdge) => {
|
|
55
|
+
const extras: GeoGraphEdgeExtras = {};
|
|
56
|
+
if (edge.isOneway) { extras.oneway = true }
|
|
57
|
+
return extras;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
return {
|
|
54
61
|
vertices: this.vertices.map(vertex => vertex.toJson()),
|
|
55
62
|
edges: this.edges.map(edge => {
|
|
56
63
|
const vertex1Idx = this.vertices.indexOf(edge.vertex1);
|
|
57
64
|
const vertex2Idx = this.vertices.indexOf(edge.vertex2);
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
const edgeExtras = createEdgeExtras(edge);
|
|
66
|
+
if (Object.keys(edgeExtras).length > 0) {
|
|
67
|
+
return [vertex1Idx, vertex2Idx, edge.level, edgeExtras];
|
|
60
68
|
}
|
|
61
69
|
if (edge.level !== null) {
|
|
62
70
|
return [vertex1Idx, vertex2Idx, edge.level];
|
|
@@ -79,8 +87,9 @@ class GeoGraph<VertexData = unknown, EdgeData = unknown> extends Graph<VertexDat
|
|
|
79
87
|
geograph.vertices[jsonEdge[1]],
|
|
80
88
|
{ level: jsonEdge.length > 2 ? jsonEdge[2] : null }
|
|
81
89
|
);
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
const extras: GeoGraphEdgeExtras = jsonEdge.length > 3 ? jsonEdge[3]! : {}
|
|
91
|
+
if (typeof extras.oneway !== 'undefined') {
|
|
92
|
+
edge.isOneway = extras.oneway;
|
|
84
93
|
}
|
|
85
94
|
return edge;
|
|
86
95
|
});
|
package/src/types.ts
CHANGED
|
@@ -38,13 +38,14 @@ export type UserPositionJson = CoordinatesJson & {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export type GraphVertexJson = CoordinatesCompressedJson;
|
|
41
|
+
export type GeoGraphEdgeExtras = { oneway?: boolean }
|
|
41
42
|
|
|
42
43
|
export type GeoGraphJson = {
|
|
43
44
|
vertices: GraphVertexJson[],
|
|
44
45
|
edges: (
|
|
45
46
|
[number, number] |
|
|
46
|
-
[number, number,
|
|
47
|
-
[number, number, Level_t,
|
|
47
|
+
[number, number, Level_t] |
|
|
48
|
+
[number, number, Level_t, GeoGraphEdgeExtras]
|
|
48
49
|
)[]
|
|
49
50
|
};
|
|
50
51
|
|