Skip to content

Commit

Permalink
Merge pull request #6498 from entur/remove_UUID_in_TempVertex
Browse files Browse the repository at this point in the history
Remove the usage of UUID in TemporaryStreetLocation
  • Loading branch information
t2gran authored Feb 28, 2025
2 parents 7d90276 + 0f6694d commit caf673b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -378,7 +372,6 @@ private Vertex createVertexFromCoordinate(
}

TemporaryStreetLocation temporaryStreetLocation = new TemporaryStreetLocation(
UUID.randomUUID().toString(),
coordinate,
name,
endVertex
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
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;
import org.opentripplanner.street.model.edge.TemporaryEdge;

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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,13 @@ 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
);
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
Expand All @@ -193,15 +191,15 @@ 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());
assertEquals("market_leary", states.get(4).getVertex().getLabelString());
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
Expand All @@ -212,15 +210,13 @@ 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
);
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
Expand All @@ -241,15 +237,15 @@ 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());
assertEquals("market_leary", states.get(4).getVertex().getLabelString());
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ public TemporaryStreetLocation streetLocation(
boolean endVertex
) {
return new TemporaryStreetLocation(
name,
new Coordinate(longitude, latitude),
new NonLocalizedString(name),
endVertex
Expand Down

0 comments on commit caf673b

Please sign in to comment.