Package org.goplanit.osm.util
Class PlanitOsmUtils
- java.lang.Object
-
- org.goplanit.osm.util.PlanitOsmUtils
-
public class PlanitOsmUtils extends Object
Utilities in relation to parsing OSM data and constructing a PLANit model from it that are too general to be moved to any of the more specific PlanitOSMXXXUtils classes.- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
SPEED_LIMIT_PATTERN
regular expression pattern([^0-9]*)([0-9]*\\.?[0-9]+).*(km/h|kmh|kph|mph|knots)?.* used to extract decimal values and unit (if any) where the decimal value is in group two and the unit in group 3 (indicated by second section of round brackets)
-
Constructor Summary
Constructors Constructor Description PlanitOsmUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.locationtech.jts.geom.Geometry
extractGeometry(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<Long,de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
extract geometry from the osm entity, either a point, line string or polygonstatic org.locationtech.jts.geom.Geometry
extractGeometry(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<Long,de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, Level logLevel)
extract geometry from the OSM entity, either a point, line string or polygonstatic Edge
findEdgeClosest(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Collection<? extends Edge> edges, Map<Long,de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, boolean suppressLogging, PlanitJtsCrsUtils geoUtils)
find the link closest to the passed in osm Entitystatic double
parseMaxSpeedValueKmPerHour(String maxSpeedValue)
parse an OSM maxSpeedValue tag value and perform unit conversion to km/h if neededstatic double[]
parseMaxSpeedValueLanesKmPerHour(String maxSpeedLanes)
parse an OSM maxSpeedValue tag value with speeds per lane separated by "|" and perform unit conversion to km/h if needed
-
-
-
Field Detail
-
SPEED_LIMIT_PATTERN
public static final Pattern SPEED_LIMIT_PATTERN
regular expression pattern([^0-9]*)([0-9]*\\.?[0-9]+).*(km/h|kmh|kph|mph|knots)?.* used to extract decimal values and unit (if any) where the decimal value is in group two and the unit in group 3 (indicated by second section of round brackets)
-
-
Method Detail
-
parseMaxSpeedValueKmPerHour
public static double parseMaxSpeedValueKmPerHour(String maxSpeedValue) throws PlanItException
parse an OSM maxSpeedValue tag value and perform unit conversion to km/h if needed- Parameters:
maxSpeedValue
- string- Returns:
- parsed speed limit in km/h
- Throws:
PlanItException
- thrown if error
-
parseMaxSpeedValueLanesKmPerHour
public static double[] parseMaxSpeedValueLanesKmPerHour(String maxSpeedLanes) throws PlanItException
parse an OSM maxSpeedValue tag value with speeds per lane separated by "|" and perform unit conversion to km/h if needed- Parameters:
maxSpeedLanes
- string, e.g. 100|100|100- Returns:
- parsed speed limit in km/h
- Throws:
PlanItException
- thrown if error
-
findEdgeClosest
public static Edge findEdgeClosest(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Collection<? extends Edge> edges, Map<Long,de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, boolean suppressLogging, PlanitJtsCrsUtils geoUtils)
find the link closest to the passed in osm Entity- Parameters:
osmEntity
- to find closest link foredges
- to check againstosmNodes
- to extract geometry of osm entity fromgeoUtils
- used to compute distancessuppressLogging
- when true suppress logging, false otherwise- Returns:
- closest edge found
-
extractGeometry
public static org.locationtech.jts.geom.Geometry extractGeometry(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<Long,de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes) throws PlanItException
extract geometry from the osm entity, either a point, line string or polygon- Parameters:
osmEntity
- to extract fromosmNodes
- to extract geo information from referenced nodes from in entity- Returns:
- geometry created
- Throws:
PlanItException
- thrown if error
-
extractGeometry
public static org.locationtech.jts.geom.Geometry extractGeometry(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<Long,de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, Level logLevel)
extract geometry from the OSM entity, either a point, line string or polygon- Parameters:
osmEntity
- to extract fromosmNodes
- to extract geo information from referenced nodes from in entitylogLevel
- change to this logLevel during the method call (reinstate original log level after)- Returns:
- geometry created
-
-