-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always record edges in pairs in the custom namer
- Loading branch information
1 parent
17279ba
commit 1d749c3
Showing
8 changed files
with
85 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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
35 changes: 35 additions & 0 deletions
35
src/main/java/org/opentripplanner/graph_builder/module/osm/StreetEdgePair.java
This file contains 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,35 @@ | ||
package org.opentripplanner.graph_builder.module.osm; | ||
|
||
import java.util.ArrayList; | ||
import org.opentripplanner.street.model.edge.StreetEdge; | ||
|
||
public record StreetEdgePair(StreetEdge main, StreetEdge back) { | ||
/** | ||
* Return the non-null elements of this pair as an Iterable. | ||
*/ | ||
public Iterable<StreetEdge> asIterable() { | ||
var ret = new ArrayList<StreetEdge>(2); | ||
if (main != null) { | ||
ret.add(main); | ||
} | ||
if (back != null) { | ||
ret.add(back); | ||
} | ||
return ret; | ||
} | ||
|
||
/** | ||
* Select one of the edges contained in this pair that is not null. No particular algorithm is | ||
* guaranteed, and it may change in the future. | ||
*/ | ||
public StreetEdge pickAny() { | ||
if (main != null) { | ||
return main; | ||
} else if (back != null) { | ||
return back; | ||
} | ||
throw new IllegalStateException( | ||
"%s must not contain two null elements".formatted(getClass().getSimpleName()) | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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