Class 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()  
    • 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)
    • Constructor Detail

      • PlanitOsmUtils

        public PlanitOsmUtils()
    • 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 for
        edges - to check against
        osmNodes - to extract geometry of osm entity from
        geoUtils - used to compute distances
        suppressLogging - 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 from
        osmNodes - 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 from
        osmNodes - to extract geo information from referenced nodes from in entity
        logLevel - change to this logLevel during the method call (reinstate original log level after)
        Returns:
        geometry created