Skip to content

Commit

Permalink
Make OSM type names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Oct 9, 2024
1 parent 8ffcc55 commit 1113c07
Show file tree
Hide file tree
Showing 76 changed files with 586 additions and 594 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.opentripplanner.framework.tostring.ToStringBuilder;
import org.opentripplanner.model.calendar.openinghours.OHCalendar;
import org.opentripplanner.model.calendar.openinghours.OpeningHoursCalendarService;
import org.opentripplanner.openstreetmap.OSMOpeningHoursParser;
import org.opentripplanner.openstreetmap.OsmOpeningHoursParser;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
Expand All @@ -36,7 +36,7 @@ abstract class ParkAPIUpdater extends GenericJsonDataSource<VehicleParking> {
private final String feedId;
private final Collection<String> staticTags;

private final OSMOpeningHoursParser osmOpeningHoursParser;
private final OsmOpeningHoursParser osmOpeningHoursParser;
private final String url;

public ParkAPIUpdater(
Expand All @@ -47,7 +47,7 @@ public ParkAPIUpdater(
this.feedId = parameters.feedId();
this.staticTags = parameters.tags();
this.osmOpeningHoursParser =
new OSMOpeningHoursParser(openingHoursCalendarService, parameters.timeZone());
new OsmOpeningHoursParser(openingHoursCalendarService, parameters.timeZone());
this.url = parameters.url();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import org.locationtech.jts.geom.Geometry;
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.openstreetmap.model.OSMNode;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmNode;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

public record DisconnectedOsmNode(OSMNode node, OSMWithTags way, OSMWithTags area)
public record DisconnectedOsmNode(OsmNode node, OsmWithTags way, OsmWithTags area)
implements DataImportIssue {
private static final String FMT = "Node %s in way %s is coincident but disconnected with area %s";
private static final String HTMLFMT =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.opentripplanner.graph_builder.issues;

import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

public record InvalidOsmGeometry(OSMWithTags entity) implements DataImportIssue {
public record InvalidOsmGeometry(OsmWithTags entity) implements DataImportIssue {
private static final String FMT = "Invalid OSM geometry %s";
private static final String HTMLFMT = "Invalid OSM geometry <a href='%s'>'%s'</a>";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.opentripplanner.graph_builder.issues;

import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

public record InvalidVehicleParkingCapacity(OSMWithTags entity, String capacityValue)
public record InvalidVehicleParkingCapacity(OsmWithTags entity, String capacityValue)
implements DataImportIssue {
private static final String FMT =
"Capacity for osm node %d is not a number: '%s'; it's replaced with '-1' (unknown).";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.opentripplanner.graph_builder.issues;

import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

public record LevelAmbiguous(String layerName, OSMWithTags entity) implements DataImportIssue {
public record LevelAmbiguous(String layerName, OsmWithTags entity) implements DataImportIssue {
private static final String FMT =
"Could not infer floor number for layer called '%s' at %s. " +
"Vertical movement will still be possible, but elevator cost might be incorrect. " +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.opentripplanner.graph_builder.issues;

import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

public record ParkAndRideUnlinked(String name, OSMWithTags entity) implements DataImportIssue {
public record ParkAndRideUnlinked(String name, OsmWithTags entity) implements DataImportIssue {
private static final String FMT =
"Park and ride '%s' (%s) not linked to any streets in OSM; entrance might not be placed correctly.";
private static final String HTMLFMT =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.opentripplanner.graph_builder.issues;

import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

public record TurnRestrictionUnknown(OSMWithTags entity, String tagval) implements DataImportIssue {
public record TurnRestrictionUnknown(OsmWithTags entity, String tagval) implements DataImportIssue {
private static final String FMT = "Invalid turn restriction tag %s in turn restriction %d";
private static final String HTMLFMT = "Invalid turn restriction tag %s in <a href='%s'>'%s'</a>";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.geom.TopologyException;
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.openstreetmap.model.OSMNode;
import org.opentripplanner.openstreetmap.model.OSMWay;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmNode;
import org.opentripplanner.openstreetmap.model.OsmWay;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

/**
* Stores information about an OSM area needed for visibility graph construction. Algorithm based on
Expand All @@ -25,14 +25,14 @@ class Area {

final List<Ring> outermostRings;
// This is the way or relation that has the relevant tags for the area
final OSMWithTags parent;
final OsmWithTags parent;
public MultiPolygon jtsMultiPolygon;

Area(
OSMWithTags parent,
List<OSMWay> outerRingWays,
List<OSMWay> innerRingWays,
TLongObjectMap<OSMNode> nodes
OsmWithTags parent,
List<OsmWay> outerRingWays,
List<OsmWay> innerRingWays,
TLongObjectMap<OsmNode> nodes
) {
this.parent = parent;
// ring assignment
Expand Down Expand Up @@ -84,16 +84,16 @@ class Area {
jtsMultiPolygon = calculateJTSMultiPolygon();
}

public List<TLongList> constructRings(List<OSMWay> ways) {
public List<TLongList> constructRings(List<OsmWay> ways) {
if (ways.size() == 0) {
// no rings is no rings
return Collections.emptyList();
}

List<TLongList> closedRings = new ArrayList<>();

ArrayListMultimap<Long, OSMWay> waysByEndpoint = ArrayListMultimap.create();
for (OSMWay way : ways) {
ArrayListMultimap<Long, OsmWay> waysByEndpoint = ArrayListMultimap.create();
for (OsmWay way : ways) {
TLongList refs = way.getNodeRefs();

long start = refs.get(0);
Expand All @@ -110,7 +110,7 @@ public List<TLongList> constructRings(List<OSMWay> ways) {
// Precheck for impossible situations, and remove those.
TLongList endpointsToRemove = new TLongArrayList();
for (Long endpoint : waysByEndpoint.keySet()) {
Collection<OSMWay> list = waysByEndpoint.get(endpoint);
Collection<OsmWay> list = waysByEndpoint.get(endpoint);
if (list.size() % 2 == 1) {
endpointsToRemove.add(endpoint);
}
Expand All @@ -126,9 +126,9 @@ public List<TLongList> constructRings(List<OSMWay> ways) {
}

long firstEndpoint = 0, otherEndpoint = 0;
OSMWay firstWay = null;
OsmWay firstWay = null;
for (Long endpoint : waysByEndpoint.keySet()) {
List<OSMWay> list = waysByEndpoint.get(endpoint);
List<OsmWay> list = waysByEndpoint.get(endpoint);
firstWay = list.get(0);
TLongList nodeRefs = firstWay.getNodeRefs();
partialRing.addAll(nodeRefs);
Expand Down Expand Up @@ -161,14 +161,14 @@ private MultiPolygon calculateJTSMultiPolygon() {
}

private boolean constructRingsRecursive(
ArrayListMultimap<Long, OSMWay> waysByEndpoint,
ArrayListMultimap<Long, OsmWay> waysByEndpoint,
TLongList ring,
List<TLongList> closedRings,
long endpoint
) {
List<OSMWay> ways = new ArrayList<>(waysByEndpoint.get(endpoint));
List<OsmWay> ways = new ArrayList<>(waysByEndpoint.get(endpoint));

for (OSMWay way : ways) {
for (OsmWay way : ways) {
// remove this way from the map
TLongList nodeRefs = way.getNodeRefs();
long firstEndpoint = nodeRefs.get(0);
Expand Down Expand Up @@ -200,9 +200,9 @@ private boolean constructRingsRecursive(

// otherwise, we need to start a new partial ring
newRing = new TLongArrayList();
OSMWay firstWay = null;
OsmWay firstWay = null;
for (Long entry : waysByEndpoint.keySet()) {
List<OSMWay> list = waysByEndpoint.get(entry);
List<OsmWay> list = waysByEndpoint.get(entry);
firstWay = list.get(0);
nodeRefs = firstWay.getNodeRefs();
newRing.addAll(nodeRefs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.graph_builder.module.osm.Ring.RingConstructionException;
import org.opentripplanner.openstreetmap.model.OSMLevel;
import org.opentripplanner.openstreetmap.model.OSMNode;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmNode;
import org.opentripplanner.openstreetmap.model.OsmWithTags;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -51,15 +51,15 @@ public AreaGroup(Collection<Area> areas) {
List<Polygon> allRings = new ArrayList<>();

// However, JTS will lose the coord<->osmnode mapping, and we will have to reconstruct it.
HashMap<Coordinate, OSMNode> nodeMap = new HashMap<>();
HashMap<Coordinate, OsmNode> nodeMap = new HashMap<>();
for (Area area : areas) {
for (Ring ring : area.outermostRings) {
allRings.add(ring.jtsPolygon);
for (OSMNode node : ring.nodes) {
for (OsmNode node : ring.nodes) {
nodeMap.put(new Coordinate(node.lon, node.lat), node);
}
for (Ring inner : ring.getHoles()) {
for (OSMNode node : inner.nodes) {
for (OsmNode node : inner.nodes) {
nodeMap.put(new Coordinate(node.lon, node.lat), node);
}
}
Expand Down Expand Up @@ -88,22 +88,22 @@ public AreaGroup(Collection<Area> areas) {

public static List<AreaGroup> groupAreas(Map<Area, OSMLevel> areasLevels) {
DisjointSet<Area> groups = new DisjointSet<>();
Multimap<OSMNode, Area> areasForNode = LinkedListMultimap.create();
Multimap<OsmNode, Area> areasForNode = LinkedListMultimap.create();
for (Area area : areasLevels.keySet()) {
for (Ring ring : area.outermostRings) {
for (Ring inner : ring.getHoles()) {
for (OSMNode node : inner.nodes) {
for (OsmNode node : inner.nodes) {
areasForNode.put(node, area);
}
}
for (OSMNode node : ring.nodes) {
for (OsmNode node : ring.nodes) {
areasForNode.put(node, area);
}
}
}

// areas that can be joined must share nodes and levels
for (OSMNode osmNode : areasForNode.keySet()) {
for (OsmNode osmNode : areasForNode.keySet()) {
for (Area area1 : areasForNode.get(osmNode)) {
OSMLevel level1 = areasLevels.get(area1);
for (Area area2 : areasForNode.get(osmNode)) {
Expand Down Expand Up @@ -133,14 +133,14 @@ public static List<AreaGroup> groupAreas(Map<Area, OSMLevel> areasLevels) {
return out;
}

public OSMWithTags getSomeOSMObject() {
public OsmWithTags getSomeOSMObject() {
return areas.iterator().next().parent;
}

private Ring toRing(Polygon polygon, HashMap<Coordinate, OSMNode> nodeMap) {
List<OSMNode> shell = new ArrayList<>();
private Ring toRing(Polygon polygon, HashMap<Coordinate, OsmNode> nodeMap) {
List<OsmNode> shell = new ArrayList<>();
for (Coordinate coord : polygon.getExteriorRing().getCoordinates()) {
OSMNode node = nodeMap.get(coord);
OsmNode node = nodeMap.get(coord);
if (node == null) {
throw new RingConstructionException();
}
Expand All @@ -150,9 +150,9 @@ private Ring toRing(Polygon polygon, HashMap<Coordinate, OSMNode> nodeMap) {
// now the holes
for (int i = 0; i < polygon.getNumInteriorRing(); ++i) {
LineString interior = polygon.getInteriorRingN(i);
List<OSMNode> hole = new ArrayList<>();
List<OsmNode> hole = new ArrayList<>();
for (Coordinate coord : interior.getCoordinates()) {
OSMNode node = nodeMap.get(coord);
OsmNode node = nodeMap.get(coord);
if (node == null) {
throw new RingConstructionException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.locationtech.jts.geom.Geometry;
import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmWithTags;

public record AreaTooComplicated(AreaGroup areaGroup, int nbNodes, int maxAreaNodes)
implements DataImportIssue {
Expand All @@ -16,7 +16,7 @@ public String getMessage() {

@Override
public String getHTMLMessage() {
OSMWithTags entity = areaGroup.getSomeOSMObject();
OsmWithTags entity = areaGroup.getSomeOSMObject();
return String.format(HTMLFMT, entity.url(), entity.getId(), nbNodes, maxAreaNodes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.graph_builder.issue.api.Issue;
import org.opentripplanner.openstreetmap.model.OSMLevel;
import org.opentripplanner.openstreetmap.model.OSMNode;
import org.opentripplanner.openstreetmap.model.OSMWay;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.model.OsmNode;
import org.opentripplanner.openstreetmap.model.OsmWay;
import org.opentripplanner.openstreetmap.model.OsmWithTags;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.street.model.StreetTraversalPermission;
import org.opentripplanner.street.model.edge.ElevatorAlightEdge;
Expand Down Expand Up @@ -57,7 +57,7 @@ public ElevatorProcessor(
public void buildElevatorEdges(Graph graph) {
/* build elevator edges */
for (Long nodeId : vertexGenerator.multiLevelNodes().keySet()) {
OSMNode node = osmdb.getNode(nodeId);
OsmNode node = osmdb.getNode(nodeId);
// this allows skipping levels, e.g., an elevator that stops
// at floor 0, 2, 3, and 5.
// Converting to an Array allows us to
Expand Down Expand Up @@ -107,10 +107,10 @@ public void buildElevatorEdges(Graph graph) {
} // END elevator edge loop

// Add highway=elevators to graph as elevators
Iterator<OSMWay> elevators = osmdb.getWays().stream().filter(this::isElevatorWay).iterator();
Iterator<OsmWay> elevators = osmdb.getWays().stream().filter(this::isElevatorWay).iterator();

while (elevators.hasNext()) {
OSMWay elevatorWay = elevators.next();
OsmWay elevatorWay = elevators.next();

List<Long> nodes = Arrays
.stream(elevatorWay.getNodeRefs().toArray())
Expand Down Expand Up @@ -206,7 +206,7 @@ private static void createElevatorHopEdges(
}
}

private boolean isElevatorWay(OSMWay way) {
private boolean isElevatorWay(OsmWay way) {
if (!way.isElevator()) {
return false;
}
Expand All @@ -222,7 +222,7 @@ private boolean isElevatorWay(OSMWay way) {
return nodeRefs.get(0) != nodeRefs.get(nodeRefs.size() - 1);
}

private OptionalInt parseDuration(OSMWithTags element) {
private OptionalInt parseDuration(OsmWithTags element) {
return element.getTagAsInt(
"duration",
v ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.opentripplanner.openstreetmap.model.OSMWay;
import org.opentripplanner.openstreetmap.model.OsmWay;
import org.opentripplanner.street.model.edge.EscalatorEdge;
import org.opentripplanner.street.model.vertex.IntersectionVertex;

Expand All @@ -18,7 +18,7 @@ public EscalatorProcessor(Map<Long, IntersectionVertex> intersectionNodes) {
this.intersectionNodes = intersectionNodes;
}

public void buildEscalatorEdge(OSMWay escalatorWay, double length) {
public void buildEscalatorEdge(OsmWay escalatorWay, double length) {
List<Long> nodes = Arrays
.stream(escalatorWay.getNodeRefs().toArray())
.filter(nodeRef ->
Expand Down
Loading

0 comments on commit 1113c07

Please sign in to comment.