2828import org .opentripplanner .street .model .vertex .LabelledIntersectionVertex ;
2929import org .opentripplanner .street .model .vertex .TransitStopVertex ;
3030import org .opentripplanner .street .model .vertex .Vertex ;
31+ import org .opentripplanner .street .model .vertex .VertexFactory ;
3132import org .opentripplanner .street .search .TraverseMode ;
3233import org .opentripplanner .street .search .TraverseModeSet ;
3334import org .opentripplanner .test .support .GeoJsonIo ;
@@ -46,14 +47,15 @@ private Graph prepareTest(Coordinate[] platform, int[] visible, Coordinate[] sto
4647 var deduplicator = new Deduplicator ();
4748 var siteRepository = new SiteRepository ();
4849 Graph graph = new Graph (deduplicator );
50+ var vertexFactory = new VertexFactory (graph );
51+
4952 var timetableRepository = new TimetableRepository (siteRepository , deduplicator );
5053 ArrayList <IntersectionVertex > vertices = new ArrayList <>();
5154 Coordinate [] closedGeom = new Coordinate [platform .length + 1 ];
5255
5356 for (int i = 0 ; i < platform .length ; i ++) {
5457 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 );
5759 vertices .add (vertex );
5860 closedGeom [i ] = c ;
5961 }
@@ -109,8 +111,7 @@ private Graph prepareTest(Coordinate[] platform, int[] visible, Coordinate[] sto
109111 graph .index (timetableRepository .getSiteRepository ());
110112
111113 for (RegularStop s : transitStops ) {
112- var v = TransitStopVertex .of ().withStop (s ).build ();
113- graph .addVertex (v );
114+ vertexFactory .transitStop (TransitStopVertex .of ().withStop (s ));
114115 }
115116
116117 return graph ;
@@ -212,6 +213,43 @@ void testLinkStopNearPlatformVertex() {
212213 assertEquals (10 , graph .getEdges ().size ());
213214 }
214215
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+
215253 /**
216254 * Link a stop which is inside an area and very close to its edge.
217255 * Linking snaps directly to the edge without short connecting edges
0 commit comments