欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Open Street Map Data

程序员文章站 2022-07-05 14:43:36
...

OpenStreetMap is an open source project to create free, user generated maps of every part of the world.

OpenStreetMap Data

The OpenStreetMap data that you will be using for this project comes in the form of an OSM XML file (.osm file). A sample of an OSM XML file from the OpenStreetMap Wiki is provided below.

<?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>

The XML file contains several element types which are important to the code you will be writing:

  1. Nodes,
  2. Ways, and
  3. Relations.

Nodes

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.

Ways

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.

Relations

A relation is a data structure which documents a relationship between other data elements. Examples from the OpenStreetMap wiki include:

  1. A route relation which lists the ways that form a major highway, cycle route, or bus route.
  2. A multipolygon that describes an area with holes, where the outer and inner boundaries of the area are given by two ways.