@wemap/routers 12.1.0 → 12.2.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.
@@ -0,0 +1,146 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <osm version='0.6' generator='JOSM'>
3
+ <node id='-161218670596205' action='modify' visible='true' lat='45.19343691244' lon='5.71669745344' />
4
+ <node id='-161218670596206' action='modify' visible='true' lat='45.193278084' lon='5.71670229287' />
5
+ <node id='-161218670596207' action='modify' visible='true' lat='45.19328319976' lon='5.71704036911' />
6
+ <node id='-161218670596208' action='modify' visible='true' lat='45.19344202819' lon='5.71703552968' />
7
+ <node id='-161218670596209' action='modify' visible='true' lat='45.19339744873' lon='5.71676589717'>
8
+ <tag k='name' v='p1' />
9
+ </node>
10
+ <node id='-161218670596210' action='modify' visible='true' lat='45.19339817953' lon='5.71679735347'>
11
+ <tag k='name' v='p2' />
12
+ </node>
13
+ <node id='-161218670596211' action='modify' visible='true' lat='45.19337869139' lon='5.71679873616'>
14
+ <tag k='name' v='p3' />
15
+ </node>
16
+ <node id='-161218670596212' action='modify' visible='true' lat='45.19337747338' lon='5.71675656398'>
17
+ <tag k='name' v='p4' />
18
+ </node>
19
+ <node id='-161218670596215' action='modify' visible='true' lat='45.19340061555' lon='5.71685646366'>
20
+ <tag k='name' v='p21' />
21
+ </node>
22
+ <node id='-161218670596216' action='modify' visible='true' lat='45.19340232076' lon='5.71692594406'>
23
+ <tag k='name' v='p22' />
24
+ </node>
25
+ <node id='-161218670596217' action='modify' visible='true' lat='45.19336456249' lon='5.7169345859'>
26
+ <tag k='name' v='p31' />
27
+ </node>
28
+ <node id='-161218670596218' action='modify' visible='true' lat='45.19332436816' lon='5.71693562293'>
29
+ <tag k='highway' v='elevator' />
30
+ <tag k='name' v='p32' />
31
+ </node>
32
+ <node id='-161218670596219' action='modify' visible='true' lat='45.19332315015' lon='5.71686372281'>
33
+ <tag k='name' v='p33' />
34
+ </node>
35
+ <node id='-161218670596220' action='modify' visible='true' lat='45.19329367429' lon='5.71686441416'>
36
+ <tag k='name' v='p34' />
37
+ </node>
38
+ <node id='-161218670596221' action='modify' visible='true' lat='45.19334458713' lon='5.71673374952'>
39
+ <tag k='name' v='p11' />
40
+ </node>
41
+ <node id='-161218670596222' action='modify' visible='true' lat='45.19334531793' lon='5.71679355106'>
42
+ <tag k='name' v='p12' />
43
+ </node>
44
+ <node id='-161218670596223' action='modify' visible='true' lat='45.19331364967' lon='5.71679493375'>
45
+ <tag k='name' v='p13' />
46
+ </node>
47
+ <node id='-161218670596224' action='modify' visible='true' lat='45.19331145725' lon='5.71674342838'>
48
+ <tag k='name' v='p14' />
49
+ </node>
50
+ <node id='-161218670596225' action='modify' visible='true' lat='45.19340037195' lon='5.71697122731'>
51
+ <tag k='name' v='p41' />
52
+ </node>
53
+ <node id='-161218670596226' action='modify' visible='true' lat='45.19340158996' lon='5.71701478219'>
54
+ <tag k='name' v='p42' />
55
+ </node>
56
+ <node id='-161218670596227' action='modify' visible='true' lat='45.19337747338' lon='5.71701581921'>
57
+ <tag k='name' v='p43' />
58
+ </node>
59
+ <node id='-161218670596228' action='modify' visible='true' lat='45.19337771699' lon='5.71697295568'>
60
+ <tag k='name' v='p44' />
61
+ </node>
62
+ <node id='-161218670596230' action='modify' visible='true' lat='45.19334848476' lon='5.71697986915'>
63
+ <tag k='name' v='p48' />
64
+ </node>
65
+ <node id='-161218670596231' action='modify' visible='true' lat='45.19332241934' lon='5.7169805605'>
66
+ <tag k='name' v='p47' />
67
+ </node>
68
+ <node id='-161218670596232' action='modify' visible='true' lat='45.19332363736' lon='5.71702307836'>
69
+ <tag k='name' v='p46' />
70
+ </node>
71
+ <node id='-161218670596233' action='modify' visible='true' lat='45.19334945917' lon='5.71702065864'>
72
+ <tag k='name' v='p45' />
73
+ </node>
74
+ <way id='-921430905467925' action='modify' visible='true'>
75
+ <nd ref='-161218670596205' />
76
+ <nd ref='-161218670596206' />
77
+ <nd ref='-161218670596207' />
78
+ <nd ref='-161218670596208' />
79
+ <nd ref='-161218670596205' />
80
+ <tag k='wemap:routing-bounds' v='yes' />
81
+ </way>
82
+ <way id='-921430905467948' action='modify' visible='true'>
83
+ <nd ref='-161218670596209' />
84
+ <nd ref='-161218670596210' />
85
+ <nd ref='-161218670596211' />
86
+ <tag k='highway' v='footway' />
87
+ </way>
88
+ <way id='-921430905467953' action='modify' visible='true'>
89
+ <nd ref='-161218670596215' />
90
+ <nd ref='-161218670596216' />
91
+ <tag k='highway' v='footway' />
92
+ </way>
93
+ <way id='-921430905467954' action='modify' visible='true'>
94
+ <nd ref='-161218670596218' />
95
+ <nd ref='-161218670596219' />
96
+ <nd ref='-161218670596220' />
97
+ <tag k='highway' v='footway' />
98
+ <tag k='level' v='0' />
99
+ </way>
100
+ <way id='-921430905467957' action='modify' visible='true'>
101
+ <nd ref='-161218670596217' />
102
+ <nd ref='-161218670596218' />
103
+ <tag k='highway' v='footway' />
104
+ <tag k='level' v='1' />
105
+ </way>
106
+ <way id='-921430905467960' action='modify' visible='true'>
107
+ <nd ref='-161218670596221' />
108
+ <nd ref='-161218670596222' />
109
+ <nd ref='-161218670596223' />
110
+ <tag k='highway' v='footway' />
111
+ <tag k='level' v='0' />
112
+ </way>
113
+ <way id='-921430905467963' action='modify' visible='true'>
114
+ <nd ref='-161218670596225' />
115
+ <nd ref='-161218670596226' />
116
+ <nd ref='-161218670596227' />
117
+ <nd ref='-161218670596228' />
118
+ <nd ref='-161218670596225' />
119
+ <tag k='highway' v='footway' />
120
+ </way>
121
+ <way id='-921430905467967' action='modify' visible='true'>
122
+ <nd ref='-161218670596230' />
123
+ <nd ref='-161218670596231' />
124
+ <nd ref='-161218670596232' />
125
+ <nd ref='-161218670596233' />
126
+ <nd ref='-161218670596230' />
127
+ <tag k='highway' v='footway' />
128
+ </way>
129
+ <way id='-921430905467985' action='modify' visible='true'>
130
+ <nd ref='-161218670596233' />
131
+ <nd ref='-161218670596227' />
132
+ <tag k='highway' v='footway' />
133
+ <tag k='oneway' v='yes' />
134
+ </way>
135
+ <way id='-921430905468123' action='modify' visible='true'>
136
+ <nd ref='-161218670596223' />
137
+ <nd ref='-161218670596224' />
138
+ <tag k='highway' v='footway' />
139
+ <tag k='level' v='1' />
140
+ </way>
141
+ <way id='-921430905468128' action='modify' visible='true'>
142
+ <nd ref='-161218670596211' />
143
+ <nd ref='-161218670596212' />
144
+ <tag k='highway' v='footway' />
145
+ </way>
146
+ </osm>
package/dist/index.js CHANGED
@@ -1129,6 +1129,36 @@ class GraphRouterEngine {
1129
1129
  calculateShortestPathByVertex(source, target, options = GraphRouterOptionsBuilder.DEFAULT, inputVertices = this.graph.vertices, inputEdges = this.graph.edges) {
1130
1130
  return this.calculateShortestPathToMultipleDestinationsByVertex(source, [target], options, inputVertices, inputEdges);
1131
1131
  }
1132
+ // https://en.wikipedia.org/wiki/Component_(graph_theory)
1133
+ calculateComponents() {
1134
+ function shiftSet(set) {
1135
+ const firstValue = set.values().next().value;
1136
+ set.delete(firstValue);
1137
+ return firstValue;
1138
+ }
1139
+ const verticesToTest = new Set(this.graph.vertices);
1140
+ let components = [];
1141
+ while (verticesToTest.size > 0) {
1142
+ const vertexToTest = shiftSet(verticesToTest);
1143
+ const otherVertices = this.graph.vertices.filter((v) => v.id !== vertexToTest.id);
1144
+ const result = this.calculateShortestPathToMultipleDestinationsByVertex(vertexToTest, otherVertices);
1145
+ const reachedVertices = otherVertices.filter((ov) => result.weightedDistance(ov) !== null);
1146
+ components.push([vertexToTest, ...reachedVertices]);
1147
+ reachedVertices.forEach((rv) => verticesToTest.delete(rv));
1148
+ }
1149
+ for (let i = 0; i < components.length - 1; i++) {
1150
+ const component1 = components[i];
1151
+ for (let j = i + 1; j < components.length; j++) {
1152
+ const component2 = components[j];
1153
+ const componentsIntersect = component2.some((v) => component1.includes(v));
1154
+ if (componentsIntersect) {
1155
+ component1.push(...component2);
1156
+ components = components.filter((component) => component !== component2);
1157
+ }
1158
+ }
1159
+ }
1160
+ return components.map((c) => [...new Set(c)]);
1161
+ }
1132
1162
  }
1133
1163
  class GraphRouterResults extends GraphRouterEngineResults {
1134
1164
  constructor(engineResults, sourceProjection, targetsProjections) {