-
Couldn't load subscription status.
- Fork 1.1k
Crosswalk naming #6918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
VillePihlava
merged 50 commits into
opentripplanner:dev-2.x
from
ibi-group:crosswalk-naming
Oct 23, 2025
Merged
Crosswalk naming #6918
Changes from 45 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
e11409d
feat(OsmWay): Add helper methods.
binh-dam-ibigroup 28b188f
feat(CrosswalkNamer): Add class for crosswalk namer w/ cross street l…
binh-dam-ibigroup 38f5e11
refactor(OsmWay): Remove redundant transit platform logic.
binh-dam-ibigroup 6b83df3
test(CrosswalkNamer): Make test OSM ways static.
binh-dam-ibigroup 21e3289
feat(CrosswalkNamer): Implement basic crosswalk naming.
binh-dam-ibigroup a4689cb
refactor(CrosswalkNamer): Extract turn lane condition.
binh-dam-ibigroup 989f7c2
test(CrosswalkNamer): Support service roads and turn lanes.
binh-dam-ibigroup 1daa299
docs(CrosswalkNamer): Update class JavaDoc.
binh-dam-ibigroup aeb0547
style: Apply Prettier.
binh-dam-ibigroup 38f0060
Merge branch 'dev-2.x' into crosswalk-naming
binh-dam-ibigroup 347e72d
feat(SidewalkCrosswalkNamer): Add sidewalk_crosswalk option to osmNam…
binh-dam-ibigroup cb6e68e
fix(OsmWay): Relax criteria for crossings.
binh-dam-ibigroup 1acf57c
fix(StatesToWalkStepsMapper): Make new instruction for crossing follo…
binh-dam-ibigroup b52cedb
style: Apply prettier.
binh-dam-ibigroup 602cb89
perf(CrosswwalkNamer): Use geo buffer to limit candidate intersecting…
binh-dam-ibigroup f5003d0
feat(CrosswwalkNamer): Rename single sidewalk on either side of cross…
binh-dam-ibigroup 9560214
Merge branch 'dev-2.x' into crosswalk-naming
binh-dam-ibigroup fb5bc8e
docs(BuildCondfiguration): Update build docs.
binh-dam-ibigroup 109f15d
test(StatesToWalkStepsMapper): Remove null edge cases.
binh-dam-ibigroup c760b69
refactor: Extract NamerWithGeoBuffer.
binh-dam-ibigroup e03a998
refactor(NamerWithGeoBuffer): Extract addToSpatialIndex.
binh-dam-ibigroup 146fbb8
refactor(NamerWithGeoBuffer): Inline method and tweak JavaDoc.
binh-dam-ibigroup 3cb0082
test(NamerTestUtils): Extract edgeBuilder method.
binh-dam-ibigroup 2027866
test(CrosswalkNamer): Fix null flag.
binh-dam-ibigroup dc99a18
test(SidewalkNamer): Fix typo.
binh-dam-ibigroup 3492317
refactor(SidewalkNamer): Require OsmWay.
binh-dam-ibigroup 1f2d8f2
style: Apply prettier.
binh-dam-ibigroup 7cd0ec3
Merge branch 'dev-2.x' into crosswalk-naming
binh-dam-ibigroup c75f928
test(OsmWay): Reuse WayTestData code.
binh-dam-ibigroup e6351db
test(OsmWay): Rename createFootway to createCrossing.
binh-dam-ibigroup 31a9e64
test(OsmWay): Apply prettier.
binh-dam-ibigroup 340b5fc
feat(StreetEdge): Add a crossing flag.
binh-dam-ibigroup 3c92825
docs(StatesToWalkStepsMapper): Add isSameStreet JavaDoc.
binh-dam-ibigroup cf97687
fix(StatesToWalkStepsMapper): Evaluate crossings if they don't use de…
binh-dam-ibigroup 615e303
refactor(StreetEdgeIndex): Extract spatial index helper/wrapper.
binh-dam-ibigroup 5fd15af
refactor(StreetEdgeIndex): Move PreciseBuffer and EdgeOnLevel to pack…
binh-dam-ibigroup 320ee6d
refactor(PreciseBuffer): Rename to PreciseBufferFactory.
binh-dam-ibigroup df13ef6
refactor: Remove inheritance from SideWalkNamer and CrosswalkNamer.
binh-dam-ibigroup 93f81ab
refactor(EdgeNamer): Rename postprocess to finalizeNames.
binh-dam-ibigroup 555c188
Use fewer static methods
leonardehrenfried 685adfd
Merge branch 'dev-2.x' into crosswalk-naming, resolve conflicts
binh-dam-ibigroup fce3f0c
refactor(CrosswalkNamer): Remove use of level sets.
binh-dam-ibigroup ba3c149
refactor(OsmWay): Add isTurnLane method.
binh-dam-ibigroup 241a85a
refactor(StreetEdgeBuilderFactory): Rename test class, reuse in Sidew…
binh-dam-ibigroup f5b2081
feat(CrosswalkNamer): Add freeway ramp as crossing type.
binh-dam-ibigroup 954cf59
refactor(CrosswalkNamer): Implement i18n.
binh-dam-ibigroup bd8de75
Merge branch 'dev-2.x' into crosswalk-naming
binh-dam-ibigroup 3072289
chore(WayProperties): Tweak French text
binh-dam-ibigroup 334a0cd
refactor(CrosswalkNamer): Change remaining 'crossing' to 'crosswalk'.
binh-dam-ibigroup 7d52252
style(CrosswalkNamer): Apply prettier.
binh-dam-ibigroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...n/src/main/java/org/opentripplanner/graph_builder/module/osm/naming/AssignNameToEdge.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package org.opentripplanner.graph_builder.module.osm.naming; | ||
|
|
||
| import org.locationtech.jts.geom.Geometry; | ||
|
|
||
| /** | ||
| * Helper interface with method to assign a name to an edge. | ||
| */ | ||
| @FunctionalInterface | ||
| interface AssignNameToEdge { | ||
| boolean assignNameToEdge(EdgeOnLevel crosswalkOnLevel, Geometry buffer); | ||
| } |
75 changes: 75 additions & 0 deletions
75
.../main/java/org/opentripplanner/graph_builder/module/osm/naming/BufferedEdgeProcessor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package org.opentripplanner.graph_builder.module.osm.naming; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
| import org.locationtech.jts.geom.Coordinate; | ||
| import org.locationtech.jts.geom.Envelope; | ||
| import org.opentripplanner.utils.lang.DoubleUtils; | ||
| import org.opentripplanner.utils.logging.ProgressTracker; | ||
| import org.slf4j.Logger; | ||
|
|
||
| /** | ||
| * Base class for namers that use a geo buffer to query geo features. | ||
| */ | ||
| class BufferedEdgeProcessor { | ||
|
|
||
| private final String type; | ||
| private final Logger logger; | ||
| private final int bufferMeters; | ||
| private final AssignNameToEdge assigner; | ||
|
|
||
| BufferedEdgeProcessor(int bufferMeters, String type, Logger logger, AssignNameToEdge assigner) { | ||
| this.type = type; | ||
| this.logger = logger; | ||
| this.bufferMeters = bufferMeters; | ||
| this.assigner = assigner; | ||
| } | ||
|
|
||
| public void applyNames(Collection<EdgeOnLevel> unnamedEdges) { | ||
| ProgressTracker progress = ProgressTracker.track( | ||
| String.format("Assigning names to %s", type), | ||
| 500, | ||
| unnamedEdges.size() | ||
| ); | ||
| PreciseBufferFactory preciseBufferFactory = new PreciseBufferFactory( | ||
| computeEnvelopeCenter(unnamedEdges), | ||
| bufferMeters | ||
| ); | ||
|
|
||
| final AtomicInteger namesApplied = new AtomicInteger(0); | ||
| unnamedEdges | ||
| .parallelStream() | ||
| .forEach(edgeOnLevel -> { | ||
| var buffer = preciseBufferFactory.preciseBuffer(edgeOnLevel.edge().getGeometry()); | ||
| if (assigner.assignNameToEdge(edgeOnLevel, buffer)) { | ||
| namesApplied.incrementAndGet(); | ||
| } | ||
|
|
||
| // Keep lambda! A method-ref would cause incorrect class and line number to be logged | ||
| // noinspection Convert2MethodRef | ||
| progress.step(m -> logger.info(m)); | ||
| }); | ||
|
|
||
| logger.info( | ||
| "Assigned names to {} of {} {} ({}%)", | ||
| namesApplied.get(), | ||
| unnamedEdges.size(), | ||
| type, | ||
| DoubleUtils.roundTo2Decimals(((double) namesApplied.get() / unnamedEdges.size()) * 100) | ||
| ); | ||
|
|
||
| logger.info(progress.completeMessage()); | ||
| } | ||
|
|
||
| /** | ||
| * Compute the centroid of all sidewalk edges. | ||
| */ | ||
| private static Coordinate computeEnvelopeCenter(Collection<EdgeOnLevel> edges) { | ||
| var envelope = new Envelope(); | ||
| edges.forEach(e -> { | ||
| envelope.expandToInclude(e.edge().getFromVertex().getCoordinate()); | ||
| envelope.expandToInclude(e.edge().getToVertex().getCoordinate()); | ||
| }); | ||
| return envelope.centre(); | ||
| } | ||
| } |
171 changes: 171 additions & 0 deletions
171
...ion/src/main/java/org/opentripplanner/graph_builder/module/osm/naming/CrosswalkNamer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| package org.opentripplanner.graph_builder.module.osm.naming; | ||
|
|
||
| import gnu.trove.list.TLongList; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.Set; | ||
| import org.locationtech.jts.geom.Geometry; | ||
| import org.opentripplanner.framework.i18n.I18NString; | ||
| import org.opentripplanner.graph_builder.module.osm.OsmDatabase; | ||
| import org.opentripplanner.graph_builder.module.osm.StreetEdgePair; | ||
| import org.opentripplanner.graph_builder.services.osm.EdgeNamer; | ||
| import org.opentripplanner.osm.model.OsmEntity; | ||
| import org.opentripplanner.osm.model.OsmWay; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * A namer that assigns names to crosswalks using the name or type of the crossed street. | ||
| * <p> | ||
| * The algorithm works as follows: | ||
| * - For each crosswalk, we find the intersecting street edge that shares a node. | ||
| * - Apply a name depending on the type of street: | ||
| * * For named streets, name the crossing so it reads "crossing over 10th Street". | ||
| * * For service roads (e.g. car access to commercial complexes, such as | ||
| * <a href="https://www.openstreetmap.org/way/1024601318">...</a>), | ||
| * use "crossing over service road". | ||
| * * For turn lanes or slip lanes at intersections (shortcuts from a street to another, | ||
| * to bypass traffic signals, prevalent in North America, | ||
| * e.g. <a href="https://www.openstreetmap.org/way/1139062913">...</a>), | ||
| * use "crossing over turn lane". | ||
| */ | ||
| public class CrosswalkNamer implements EdgeNamer { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(CrosswalkNamer.class); | ||
| private static final int BUFFER_METERS = 25; | ||
| private final BufferedEdgeProcessor processor; //= | ||
|
|
||
| private StreetEdgeIndex streetIndex = new StreetEdgeIndex(); | ||
| private StreetEdgeIndex sidewalkIndex = new StreetEdgeIndex(); | ||
| private Collection<EdgeOnLevel> unnamedCrosswalks = new ArrayList<>(); | ||
|
|
||
| public CrosswalkNamer() { | ||
| processor = new BufferedEdgeProcessor(BUFFER_METERS, "crosswalks", LOG, this::assignNameToEdge); | ||
| } | ||
|
|
||
| @Override | ||
| public I18NString name(OsmEntity way) { | ||
| return way.getAssumedName(); | ||
| } | ||
|
|
||
| @Override | ||
| public void recordEdges(OsmEntity way, StreetEdgePair pair, OsmDatabase osmdb) { | ||
| if (way instanceof OsmWay osmWay) { | ||
VillePihlava marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Record unnamed crossings to a list. | ||
| if (osmWay.isCrossing() && way.hasNoName() && !way.isExplicitlyUnnamed()) { | ||
| pair | ||
| .asIterable() | ||
| .forEach(edge -> unnamedCrosswalks.add(new EdgeOnLevel(osmWay, edge, Set.of()))); | ||
| } | ||
| // Record (short) sidewalks to a geometric index | ||
| else if (way.isSidewalk()) { | ||
| sidewalkIndex.add(way, pair, Set.of(), BUFFER_METERS); | ||
| } | ||
| // Record named streets, service roads, and slip/turn lanes to a geometric index. | ||
| else if ( | ||
| !osmWay.isFootway() && (way.isNamed() || osmWay.isServiceRoad() || osmWay.isTurnLane()) | ||
| ) { | ||
| streetIndex.add(way, pair, Set.of()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void finalizeNames() { | ||
| processor.applyNames(unnamedCrosswalks); | ||
|
|
||
| // Set the indices to null so they can be garbage-collected | ||
| streetIndex = null; | ||
| sidewalkIndex = null; | ||
| unnamedCrosswalks = null; | ||
| } | ||
|
|
||
| /** | ||
| * The actual logic for naming individual crosswalk edges. | ||
| * This will also name adjacent sidewalks on each end if they are the only adjacent sidewalks to a crosswalk. | ||
| */ | ||
| public boolean assignNameToEdge(EdgeOnLevel crosswalkOnLevel, Geometry buffer) { | ||
| var crosswalk = crosswalkOnLevel.edge(); | ||
| OsmWay way = crosswalkOnLevel.way(); | ||
|
|
||
| var streetCandidates = streetIndex.query(buffer).stream().map(EdgeOnLevel::way).toList(); | ||
|
|
||
| var crossStreetOpt = getIntersectingStreet(way, streetCandidates); | ||
| if (crossStreetOpt.isPresent()) { | ||
| OsmWay crossStreet = crossStreetOpt.get(); | ||
| // TODO: i18n | ||
| if (crossStreet.isNamed()) { | ||
| crosswalk.setName( | ||
| I18NString.of(String.format("crossing over %s", crossStreet.getAssumedName())) | ||
| ); | ||
| } else if (crossStreet.isServiceRoad()) { | ||
| crosswalk.setName(I18NString.of("crossing over service road")); | ||
| } else if (crossStreet.isMotorwayRamp()) { | ||
| crosswalk.setName(I18NString.of("crossing over freeway ramp")); | ||
| } else if (crossStreet.isTurnLane()) { | ||
| crosswalk.setName(I18NString.of("crossing over turn lane")); | ||
| } else { | ||
| // Default on using the OSM way ID, which should not happen. | ||
| crosswalk.setName(I18NString.of(String.format("crossing %s", way.getId()))); | ||
| } | ||
|
|
||
| var adjacentSidewalks = sidewalkIndex | ||
| .query(buffer) | ||
| .stream() | ||
| .filter(e -> e.way().isAdjacentTo(way)) | ||
| .filter(e -> e.edge().nameIsDerived()) | ||
| .toList(); | ||
|
|
||
| // Group sidewalks at each end of the crosswalk. | ||
| TLongList nodes = way.getNodeRefs(); | ||
| renameAdjacentSidewalk(adjacentSidewalks, crosswalk.getName(), nodes.get(0)); | ||
| renameAdjacentSidewalk(adjacentSidewalks, crosswalk.getName(), nodes.get(nodes.size() - 1)); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Rename a sidewalk, among candidates, if it is the only adjacent sidewalk to the given crosswalk. | ||
| */ | ||
| private void renameAdjacentSidewalk( | ||
| List<EdgeOnLevel> adjacentSidewalks, | ||
| I18NString crosswalkName, | ||
| long nodeId | ||
| ) { | ||
| List<EdgeOnLevel> sidewalks = adjacentSidewalks | ||
| .stream() | ||
| .filter(e -> e.way().getNodeRefs().contains(nodeId)) | ||
| .toList(); | ||
| if (sidewalks.size() == 1) { | ||
| sidewalks.getFirst().edge().setName(crosswalkName); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the intersecting street, if any, for the given way and candidate streets. | ||
| */ | ||
| public static Optional<OsmWay> getIntersectingStreet(OsmWay way, Collection<OsmWay> streets) { | ||
| TLongList nodeRefs = way.getNodeRefs(); | ||
| if (nodeRefs.size() >= 3) { | ||
| // There needs to be at least three nodes: 2 extremities that are on the sidewalk, | ||
| // and one somewhere in the middle that joins the crossing with the street. | ||
| // We exclude the first and last node which are on the sidewalk. | ||
| long[] nodeRefsArray = nodeRefs.toArray(1, nodeRefs.size() - 2); | ||
| return streets | ||
| .stream() | ||
| .filter(w -> Arrays.stream(nodeRefsArray).anyMatch(nid -> w.getNodeRefs().contains(nid))) | ||
| .findFirst(); | ||
| } | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| Collection<EdgeOnLevel> getUnnamedCrosswalks() { | ||
| return unnamedCrosswalks; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...cation/src/main/java/org/opentripplanner/graph_builder/module/osm/naming/EdgeOnLevel.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package org.opentripplanner.graph_builder.module.osm.naming; | ||
|
|
||
| import java.util.Set; | ||
| import org.opentripplanner.osm.model.OsmLevel; | ||
| import org.opentripplanner.osm.model.OsmWay; | ||
| import org.opentripplanner.street.model.edge.StreetEdge; | ||
|
|
||
| public record EdgeOnLevel(OsmWay way, StreetEdge edge, Set<OsmLevel> levels) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...c/main/java/org/opentripplanner/graph_builder/module/osm/naming/PreciseBufferFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package org.opentripplanner.graph_builder.module.osm.naming; | ||
|
|
||
| import org.geotools.api.referencing.FactoryException; | ||
| import org.geotools.api.referencing.crs.CoordinateReferenceSystem; | ||
| import org.geotools.api.referencing.operation.MathTransform; | ||
| import org.geotools.api.referencing.operation.TransformException; | ||
| import org.geotools.geometry.jts.JTS; | ||
| import org.geotools.referencing.CRS; | ||
| import org.geotools.referencing.crs.DefaultGeographicCRS; | ||
| import org.locationtech.jts.geom.Coordinate; | ||
| import org.locationtech.jts.geom.Geometry; | ||
| import org.locationtech.jts.operation.buffer.BufferParameters; | ||
|
|
||
| /** | ||
| * A class to cache the expensive construction of a Universal Traverse Mercator coordinate reference | ||
| * system. Re-using the same CRS for all edges might introduce tiny imprecisions for OTPs use cases | ||
| * but speeds up the processing enormously and is a price well worth paying. | ||
| */ | ||
| final class PreciseBufferFactory { | ||
|
|
||
| private final double distanceInMeters; | ||
| private final MathTransform toTransform; | ||
| private final MathTransform fromTransform; | ||
|
|
||
| PreciseBufferFactory(Coordinate coordinate, double distanceInMeters) { | ||
| this.distanceInMeters = distanceInMeters; | ||
| String code = "AUTO:42001,%s,%s".formatted(coordinate.x, coordinate.y); | ||
| try { | ||
| CoordinateReferenceSystem auto = CRS.decode(code); | ||
| this.toTransform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto); | ||
| this.fromTransform = CRS.findMathTransform(auto, DefaultGeographicCRS.WGS84); | ||
| } catch (FactoryException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Add a buffer around a geometry that makes sure that the buffer is the same distance (in meters) | ||
| * anywhere on earth. | ||
| * <p> | ||
| * Background: If you call the regular buffer() method on a JTS geometry that uses WGS84 as the | ||
| * coordinate reference system, the buffer will be accurate at the equator but will become more | ||
| * and more elongated the farther north/south you go. | ||
| * <p> | ||
| * Taken from https://stackoverflow.com/questions/36455020 | ||
| */ | ||
| Geometry preciseBuffer(Geometry geometry) { | ||
| try { | ||
| Geometry pGeom = JTS.transform(geometry, toTransform); | ||
| Geometry pBufferedGeom = pGeom.buffer(distanceInMeters, 4, BufferParameters.CAP_FLAT); | ||
| return JTS.transform(pBufferedGeom, fromTransform); | ||
| } catch (TransformException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
...main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkCrosswalkNamer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.opentripplanner.graph_builder.module.osm.naming; | ||
|
|
||
| import org.opentripplanner.framework.i18n.I18NString; | ||
| import org.opentripplanner.graph_builder.module.osm.OsmDatabase; | ||
| import org.opentripplanner.graph_builder.module.osm.StreetEdgePair; | ||
| import org.opentripplanner.graph_builder.services.osm.EdgeNamer; | ||
| import org.opentripplanner.osm.model.OsmEntity; | ||
|
|
||
| /** | ||
| * Combines the sidewalk and crosswalk namer. | ||
| */ | ||
| public class SidewalkCrosswalkNamer implements EdgeNamer { | ||
|
|
||
| private final SidewalkNamer sidewalkNamer = new SidewalkNamer(); | ||
| private final CrosswalkNamer crosswalkNamer = new CrosswalkNamer(); | ||
|
|
||
| @Override | ||
| public I18NString name(OsmEntity way) { | ||
| return way.getAssumedName(); | ||
| } | ||
|
|
||
| @Override | ||
| public void recordEdges(OsmEntity way, StreetEdgePair pair, OsmDatabase osmdb) { | ||
| sidewalkNamer.recordEdges(way, pair, osmdb); | ||
| crosswalkNamer.recordEdges(way, pair, osmdb); | ||
| } | ||
|
|
||
| @Override | ||
| public void finalizeNames() { | ||
| sidewalkNamer.finalizeNames(); | ||
| crosswalkNamer.finalizeNames(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is really a way, we should use the
OsmWaytype. If it has to be anOsmEntitythere might be a logic error somewhere because relations and nodes can also be given as parameter in theory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also personally prefer
OsmWayand I also got confused because a lot of way/edge code is inOsmEntity. Does aStreetEdgealways come from anOsmWay? Happy to discuss how to proceed in an upcoming call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think another option is to maybe do it in a separate PR. Lets discuss in Thursday's meeting to decide how to proceed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a PR for this: #6989. It changes the type from
OsmEntitytoOsmWayinrecordEdges. Would you like to merge this first, or my PR first?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whichever one is ready first!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets merge this one first