Skip to content
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

Make OSM type names consistent #6131

Merged
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.osm.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.osm.model.OsmNode;
import org.opentripplanner.osm.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.osm.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.osm.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.osm.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.osm.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.osm.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 @@ -40,7 +40,7 @@
import org.opentripplanner.gtfs.graphbuilder.GtfsModule;
import org.opentripplanner.netex.NetexModule;
import org.opentripplanner.netex.configure.NetexConfigure;
import org.opentripplanner.openstreetmap.OsmProvider;
import org.opentripplanner.osm.OsmProvider;
import org.opentripplanner.routing.api.request.preference.WalkPreferences;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.standalone.config.BuildConfig;
Expand All @@ -55,7 +55,7 @@ public class GraphBuilderModules {

@Provides
@Singleton
static OsmModule provideOpenStreetMapModule(
static OsmModule provideOsmModule(
GraphBuilderDataSources dataSources,
BuildConfig config,
Graph graph,
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.osm.model.OsmNode;
import org.opentripplanner.osm.model.OsmWay;
import org.opentripplanner.osm.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 @@ -17,9 +17,9 @@
import org.locationtech.jts.geom.Polygon;
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.osm.model.OsmLevel;
import org.opentripplanner.osm.model.OsmNode;
import org.opentripplanner.osm.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 All @@ -86,28 +86,28 @@ public AreaGroup(Collection<Area> areas) {
}
}

public static List<AreaGroup> groupAreas(Map<Area, OSMLevel> areasLevels) {
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);
OsmLevel level1 = areasLevels.get(area1);
for (Area area2 : areasForNode.get(osmNode)) {
OSMLevel level2 = areasLevels.get(area2);
OsmLevel level2 = areasLevels.get(area2);
if ((level1 == null && level2 == null) || (level1 != null && level1.equals(level2))) {
groups.union(area1, area2);
}
Expand All @@ -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.osm.model.OsmWithTags;

public record AreaTooComplicated(AreaGroup areaGroup, int nbNodes, int maxAreaNodes)
implements DataImportIssue {
Expand All @@ -11,12 +11,12 @@ public record AreaTooComplicated(AreaGroup areaGroup, int nbNodes, int maxAreaNo

@Override
public String getMessage() {
return String.format(FMT, areaGroup.getSomeOSMObject().getId(), nbNodes, maxAreaNodes);
return String.format(FMT, areaGroup.getSomeOsmObject().getId(), nbNodes, maxAreaNodes);
}

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

Expand Down
Loading
Loading