Class OsmWayUtils


  • public class OsmWayUtils
    extends Object
    Utilities in relation to parsing osm ways and constructing a PLANit model from it
    Author:
    markr
    • Constructor Summary

      Constructors 
      Constructor Description
      OsmWayUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.locationtech.jts.geom.Coordinate[] createCoordinateArray​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, int startNodeIndex, int endNodeIndex, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Based on the passed in osmWay collect the coordinates on that way as a coordinate array for the given range.
      static org.locationtech.jts.geom.Coordinate[] createCoordinateArray​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Based on the passed in osmWay collect the coordinates on that way as a coordinate array.
      static org.locationtech.jts.geom.Coordinate[] createCoordinateArray​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, int startNodeIndex, int endNodeIndex, PlanitExceptionConsumer<Set<Long>> missingNodeConsumer)
      Based on the passed in osmWay collect the coordinates on that way as a coordinate array.
      static org.locationtech.jts.geom.Coordinate[] createCoordinateArrayNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, int startNodeIndex, int endNodeIndex, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Based on the passed in osmWay collect the coordinates on that way as a coordinate array for the given range.
      static org.locationtech.jts.geom.Coordinate[] createCoordinateArrayNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Based on the passed in osmWay collect the coordinates on that way as a coordinate array.
      static org.locationtech.jts.geom.Geometry extractGeometry​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      extract geometry from the osm way which can either be a line string or polygon
      static org.locationtech.jts.geom.Geometry extractGeometry​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, Level logLevel)
      extract geometry from the OSM way which can either be a line string or polygon
      static org.locationtech.jts.geom.LineString extractLineString​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, int startNodeIndex, int endNodeIndex, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Extract the geometry for the passed in way as line string for the given nodes
      static org.locationtech.jts.geom.LineString extractLineString​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Extract the geometry for the passed in way as line string
      static org.locationtech.jts.geom.LineString extractLineStringNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, int startNodeIndex, int endNodeIndex, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      static org.locationtech.jts.geom.LineString extractLineStringNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      static org.locationtech.jts.geom.Point extractPoint​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      creates a point geometry using the first available node from the nodes on the OSM way.
      static org.locationtech.jts.geom.Polygon extractPolygon​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Extract the geometry for the passed in way as polygon (assumed it has been identified as such already)
      static org.locationtech.jts.geom.Polygon extractPolygonNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      identical to extractPolygon(OsmWay, Map), except it does not throw exceptions, but simply logs any issues found and tries to salvage the polygon by creating it out of the coordinates that are available as lnog as we can still create a closed 2D shape.
      static Edge findEdgeClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Collection<? extends Edge> edges, double maxDistanceMeters, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, boolean suppressLogging, PlanitJtsCrsUtils geoUtils)
      find the closest edge to the way from the available edges.
      static Edge findEdgeClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Collection<? extends Edge> edges, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, boolean suppressLogging, PlanitJtsCrsUtils geoUtils)
      find the closest edge to the way from the available edges.
      static Integer findFirstAvailableOsmNodeIndexAfter​(int offsetIndex, de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      finds the first available osm node index on the osm way
      static Pair<Integer,​Integer> findIndicesOfFirstLoop​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, int initialNodeIndex)
      Find the start and end index of the first circular component of the passed in way (if any).
      static Integer findLastAvailableOsmNodeIndexAfter​(int offsetIndex, de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Finds the last consecutive available OSM node index after the offset, i.e.
      static org.locationtech.jts.geom.LineSegment findMinimumLineSegmentBetween​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, org.locationtech.jts.geom.LineString geometry, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, PlanitJtsCrsUtils geoUtils)
      find the minimum distance line segment that connects the osmWay to the passed in line string geometry
      static String findMostProminentOsmHighWayType​(Set<? extends Edge> edges)
      find the most prominent (important) of the edges based on the osm highway type they carry
      protected static <T> T findPlanitEntityClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Collection<? extends T> planitEntities, double maxDistanceMeters, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, boolean suppressLogging, PlanitJtsCrsUtils geoUtils)
      find the closest PLANit entity to the way from the available entities.
      static String findWayTypeValueForEligibleKey​(Map<String,​String> tags)
      Verify existence of any of the supported way keys (highway=, railway=, or a waterway one (route=ferry, ferry=_highway_type) and return the value
      static Zone findZoneClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Collection<? extends Zone> zones, double maxDistanceMeters, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, boolean suppressLogging, PlanitJtsCrsUtils geoUtils)
      Find the closest zone to the way .
      static Zone findZoneClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Collection<? extends Zone> zones, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, boolean suppressLogging, PlanitJtsCrsUtils geoUtils)
      Find the closest zone to the way .
      static Integer getOsmWayNodeIndexByLocation​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, org.locationtech.jts.geom.Point nodePosition, OsmNetworkReaderData networkData)
      Collect index by location within the way.
      static boolean isAllOsmWayNodesAvailable​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
      Verify that all OSM nodes in the OSM way are available
      static boolean isCircularOsmWay​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<String,​String> tags, boolean mustEndAtStart)
      Verify if passed osmWay is in fact circular in nature, e.g., , a type of roundabout.
      static boolean isCircularWayDefaultDirectionClockwise​(String countryName)
      The OSM default driving direction on a roundabout is either anticlockwise (right hand drive countries) or clockwise (left hand drive countries), here we verify, based on the country name, if the default is clockwise or not (anticlockwise)
      static boolean isCircularWayDirectionClosed​(Map<String,​String> tags, boolean isForwardDirection, String countryName)
      assuming the tags represent an OSM way that is tagged as a junction=roundabout or circular, this method verifies the driving direction on this way based on the country it resides in or an explicit override of the clockwise or anticlockwise direction tags.
      static boolean isOsmWayPerfectLoop​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay)
      Verify if the OSM way is a perfect loop, i.e., its first node equates to the last node
      static void removeEdgesWithOsmHighwayTypesLessImportantThan​(String osmHighwayType, Set<? extends Edge> edgesToFilter)
      Remove all edges with osm way types that are deemed less prominent than the one provided based on the OSM highway tags ordering
    • Constructor Detail

      • OsmWayUtils

        public OsmWayUtils()
    • Method Detail

      • findPlanitEntityClosest

        protected static <T> T findPlanitEntityClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                       Collection<? extends T> planitEntities,
                                                       double maxDistanceMeters,
                                                       Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                                       boolean suppressLogging,
                                                       PlanitJtsCrsUtils geoUtils)
        find the closest PLANit entity to the way from the available entities. This method computes the actual distance between any location on any line segment of the geometry of the entity and any node on the way and it is therefore is very precise. A cap is placed on how far a zone is allowed to be to still be regarded as closest via maxDistanceMeters.
        Type Parameters:
        T - type of the PLANit entity
        Parameters:
        osmWay - reference way
        planitEntities - to check against using their geometries
        maxDistanceMeters - maximum allowedDistance to be eligible
        osmNodes - the way might refer to
        suppressLogging - when true suppress logging, false otherwise
        geoUtils - to compute projected distances
        Returns:
        closest, null if none matches criteria
      • isCircularOsmWay

        public static boolean isCircularOsmWay​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                               Map<String,​String> tags,
                                               boolean mustEndAtStart)
        Verify if passed osmWay is in fact circular in nature, e.g., , a type of roundabout. The way must be of type highway or railway as well
        Parameters:
        osmWay - the way to verify
        tags - of this OSM way
        mustEndAtStart - , when true only circular roads where the end node is the start node are identified, when false, any node that appears twice results in a positive result (true is returned)
        Returns:
        true if circular, false otherwise
      • isOsmWayPerfectLoop

        public static boolean isOsmWayPerfectLoop​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay)
        Verify if the OSM way is a perfect loop, i.e., its first node equates to the last node
        Parameters:
        osmWay - to check
        Returns:
        true when circular way, i.e., enclosed area, false otherwise
      • findIndicesOfFirstLoop

        public static Pair<Integer,​Integer> findIndicesOfFirstLoop​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                         int initialNodeIndex)
        Find the start and end index of the first circular component of the passed in way (if any).
        Parameters:
        osmWay - to check
        initialNodeIndex - offset to use, when set it uses it as the starting point to start looking
        Returns:
        pair of indices demarcating the first two indices with the same node conditional on the offset, null if not found
      • isCircularWayDefaultDirectionClockwise

        public static boolean isCircularWayDefaultDirectionClockwise​(String countryName)
        The OSM default driving direction on a roundabout is either anticlockwise (right hand drive countries) or clockwise (left hand drive countries), here we verify, based on the country name, if the default is clockwise or not (anticlockwise)
        Parameters:
        countryName - to check
        Returns:
        true when lockwise direction is default, false otherwise
      • isCircularWayDirectionClosed

        public static boolean isCircularWayDirectionClosed​(Map<String,​String> tags,
                                                           boolean isForwardDirection,
                                                           String countryName)
        assuming the tags represent an OSM way that is tagged as a junction=roundabout or circular, this method verifies the driving direction on this way based on the country it resides in or an explicit override of the clockwise or anticlockwise direction tags. Because OSM implicitly assumes these ways are one way and they comply with country specific direction defaults we must utilise this method to find out what the actual driving direction is
        Parameters:
        tags - to use
        isForwardDirection - the direction that we want to verify if it is closed
        countryName - country name we determine the driving direction from in case it is not explicitly tagged
        Returns:
        true when isForwardDirection is closed, false otherwise
      • createCoordinateArray

        public static org.locationtech.jts.geom.Coordinate[] createCoordinateArray​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                                   Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                                                                   int startNodeIndex,
                                                                                   int endNodeIndex,
                                                                                   PlanitExceptionConsumer<Set<Long>> missingNodeConsumer)
                                                                            throws PlanItException
        Based on the passed in osmWay collect the coordinates on that way as a coordinate array. In case something goes wrong and missing nodes are found, the passed in consumer is called to deal with it. User can decide to throw an exception or do something else entirely. If no exception is thrown, the nodes that could be parsed will be returned
        Parameters:
        osmWay - to extract node coordinates from
        osmNodes - to collect nodes from by reference node ids in the way
        startNodeIndex - reference
        endNodeIndex - reference
        missingNodeConsumer - callback in case of missing node found
        Returns:
        coordinate array found, empty when no nodes were found available
        Throws:
        PlanItException - thrown if error
      • createCoordinateArray

        public static org.locationtech.jts.geom.Coordinate[] createCoordinateArray​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                                   Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
                                                                            throws PlanItException
        Based on the passed in osmWay collect the coordinates on that way as a coordinate array. In case there are missing nodes or something else goes wrong a PlanitException is thrown
        Parameters:
        osmWay - to extract node coordinates from
        osmNodes - to collect nodes from by reference node ids in the way
        Returns:
        coordinate array
        Throws:
        PlanItException - thrown if error
      • createCoordinateArray

        public static org.locationtech.jts.geom.Coordinate[] createCoordinateArray​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                                   int startNodeIndex,
                                                                                   int endNodeIndex,
                                                                                   Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
                                                                            throws PlanItException
        Based on the passed in osmWay collect the coordinates on that way as a coordinate array for the given range. In case there are missing nodes or something else goes wrong a PlanitException is thrown
        Parameters:
        osmWay - to extract node coordinates from
        osmNodes - to collect nodes from by reference node ids in the way
        startNodeIndex - to use
        endNodeIndex - to use
        Returns:
        coordinate array
        Throws:
        PlanItException - thrown if error
      • createCoordinateArrayNoThrow

        public static org.locationtech.jts.geom.Coordinate[] createCoordinateArrayNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                                          int startNodeIndex,
                                                                                          int endNodeIndex,
                                                                                          Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
                                                                                   throws PlanItException
        Based on the passed in osmWay collect the coordinates on that way as a coordinate array for the given range. In case there are missing nodes we log this but retain as much of the information in the returned coordinate array as possible
        Parameters:
        osmWay - to extract node coordinates from
        osmNodes - to collect nodes from by reference node ids in the way
        startNodeIndex - to use
        endNodeIndex - to use
        Returns:
        coordinate array
        Throws:
        PlanItException - thrown if error
      • createCoordinateArrayNoThrow

        public static org.locationtech.jts.geom.Coordinate[] createCoordinateArrayNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                                          Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
        Based on the passed in osmWay collect the coordinates on that way as a coordinate array. In case there are missing nodes we log this but retain as much of the information in the returned coordinate array as possible
        Parameters:
        osmWay - to extract node coordinates from
        osmNodes - to collect nodes from by reference node ids in the way
        Returns:
        coordinate array
      • extractGeometry

        public static org.locationtech.jts.geom.Geometry extractGeometry​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                         Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
                                                                  throws PlanItException
        extract geometry from the osm way which can either be a line string or polygon
        Parameters:
        osmWay - to extract geometry for
        osmNodes - to extract geo features from
        Returns:
        created geometry
        Throws:
        PlanItException - thrown if error
      • extractGeometry

        public static org.locationtech.jts.geom.Geometry extractGeometry​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                         Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                                                         Level logLevel)
        extract geometry from the OSM way which can either be a line string or polygon
        Parameters:
        osmWay - to extract geometry for
        osmNodes - to extract geo features from
        logLevel - logLevel
        Returns:
        created geometry
      • extractLineString

        public static org.locationtech.jts.geom.LineString extractLineString​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                             Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
                                                                      throws PlanItException
        Extract the geometry for the passed in way as line string
        Parameters:
        osmWay - way to extract geometry from
        osmNodes - to consider
        Returns:
        line string instance representing the shape of the way
        Throws:
        PlanItException - thrown if error
      • extractLineString

        public static org.locationtech.jts.geom.LineString extractLineString​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                             int startNodeIndex,
                                                                             int endNodeIndex,
                                                                             Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
                                                                      throws PlanItException
        Extract the geometry for the passed in way as line string for the given nodes
        Parameters:
        osmWay - way to extract geometry from
        startNodeIndex - to use
        endNodeIndex - to use
        osmNodes - to consider
        Returns:
        line string instance representing the shape of the way
        Throws:
        PlanItException - thrown if error
      • extractPoint

        public static org.locationtech.jts.geom.Point extractPoint​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                   Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
        creates a point geometry using the first available node from the nodes on the OSM way. Only to be used when no line string or polygon could be extract due to missing nodes for example
        Parameters:
        osmWay - to extract point geometry for
        osmNodes - to collect from
        Returns:
        parsed geometry, can be null if not valid for some reason
      • extractPolygon

        public static org.locationtech.jts.geom.Polygon extractPolygon​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                       Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
                                                                throws PlanItException
        Extract the geometry for the passed in way as polygon (assumed it has been identified as such already)
        Parameters:
        osmWay - to extract geometry for
        osmNodes - to collect from
        Returns:
        parsed geometry
        Throws:
        PlanItException - thrown if error
      • extractPolygonNoThrow

        public static org.locationtech.jts.geom.Polygon extractPolygonNoThrow​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                              Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
        identical to extractPolygon(OsmWay, Map), except it does not throw exceptions, but simply logs any issues found and tries to salvage the polygon by creating it out of the coordinates that are available as lnog as we can still create a closed 2D shape.
        Parameters:
        osmWay - to extract geometry for
        osmNodes - to collect from
        Returns:
        parsed geometry
      • findZoneClosest

        public static Zone findZoneClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                           Collection<? extends Zone> zones,
                                           Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                           boolean suppressLogging,
                                           PlanitJtsCrsUtils geoUtils)
        Find the closest zone to the way . This method computes the actual distance between any location on any line segment of the outer boundary of the zones (or its centroid if no polygon/linestring is available) and any node on the way and it is therefore is very precise
        Parameters:
        osmWay - reference way
        zones - to check against using their geometries
        osmNodes - to consider
        suppressLogging - when true suppress logging, false otherwise
        geoUtils - to compute projected distances
        Returns:
        zone closest, null if none matches criteria
      • findZoneClosest

        public static Zone findZoneClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                           Collection<? extends Zone> zones,
                                           double maxDistanceMeters,
                                           Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                           boolean suppressLogging,
                                           PlanitJtsCrsUtils geoUtils)
        Find the closest zone to the way . This method computes the actual distance between any location on any line segment of the outer boundary of the zones (or its centroid if no polygon/linestring is available) and any node on the way and it is therefore is very precise. A cap is placed on how far a zone is allowed to be to still be regarded as closest via maxDistanceMeters.
        Parameters:
        osmWay - reference way
        zones - to check against using their geometries
        maxDistanceMeters - maximum allowedDistance to be eligible
        osmNodes - the way might refer to
        suppressLogging - when true suppress logging, false otherwise
        geoUtils - to compute projected distances
        Returns:
        zone closest, null if none matches criteria
      • findEdgeClosest

        public static Edge findEdgeClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                           Collection<? extends Edge> edges,
                                           Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                           boolean suppressLogging,
                                           PlanitJtsCrsUtils geoUtils)
        find the closest edge to the way from the available edges. This method computes the actual distance between any location on any line segment of the geometry of the edge and any node on the way and it is therefore is very precise
        Parameters:
        osmWay - reference way
        edges - to check against using their geometries
        osmNodes - the way might refer to
        suppressLogging - when true suppress logging, false otherwise
        geoUtils - to compute projected distances
        Returns:
        edge closest, null if none matches criteria
      • findEdgeClosest

        public static Edge findEdgeClosest​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                           Collection<? extends Edge> edges,
                                           double maxDistanceMeters,
                                           Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                           boolean suppressLogging,
                                           PlanitJtsCrsUtils geoUtils)
        find the closest edge to the way from the available edges. This method computes the actual distance between any location on any line segment of the geometry of the edge and any node on the way and it is therefore is very precise. A cap is placed on how far a zone is allowed to be to still be regarded as closest via maxDistanceMeters.
        Parameters:
        osmWay - reference way
        edges - to check against using their geometries
        maxDistanceMeters - maximum allowedDistance to be eligible
        osmNodes - the way might refer to
        suppressLogging - when true suppress logging, false otherwise
        geoUtils - to compute projected distances
        Returns:
        edge closest, null if none matches criteria
      • findMinimumLineSegmentBetween

        public static org.locationtech.jts.geom.LineSegment findMinimumLineSegmentBetween​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                                          org.locationtech.jts.geom.LineString geometry,
                                                                                          Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                                                                          PlanitJtsCrsUtils geoUtils)
        find the minimum distance line segment that connects the osmWay to the passed in line string geometry
        Parameters:
        osmWay - to use
        geometry - to find minimum line segment to
        osmNodes - to use for extracting geo information regarding the osm way
        geoUtils - to compute distances
        Returns:
        line segment with minimum distance connecting the way and the geometry
      • findMostProminentOsmHighWayType

        public static String findMostProminentOsmHighWayType​(Set<? extends Edge> edges)
        find the most prominent (important) of the edges based on the osm highway type they carry
        Parameters:
        edges - to check
        Returns:
        osm highway type found to be the most prominent
      • removeEdgesWithOsmHighwayTypesLessImportantThan

        public static void removeEdgesWithOsmHighwayTypesLessImportantThan​(String osmHighwayType,
                                                                           Set<? extends Edge> edgesToFilter)
        Remove all edges with osm way types that are deemed less prominent than the one provided based on the OSM highway tags ordering
        Parameters:
        osmHighwayType - to use as a reference
        edgesToFilter - the collection being filtered
      • findFirstAvailableOsmNodeIndexAfter

        public static Integer findFirstAvailableOsmNodeIndexAfter​(int offsetIndex,
                                                                  de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                  Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
        finds the first available osm node index on the osm way
        Parameters:
        offsetIndex - to start search from
        osmWay - to collect from
        osmNodes - to check existence of osm way nodes
        Returns:
        index of first available osm node, null if not found
      • findLastAvailableOsmNodeIndexAfter

        public static Integer findLastAvailableOsmNodeIndexAfter​(int offsetIndex,
                                                                 de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                 Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
        Finds the last consecutive available OSM node index after the offset, i.e. the index before the first unavailable node
        Parameters:
        offsetIndex - to start search from
        osmWay - to collect from
        osmNodes - to check existence of osm way nodes
        Returns:
        last index of node that is available, null otherwise
      • isAllOsmWayNodesAvailable

        public static boolean isAllOsmWayNodesAvailable​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                        Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes)
        Verify that all OSM nodes in the OSM way are available
        Parameters:
        osmWay - to verify
        osmNodes - to check existence of OSM way nodes
        Returns:
        true when complete, false otherwise
      • getOsmWayNodeIndexByLocation

        public static Integer getOsmWayNodeIndexByLocation​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                           org.locationtech.jts.geom.Point nodePosition,
                                                           OsmNetworkReaderData networkData)
        Collect index by location within the way. first collect node from all nodes and then extract location because if duplicate nodes in the same location exist, collecting by location directly from layer data could yield the wrong node. this way we are certain to extract the location from the right OSM node
        Parameters:
        osmWay - way to use
        nodePosition - node position to find
        networkData - to use
        Returns:
        the index, null if nothing is found
      • findWayTypeValueForEligibleKey

        public static String findWayTypeValueForEligibleKey​(Map<String,​String> tags)
        Verify existence of any of the supported way keys (highway=, railway=, or a waterway one (route=ferry, ferry=_highway_type) and return the value
        Parameters:
        tags - to check
        Returns:
        value found or log warning