本文共 3783 字,大约阅读时间需要 12 分钟。
在(一)中大体了解了OpenStreetMap。
地图是如何花花绿绿地呈现出来的呢?首先,看一下OpenStreetMap的数据结构:
OpenStreetMap的元素(数据基元)主要包括三种:点()、路()和关系(R),这三种原始构成了整个地图画面。其中,定义了空间中点的位置;定义了线或区域;R(可选的)定义了元素间的关系。
通过经纬度定义了一个地理坐标点。同时,还可以=*标示物体所海拔;通过=* 和 =*,可以标示物体所在的地图层面与所在建筑物内的层数;通过=* and =*来表示对象的名称。同时,也是通过多个点()连接成线(面)来构成的。
通过2-2000个点(nodes)构成了way。way可表示如下3种图形事物(非闭合线、闭合线、区域)。对于超过2000 nodes的way,可以通过分割来处理。
非闭合线:收尾不闭合的线段。通常可用于表示现实中的道路、河流、铁路等。
闭合线:收尾相连的线。例如可以表示现实中的环线地铁。
区域:闭合区域。通常使用=* 来标示区域等。
一个可由一系列nodes, ways 或者其他的relations来组成,相互的关系通过来定义。一个元素可以在relation中被多次使用,而一个relation可以包含其他的relation。
标签不是地图基本元素,但是各元素都通过tag来记录数据信息。通过'key' and a 'value'来对数据进行记录(了解xml或者数据库的应该都比较清楚了吧?)。例如,可以通过=来定义居住区道路;同时,可以使用附加的命名空间来添加附加信息,例如:=*就表示冬天的最高限速。
具体的tag分类可参看:
简单的说:
OSM数据由以下元素组成:
所以这些元素都有标签,以描述地名,道路类型等信息。你可以用各种编辑器来创建元素和标签。
共同属性
Nodes, Ways 和 Relations 具有如下共同属性值:
name | value | description |
---|---|---|
user | string | The display name of the user who last modified the object. A user can change their display name |
uid | integer | The numeric user id. of the user who last modified the object. The user id. number will remain constant. |
timestamp | time of the last modification | |
visible | "true" "false" | whether the object is deleted or not in the database, if visible="false" then the object should only be returned by history calls. |
version | integer | The edit version of the object. Newly created objects start at version 1 and the value is incremented by the server when a client uploads a new version of the object. The server will reject a new version of an object if the version sent by the client does not match the current version of the object in the database. |
changeset | integer | The in which the object was created or updated. |
Nodes
<osm version="0.6" generator="OpenStreetMap server">
<node id="483034256" lat="55.9458449" lon="-3.2035477" version="1"
changeset="2369219" user="spytfyre" uid="166957" visible="true"
timestamp="2009-09-04T13:35:42Z">
<tag k="name" v="The Blue Blazer" />
<tag k="amenity" v="pub" />
</node>
</osm>
显示效果:
Ways
<osm version="0.6" generator="OpenStreetMap server">
<way id="43157302" visible="true" timestamp="2009-10-26T10:45:09Z"
version="1" changeset="2954960" user="Ed Avis" uid="31257">
<nd ref="540653724" />
<nd ref="25507043" />
<nd ref="107762" />
<nd ref="25507038" />
<nd ref="107759" />
<tag k="highway" v="primary" />
<tag k="lcn_ref" v="6a" />
<tag k="name" v="Parliament Street" />
</way>
</osm>
ref =* 代表了连接成线的点。
Relations
<osm version="0.6" generator="OpenStreetMap server">
<relation id="113421" visible="true" timestamp="2009-11-03T10:08:27Z"
version="2" changeset="3023369" user="Jonathan Bennett" uid="5352">
<member type="node" ref="270186" role="via" />
<member type="way" ref="4418767" role="from" />
<member type="way" ref="4641665" role="to" />
<tag k="restriction" v="no_right_turn" />
<tag k="type" v="restriction" />
</relation>
</osm>
表示:从id为"4418767"的way,经
tag
<osm version="0.6" generator="OpenStreetMap server">
<node id="107775" lat="51.5072647" lon="-0.1278328" version="29"
changeset="2628959" user="EdinburghGael" uid="170586" visible="true"
timestamp="2009-09-25T23:04:28Z">
<tag k="place" v="city" />
<tag k="name:zh" v="伦敦" />
<tag k="name:sv" v="London" />
<tag k="name:sk" v="Londyn" />
<tag k="name:ru" v="Лондон" />
<tag k="name:fi" v="Lontoo" />
<tag k="name:es" v="Londres" />
<tag k="name:gv" v="Lunnin" />
<tag k="name:zh_pyt" v="Lúndūn" />
...
<tag k="is_in" v="England, United Kingdom, UK, Great Britain,Europe" />
<tag k="capital" v="yes" />
<tag k="name:fr" v="Londres" />
<tag k="name:cy" v="Llundain" />
</node>
</osm>
使用tag,定义了伦敦市。
参考文献:
注:本博文多为自己参看资料整理翻译所得,能力所限,难免错误。欢迎各位同仁讨论批评指正。
转载地址:http://hwrbi.baihongyu.com/