02. The OpenStreetMap Project
The OpenStreetMap Project
In the next classroom concepts, you will write a course project in C++ using real map data and A* search to find a path between two points, just as you might see in a desktop or mobile mapping application. The project you will will write will be using data from the OpenStreetMap project .
The OpenStreetMap project is an open source, collaborative endeavor to create free, user-generated maps of every part of the world. These maps are similar to the maps you might use in Google Maps or the Apple Maps app on your phone, but they are completely generated by individuals who volunteer to perform ground surveys of their local environment.
Example OpenStreetMap with plotted path
OpenStreetMap Data
OpenStreetMap data can come in several different formats. The data that is used for this project comes in the form of an OSM XML file (.osm file), and we have provided a sample from the OpenStreetMap Wiki below. Although you may not have worked with this type of data before, have a look at the data below and try to guess which element types from the next quiz are present in the data. We are confident you can figure this out by carefully studying the data!
SOLUTION:
- node
- way
- relation
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.0.2">
<bounds minlat="54.0889580" minlon="12.2487570" maxlat="54.0913900" maxlon="12.2524800"/>
<node id="298884269" lat="54.0901746" lon="12.2482632" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/>
<node id="261728686" lat="54.0906309" lon="12.2441924" user="PikoWinter" uid="36744" visible="true" version="1" changeset="323878" timestamp="2008-05-03T13:39:23Z"/>
<node id="1831881213" version="1" changeset="12370172" lat="54.0900666" lon="12.2539381" user="lafkor" uid="75625" visible="true" timestamp="2012-07-20T09:43:19Z">
<tag k="name" v="Neu Broderstorf"/>
<tag k="traffic_sign" v="city_limit"/>
</node>
...
<node id="298884272" lat="54.0901447" lon="12.2516513" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/>
<way id="26659127" user="Masch" uid="55988" visible="true" version="5" changeset="4142606" timestamp="2010-03-16T11:47:08Z">
<nd ref="292403538"/>
<nd ref="298884289"/>
...
<nd ref="261728686"/>
<tag k="highway" v="unclassified"/>
<tag k="name" v="Pastower Straße"/>
</way>
<relation id="56688" user="kmvar" uid="56190" visible="true" version="28" changeset="6947637" timestamp="2011-01-12T14:23:49Z">
<member type="node" ref="294942404" role=""/>
...
<member type="node" ref="364933006" role=""/>
<member type="way" ref="4579143" role=""/>
...
<member type="node" ref="249673494" role=""/>
<tag k="name" v="Küstenbus Linie 123"/>
<tag k="network" v="VVW"/>
<tag k="operator" v="Regionalverkehr Küste"/>
<tag k="ref" v="123"/>
<tag k="route" v="bus"/>
<tag k="type" v="route"/>
</relation>
...
</osm>
Data Types Overview
Excellent work in guessing the types present in the data above! If you look closely at the XML element types in the sample above, you should see the three element types which are important to the code you will be writing: Nodes, Ways, and Relations.
Node
A
node
is one of the most basic elements in the OpenStreetMap data model. Each node indicates a single point with an identifier
id
, latitude
lat
, and longitude
lon
. There are other XML attributes in a node element that won't be relevant to this project, such as the
user
id and the
timestamp
when the node was added to the data set. Additionally, a node can have several tags which provide additional information.
Way
A
way
is an ordered list of nodes that represents a feature in the map. This feature could be a road, or a boundary of a park, or some other feature in the map. Each way has at least one
tag
which denotes some information about the way, and each way also belongs to at least one relation, which is described below.
Relation
A relation is a data structure which documents a relationship between other data elements. Examples from the OpenStreetMap wiki include:
- A route relation which lists the ways that form a major highway, cycle route, or bus route.
- A multipolygon that describes an area with holes, where the outer and inner boundaries of the area are given by two ways.
Example
To help you understand how all these types are used together, consider the following example from the OpenStreetMap wiki of mapping a large river with distinct banks on either side of the river. In the image below, nodes are used to provide the coordinates of points along the banks of the river. Multiple nodes are then connected using ways; there are ways which form closed sections of the river, labeled as "Areas" in the image below. Another way is used to represent the island in the middle of the river. These ways are then grouped together using a relation, which represents the entire river.
QUIZ QUESTION: :
Imagine you are going to create a bus route using OpenStreetMap data. Match the OpenStreetMap data type with the part of the bus route it represents.
ANSWER CHOICES:
|
Bus Route Part |
OSM Data Type |
|---|---|
|
Way |
|
|
Relation |
|
|
Node |
SOLUTION:
|
Bus Route Part |
OSM Data Type |
|---|---|
|
Way |
|
|
Relation |
|
|
Node |
Up Next
For your project, you will primarily be working with Nodes, although the code that we provide determines which nodes are neighbors by using the ways and relations those nodes belong to.
Both the code to parse the OSM data and the data structures which are used to store the data in your program have already been written in the IO2D OpenStreetMap example . In your project, you won't need to recreate any of this code - you task will be writing code that extends the code in order to plot a path between two points.
Up next, you will learn how to build, run, and test the project code. After that, we'll have an in-depth look at the files in the project starter code so you will be prepared to work on your project.