Reference

Representing map data

OpenStreetMapX.MapDataType

The MapData represents all data that have been processed from OpenStreetMap osm file This is the main data structure used fot map data analytics.

Fields

  • bounds : bounds of the area map (stored as a OpenStreetMapX.Bounds object)
  • nodes : dictionary of nodes representing all the objects on the map (with coordinates in East, North, Up system)
  • roadways : unique roads stored as a OpenStreetMapX.Way objects
  • intersections : roads intersections
  • g : Graphs directed graph representing a road network
  • v : vertices in the road network (node id .=> graph vertex)
  • n : vector of OpenStreetMap node ids for each corresponding graph vertex
  • e : vector of edges in the graph represented as a tuple (source,destination)
  • w : sparse matrix of edge weights, indexed by graph id
  • class : road class of each edge
source
OpenStreetMapX.get_map_dataMethod
get_map_data(filepath::String,filename::Union{String,Nothing}=nothing;
             road_levels::Set{Int} = Set(1:length(OpenStreetMapX.ROAD_CLASSES)),
			 use_cache::Bool = true, only_intersections::Bool=true)::MapData

High level function - parses .osm file and create the road network based on the map data. This code currently can parse both *.osm and *.pbf (@blegat - thank you!) files. The data type is determined by file extension.

Arguments

  • filepath : path with an .osm/.pbf file (directory or path to a file)
  • filename : name of the file (when the first argument is a directory)
  • road_levels : a set with the road categories (see: OpenStreetMapX.ROAD_CLASSES for more informations)
  • use_cache : a *.cache file will be crated with a serialized map image in the datapath folder
  • only_intersections : include only road system data
  • trim_to_connected_graph: trim orphan nodes in such way that the map is a strongly connected graph
source

Coordinate systems

OpenStreetMapX.ECEFType
ECEF

Point in Earth-Centered-Earth-Fixed (ECEF) coordinates. Global cartesian coordinate system rotating with the Earth.

Constructors

ECEF(x::Float64, y::Float64, z::Float64)
source
OpenStreetMapX.LLAType
LLA

Point in Latitude-Longitude-Altitude (LLA) coordinates Used to store node data in OpenStreetMapX XML files

Constructors

LLA(lat::Float64, lon::Float64)
LLA(lat::Float64, lon::Float64, alt::Float64)
LLA(xyz::XYZ)

Arguments

  • lat : lattitude
  • lon : Longitude
  • alt : altitude
source
OpenStreetMapX.ENUType
ENU

Point in East-North-Up (ENU) coordinates.

Local cartesian coordinate system. Linearized about a reference point.

Constructors

ENU(east::Float64, north::Float64, up::Float64)
ENU(east::Float64, north::Float64)
ENU(xyz::XYZ)
source
OpenStreetMapX.BoundsType
Bounds{T <: Union{LLA, ENU}}

Bounds for the LLA or ENUcoordinates. If T is not given Bounds{ENU} will be created.

source
OpenStreetMapX.centerFunction
center(bounds::Bounds{ENU})

Get Center Point of ENU Bounds Region

source
center(bounds::Bounds{LLA})

Get Center Point of LLA Bounds Region

source
OpenStreetMapX.inboundsFunction
inbounds(loc::ENU, bounds::Bounds{ENU})

Check Whether a location loc is within bounds bounds

source
inbounds(loc::LLA, bounds::Bounds{LLA})

Check whether a location loc is within bounds bounds

source
OpenStreetMapX.onboundsFunction
onbounds(loc::T, bounds::Bounds{T}) where T<:Union{LLA,ENU}

Check whether a location loc is onbounds bounds Works only for points that have passed the inbounds test

source
OpenStreetMapX.latlonFunction
latlon(m::MapData,map_g_point_id::Int64)::Tuple{Float64, Float64}

Returns a tuple of lattitute and longitude for a given graph node identifier map_g_point_id in graph m.g (i.e. map_g_point_id ∈ 1:nv(m.g)).

source

Routing operations

Missing docstring.

Missing docstring for generate_point_in_bounds(::MapData). Check Documenter's build log for details.

OpenStreetMapX.point_to_nodesMethod
point_to_nodes(point::Tuple{Float64,Float64}, m::MapData)

Converts a pair Latitude-Longitude of coordinates point to a node on a map m The result is a node indentifier.

source
OpenStreetMapX.point_to_nodesMethod
point_to_nodes(point::LLA, m::MapData)

Converts a pair of coordinates LLA (Latitude-Longitude-Altitude) point to a node on a map m The result is a node indentifier.

source
OpenStreetMapX.shortest_routeFunction
shortest_route(m::MapData, node1::Int, node2::Int; routing::Symbol = :astar)

Find Shortest route between node1 and node2 on map m.

source
shortest_route(m::MapData, node1::Int, node2::Int, node3::Int; routing::Symbol = :astar)

Find Shortest route between node1 and node2 and node3 on map m.

source
OpenStreetMapX.fastest_routeFunction
fastest_route(m::MapData, node1::Int, node2::Int;
                    routing::Symbol = :astar,
                    speeds::Dict{Int,Float64}=SPEED_ROADS_URBAN)

Find fastest route between node1 and node2 on map m with assuming speeds for road classes.

source
fastest_route(m::MapData, node1::Int, node2::Int, node3::Int;
                    routing::Symbol = :astar,
                    speeds::Dict{Int,Float64}=SPEED_ROADS_URBAN)

Find fastest route between node1 and node2 and node3 on map m with assuming speeds for road classes.

source
OpenStreetMapX.a_star_algorithmFunction
a_star_algorithm(g::AbstractGraph{U},  
                s::Integer,                       
                t::Integer,                       
                distmx::AbstractMatrix{T}=Graphs.weights(g),
                heuristic::Function = (u,v) -> zero(T)) where {T, U}

High level function - implementation of A star search algorithm: (https://en.wikipedia.org/wiki/A*searchalgorithm). Based on the implementation in Graphs library, however significantly improved in terms of performance.

Arguments

  • g : graph object
  • S : start vertex
  • t : end vertex
  • distmx : distance matrix
  • heuristic : search heuristic function; by default returns zero
source
a_star_algorithm(m::MapData,  
                s::Integer,                       
                t::Integer)

A star search algorithm with straight line distance heuristic

Arguments

  • m : MapData object
  • S : start vertex
  • t : end vertex
  • distmx : distance matrix
source
OpenStreetMapX.distanceFunction
distance(a::ENU, b::ENU)

Calculates a distance between two points a and b

source
distance(a::ECEF, b::ECEF)

Calculates a distance between two points a and b

source

Compute the distance of a route for some nodes data

source

Get Distances Between Edges

source

Google API routing

OpenStreetMapX.get_google_routeMethod
get_google_route(origin::Int, destination::Int,
                 map_data:MapData, googleapi_key::String;
                 googleapi_parameters::Dict{Symbol,String} = googleAPI_parameters)

Get route from to based on Google Distances API with two points (origin and destination) on map map_data using Google API key googleapi_key with optional Google Distances API request parameters googleapi_parameters.

source
OpenStreetMapX.get_google_routeMethod
get_google_route(origin::Int, destination::Int, waypoint::Int,
                 map_data:MapData, googleapi_key::String;
                 googleapi_parameters::Dict{Symbol,String} = googleAPI_parameters)

Get route from to based on Google Distances API with three points (origin, destination and waypoint between) on map map_data using Google API key googleapi_key with optional Google Distances API request parameters googleapi_parameters.

source
OpenStreetMapX.node_to_stringMethod
node_to_string(node_id::Int,map_data::MapData)

Convert node coordinates (stored in ENU system in the nodes field of map_data) identified by node_id to string with LLA system coordinates

source
OpenStreetMapX.googleAPI_parametersConstant

Dictionary for Google Distances API requests:

Keys

  • :url : url for google API, only JSON files outputs are accepted
  • :mode : transportation mode used in simulation, in the current library scope only driving is accepted
  • :avoid : map features to avoid (to mantain compatibility with OSM routes ferries should be avoided)
  • :units : unit system for displaing distances (changing to imperial needs deeper changes in both OSMsim and OpenStreetMapX modules)
source
OpenStreetMapX.encode_oneFunction

Encode single coordinate (multiplied by 1e5 and rounded) in Google Polyline Algorithm Format

Arguments

  • val : single coordinate (multiplied by 1e5 and rounded)
source
OpenStreetMapX.encodeFunction

Encode coordinates in Google Polyline Algorithm Format

Arguments

  • coords : coordinates in LLA system stored as a tuple
source
OpenStreetMapX.decode_oneFunction

Decode single coordinate

Arguments

  • polyline : coordinates in Google Polyline Algorithm Format stored as an array of characters
  • index : position of each single coordinate in polyline array
source
OpenStreetMapX.decodeFunction

Decode coordinates in Google Polyline Algorithm Format

Arguments

  • polyline : string containing coordinates in Polyline Algorithm Format
source

Routing parameters

OpenStreetMapX.CYCLE_CLASSESConstant
CYCLE_CLASSES

Cycle classes - Level 1: Bike paths - Level 2: Separated bike lanes (tracks) - Level 3: Bike lanes - Level 4: Bikes typically allowed but not specified

source
OpenStreetMapX.PED_CLASSESConstant
PED_CLASSES

Pedestrain paths

- Level 1: Cycleways, walking paths, and pedestrian streets
- Level 2: Sidewalks
- Level 3: Pedestrians typically allowed but unspecified
- Level 4: Agricultural or horse paths, etc.
source