-
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.
- Loading branch information
1 parent
cc633fa
commit 3e028ef
Showing
7 changed files
with
160 additions
and
108 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
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
69 changes: 69 additions & 0 deletions
69
...t/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.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,69 @@ | ||
package org.opentripplanner.graph_builder.module.osm.moduletests; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.graph_builder.module.osm.OsmModule; | ||
import org.opentripplanner.graph_builder.module.osm.moduletests._support.TestOsmProvider; | ||
import org.opentripplanner.osm.model.OsmWay; | ||
import org.opentripplanner.osm.wayproperty.specifier.WayTestData; | ||
import org.opentripplanner.routing.graph.Graph; | ||
import org.opentripplanner.service.osminfo.internal.DefaultOsmInfoGraphBuildRepository; | ||
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingRepository; | ||
import org.opentripplanner.transit.model.framework.Deduplicator; | ||
|
||
public class BoardingLocationTest { | ||
|
||
/** | ||
* There is a one-way road which is also marked as a platform in Sky Campus which crashed OSM. | ||
*/ | ||
@Test | ||
void oneWayPlatform() { | ||
var way = WayTestData.platform(); | ||
way.addTag("access", "no"); | ||
way.addTag("motor_vehicle", "permissive"); | ||
way.addTag("oneway", "yes"); | ||
var provider = TestOsmProvider.of().addWay(way).build(); | ||
|
||
var graph = new Graph(new Deduplicator()); | ||
var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); | ||
var osmModule = OsmModule | ||
.of(provider, graph, osmInfoRepository, new DefaultVehicleParkingRepository()) | ||
.withBoardingAreaRefTags(Set.of("ref")) | ||
.build(); | ||
|
||
osmModule.buildGraph(); | ||
var edges = List.copyOf(graph.getEdges()); | ||
assertThat(edges).hasSize(1); | ||
|
||
var platform = osmInfoRepository.findPlatform(edges.getFirst()); | ||
|
||
assertTrue(platform.isPresent()); | ||
assertEquals(Set.of("123"), platform.get().references()); | ||
} | ||
|
||
@Test | ||
void skipPlatformsWithoutReferences() { | ||
var way = new OsmWay(); | ||
way.addTag("public_transport", "platform"); | ||
var provider = TestOsmProvider.of().addWay(way).build(); | ||
|
||
var graph = new Graph(new Deduplicator()); | ||
var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); | ||
var osmModule = OsmModule | ||
.of(provider, graph, osmInfoRepository, new DefaultVehicleParkingRepository()) | ||
.withBoardingAreaRefTags(Set.of("ref")) | ||
.build(); | ||
|
||
osmModule.buildGraph(); | ||
var edges = List.copyOf(graph.getEdges()); | ||
assertThat(edges).hasSize(2); | ||
|
||
var platform = osmInfoRepository.findPlatform(edges.getFirst()); | ||
assertTrue(platform.isEmpty()); | ||
} | ||
} |
102 changes: 0 additions & 102 deletions
102
...src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/OsmModuleTest.java
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
...va/org/opentripplanner/graph_builder/module/osm/moduletests/_support/TestOsmProvider.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,80 @@ | ||
package org.opentripplanner.graph_builder.module.osm.moduletests._support; | ||
|
||
import java.time.ZoneId; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.opentripplanner._support.time.ZoneIds; | ||
import org.opentripplanner.graph_builder.module.osm.OsmDatabase; | ||
import org.opentripplanner.osm.OsmProvider; | ||
import org.opentripplanner.osm.model.OsmNode; | ||
import org.opentripplanner.osm.model.OsmWay; | ||
import org.opentripplanner.osm.tagmapping.OsmTagMapper; | ||
import org.opentripplanner.osm.wayproperty.WayPropertySet; | ||
|
||
public class TestOsmProvider implements OsmProvider { | ||
|
||
private final List<OsmWay> ways; | ||
private final List<OsmNode> nodes; | ||
|
||
public TestOsmProvider(List<OsmWay> ways, List<OsmNode> nodes) { | ||
this.ways = ways.stream().peek(w -> w.setOsmProvider(this)).toList(); | ||
this.nodes = List.copyOf(nodes); | ||
} | ||
|
||
public static Builder of() { | ||
return new Builder(); | ||
} | ||
|
||
@Override | ||
public void readOsm(OsmDatabase osmdb) { | ||
ways.forEach(osmdb::addWay); | ||
|
||
osmdb.doneSecondPhaseWays(); | ||
|
||
nodes.forEach(osmdb::addNode); | ||
} | ||
|
||
@Override | ||
public OsmTagMapper getOsmTagMapper() { | ||
return new OsmTagMapper(); | ||
} | ||
|
||
@Override | ||
public void checkInputs() {} | ||
|
||
@Override | ||
public WayPropertySet getWayPropertySet() { | ||
return new WayPropertySet(); | ||
} | ||
|
||
@Override | ||
public ZoneId getZoneId() { | ||
return ZoneIds.LONDON; | ||
} | ||
|
||
public static class Builder { | ||
|
||
private final List<OsmWay> ways = new ArrayList<>(); | ||
private final List<OsmNode> nodes = new ArrayList<>(); | ||
|
||
public TestOsmProvider build() { | ||
return new TestOsmProvider(ways, nodes); | ||
} | ||
|
||
/** | ||
* Add a way and create nodes for the from and to coordinates. | ||
*/ | ||
public Builder addWay(OsmWay way) { | ||
var from = new OsmNode(1, 1); | ||
from.setId(1); | ||
var to = new OsmNode(1.1, 1.1); | ||
to.setId(2); | ||
way.getNodeRefs().add(from.getId()); | ||
way.getNodeRefs().add(to.getId()); | ||
|
||
ways.add(way); | ||
nodes.addAll(List.of(from, to)); | ||
return this; | ||
} | ||
} | ||
} |
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