28
28
import org .opentripplanner .street .model .vertex .LabelledIntersectionVertex ;
29
29
import org .opentripplanner .street .model .vertex .TransitStopVertex ;
30
30
import org .opentripplanner .street .model .vertex .Vertex ;
31
+ import org .opentripplanner .street .model .vertex .VertexFactory ;
31
32
import org .opentripplanner .street .search .TraverseMode ;
32
33
import org .opentripplanner .street .search .TraverseModeSet ;
33
34
import org .opentripplanner .test .support .GeoJsonIo ;
@@ -46,14 +47,15 @@ private Graph prepareTest(Coordinate[] platform, int[] visible, Coordinate[] sto
46
47
var deduplicator = new Deduplicator ();
47
48
var siteRepository = new SiteRepository ();
48
49
Graph graph = new Graph (deduplicator );
50
+ var vertexFactory = new VertexFactory (graph );
51
+
49
52
var timetableRepository = new TimetableRepository (siteRepository , deduplicator );
50
53
ArrayList <IntersectionVertex > vertices = new ArrayList <>();
51
54
Coordinate [] closedGeom = new Coordinate [platform .length + 1 ];
52
55
53
56
for (int i = 0 ; i < platform .length ; i ++) {
54
57
Coordinate c = platform [i ];
55
- var vertex = new LabelledIntersectionVertex (String .valueOf (i ), c .x , c .y , false , false );
56
- graph .addVertex (vertex );
58
+ var vertex = vertexFactory .intersection (String .valueOf (i ), c .x , c .y );
57
59
vertices .add (vertex );
58
60
closedGeom [i ] = c ;
59
61
}
@@ -109,8 +111,7 @@ private Graph prepareTest(Coordinate[] platform, int[] visible, Coordinate[] sto
109
111
graph .index (timetableRepository .getSiteRepository ());
110
112
111
113
for (RegularStop s : transitStops ) {
112
- var v = TransitStopVertex .of ().withStop (s ).build ();
113
- graph .addVertex (v );
114
+ vertexFactory .transitStop (TransitStopVertex .of ().withStop (s ));
114
115
}
115
116
116
117
return graph ;
@@ -212,6 +213,43 @@ void testLinkStopNearPlatformVertex() {
212
213
assertEquals (10 , graph .getEdges ().size ());
213
214
}
214
215
216
+ /**
217
+ * Link an interior vertex which is very close to a visibility vertex by
218
+ * calling directly addPermanentAreaVertex used in boarding location linking
219
+ * A connecting edge pair is created despite of the small distance
220
+ */
221
+ @ Test
222
+ void testAddPermanentAreaVertex () {
223
+ Coordinate [] platform = {
224
+ new Coordinate (10 , 60.002 ),
225
+ new Coordinate (10.004 , 60.002 ),
226
+ new Coordinate (10.004 , 60 ),
227
+ new Coordinate (10 , 60 ),
228
+ };
229
+ // add one entrance to bottom left corner
230
+ int [] visibilityPoints = { 3 };
231
+
232
+ // No stops
233
+ Coordinate [] stops = {};
234
+
235
+ Graph graph = prepareTest (platform , visibilityPoints , stops );
236
+
237
+ // dig up the AreaGroup
238
+ AreaGroup ag = null ;
239
+ var edge = graph .getEdges ().stream ().findFirst ().get ();
240
+ if (edge instanceof AreaEdge ae ) {
241
+ ag = ae .getArea ();
242
+ }
243
+ assertNotNull (ag );
244
+
245
+ var vertexFactory = new VertexFactory (graph );
246
+ var v = vertexFactory .intersection ("boardingLocation" , 10.00000001 , 60.00000001 );
247
+ graph .getLinker ().addPermanentAreaVertex (v , ag );
248
+
249
+ // vertex links to the single visibility point with 2 edges
250
+ assertEquals (10 , graph .getEdges ().size ());
251
+ }
252
+
215
253
/**
216
254
* Link a stop which is inside an area and very close to its edge.
217
255
* Linking snaps directly to the edge without short connecting edges
0 commit comments