Nearest Way

LightOSM.nearest_wayFunction
nearest_way(g, point, [search_radius])

Finds the nearest way from a point using a SpatialIndexing.jl R-tree.

The search area is a cube centred on point with an edge length of 2 * search_radius. If search_radius is not specified, it is automatically determined from the distance to the nearest node.

A larger search_radius will incur a performance penalty as more ways must be checked for their closest points. Choose this value carefully according to the desired use case.

Arguments

  • g::OSMGraph: Graph container.
  • point: Single point as a GeoLocation or [lat, lon, alt].
  • search_radius::AbstractFloat: Size of cube to search around point.

Return

  • ::Tuple{<:Integer,Float64,EdgePoint}: If nearest way was found.
    • ::Integer: Nearest way ID.
    • ::Float64: Distance to nearest way.
    • ::EdgePoint: Closest point on the nearest way.
  • ::Tuple{Nothing,Nothing,Nothing}: If no ways were found within search_radius.
source
LightOSM.nearest_waysFunction
nearest_ways(g, point, [search_radius])

Finds nearby ways from a point using a SpatialIndexing.jl R-tree.

The search area is a cube centred on point with an edge length of 2 * search_radius.

A larger search_radius will incur a performance penalty as more ways must be checked for their closest points. Choose this value carefully according to the desired use case.

Arguments

  • g::OSMGraph: Graph container.
  • point/points: Single point as a GeoLocation or [lat, lon, alt].
  • search_radius::AbstractFloat=0.1: Size of cube to search around point.

Return

  • ::Tuple{Vector{<:Integer},Vector{Float64},Vector{EdgePoint}}:
    • ::Vector{<:Integer}: Nearest way IDs.
    • ::Vector{Float64}: Distance to each corresponding nearby way.
    • ::Vector{EdgePoint}: Closest point on each corresponding nearby way.
source
LightOSM.nearest_point_on_wayFunction
nearest_point_on_way(g::OSMGraph, point::GeoLocation, way_id::DEFAULT_OSM_ID_TYPE)

Finds the nearest position on a way to a given point. Matches to an EdgePoint.

Arguments

  • g::OSMGraph: LightOSM graph.
  • point::GeoLocation: Point to find nearest position to.
  • wid::Integer: Way ID to search.

Returns

  • ::Tuple:
    • ::EdgePoint: Nearest position along the way between two nodes.
    • ::Float64: Distance from point to the nearest position on the way.
source