From 0f6694d0d3513bd22f2475db7df1bc1c13022f7d Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 27 Feb 2025 18:16:42 +0100 Subject: [PATCH] refactor:Remove the usage of UUID in TemporaryStreetLocation The other temporary vertex, TemporarySplitterVertex, is left as is. This is getting its id(label) from the splitter. --- .../routing/graph/index/StreetIndex.java | 9 +-------- .../street/model/vertex/TemporaryStreetLocation.java | 12 +++++------- .../java/org/opentripplanner/astar/AStarTest.java | 12 ++++-------- .../routing/algorithm/GraphRoutingTest.java | 1 - 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java index b632cd5c3e9..5ad8068a3f0 100644 --- a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java +++ b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.UUID; import java.util.stream.Collectors; import javax.annotation.Nullable; import org.locationtech.jts.geom.Coordinate; @@ -102,12 +101,7 @@ public static TemporaryStreetLocation createTemporaryStreetLocationForTest( ) { boolean wheelchairAccessible = false; - TemporaryStreetLocation location = new TemporaryStreetLocation( - label, - nearestPoint, - name, - endVertex - ); + TemporaryStreetLocation location = new TemporaryStreetLocation(nearestPoint, name, endVertex); for (StreetEdge street : edges) { Vertex fromv = street.getFromVertex(); @@ -378,7 +372,6 @@ private Vertex createVertexFromCoordinate( } TemporaryStreetLocation temporaryStreetLocation = new TemporaryStreetLocation( - UUID.randomUUID().toString(), coordinate, name, endVertex diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java index 8af9474a7e7..0135c36dda2 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java @@ -1,5 +1,6 @@ package org.opentripplanner.street.model.vertex; +import java.util.concurrent.atomic.AtomicLong; import org.locationtech.jts.geom.Coordinate; import org.opentripplanner.framework.i18n.I18NString; import org.opentripplanner.street.model.edge.Edge; @@ -7,15 +8,12 @@ public final class TemporaryStreetLocation extends StreetLocation implements TemporaryVertex { + private static final AtomicLong idCounter = new AtomicLong(0); + private final boolean endVertex; - public TemporaryStreetLocation( - String id, - Coordinate nearestPoint, - I18NString name, - boolean endVertex - ) { - super(id, nearestPoint, name); + public TemporaryStreetLocation(Coordinate nearestPoint, I18NString name, boolean endVertex) { + super("TempVertex-" + idCounter.incrementAndGet(), nearestPoint, name); this.endVertex = endVertex; } diff --git a/application/src/test/java/org/opentripplanner/astar/AStarTest.java b/application/src/test/java/org/opentripplanner/astar/AStarTest.java index 40310fedb7b..79b995ebffa 100644 --- a/application/src/test/java/org/opentripplanner/astar/AStarTest.java +++ b/application/src/test/java/org/opentripplanner/astar/AStarTest.java @@ -164,7 +164,6 @@ public void testForwardExtraEdges() { request.withPreferences(pref -> pref.withWalk(w -> w.withSpeed(1.0))); TemporaryStreetLocation from = new TemporaryStreetLocation( - "near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), new NonLocalizedString("near_shilshole_22nd"), false @@ -172,7 +171,6 @@ public void testForwardExtraEdges() { TemporaryConcreteEdge.createTemporaryConcreteEdge(from, graph.getVertex("shilshole_22nd")); TemporaryStreetLocation to = new TemporaryStreetLocation( - "near_56th_20th", new Coordinate(-122.382347, 47.669518), new NonLocalizedString("near_56th_20th"), true @@ -193,7 +191,7 @@ public void testForwardExtraEdges() { assertEquals(9, states.size()); - assertEquals("near_shilshole_22nd", states.get(0).getVertex().getLabelString()); + assertEquals("near_shilshole_22nd", states.get(0).getVertex().getDefaultName()); assertEquals("shilshole_22nd", states.get(1).getVertex().getLabelString()); assertEquals("ballard_22nd", states.get(2).getVertex().getLabelString()); assertEquals("market_22nd", states.get(3).getVertex().getLabelString()); @@ -201,7 +199,7 @@ public void testForwardExtraEdges() { assertEquals("market_russell", states.get(5).getVertex().getLabelString()); assertEquals("market_20th", states.get(6).getVertex().getLabelString()); assertEquals("56th_20th", states.get(7).getVertex().getLabelString()); - assertEquals("near_56th_20th", states.get(8).getVertex().getLabelString()); + assertEquals("near_56th_20th", states.get(8).getVertex().getDefaultName()); } @Test @@ -212,7 +210,6 @@ public void testBackExtraEdges() { request.setArriveBy(true); TemporaryStreetLocation from = new TemporaryStreetLocation( - "near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), new NonLocalizedString("near_shilshole_22nd"), false @@ -220,7 +217,6 @@ public void testBackExtraEdges() { TemporaryConcreteEdge.createTemporaryConcreteEdge(from, graph.getVertex("shilshole_22nd")); TemporaryStreetLocation to = new TemporaryStreetLocation( - "near_56th_20th", new Coordinate(-122.382347, 47.669518), new NonLocalizedString("near_56th_20th"), true @@ -241,7 +237,7 @@ public void testBackExtraEdges() { assertEquals(9, states.size()); - assertEquals("near_shilshole_22nd", states.get(0).getVertex().getLabelString()); + assertEquals("near_shilshole_22nd", states.get(0).getVertex().getDefaultName()); assertEquals("shilshole_22nd", states.get(1).getVertex().getLabelString()); assertEquals("ballard_22nd", states.get(2).getVertex().getLabelString()); assertEquals("market_22nd", states.get(3).getVertex().getLabelString()); @@ -249,7 +245,7 @@ public void testBackExtraEdges() { assertEquals("market_russell", states.get(5).getVertex().getLabelString()); assertEquals("market_20th", states.get(6).getVertex().getLabelString()); assertEquals("56th_20th", states.get(7).getVertex().getLabelString()); - assertEquals("near_56th_20th", states.get(8).getVertex().getLabelString()); + assertEquals("near_56th_20th", states.get(8).getVertex().getDefaultName()); } @Test diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java index e283e4e9fa8..6fc6fe68919 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java @@ -360,7 +360,6 @@ public TemporaryStreetLocation streetLocation( boolean endVertex ) { return new TemporaryStreetLocation( - name, new Coordinate(longitude, latitude), new NonLocalizedString(name), endVertex