在(一)中大体了解了OpenStreetMap。
地图是如何花花绿绿地呈现出来的呢?首先,看一下OpenStreetMap的数据结构:
OpenStreetMap的元素(数据基元)主要包括三种:点(Nodes)、路(Ways)和关系(Relations),这三种原始构成了整个地图画面。其中,Nodes定义了空间中点的位置;Ways定义了线或区域;Relations(可选的)定义了元素间的关系。
node通过经纬度定义了一个地理坐标点。同时,还可以height=*标示物体所海拔;通过layer=* 和 level=*,可以标示物体所在的地图层面与所在建筑物内的层数;通过place=* and name=*来表示对象的名称。同时,way也是通过多个点(node)连接成线(面)来构成的。
通过2-2000个点(nodes)构成了way。way可表示如下3种图形事物(非闭合线、闭合线、区域)。对于超过2000 nodes的way,可以通过分割来处理。
非闭合线:收尾不闭合的线段。通常可用于表示现实中的道路、河流、铁路等。
闭合线:收尾相连的线。例如可以表示现实中的环线地铁。
区域:闭合区域。通常使用landuse=* 来标示区域等。
一个Relation可由一系列nodes, ways 或者其他的relations来组成,相互的关系通过role来定义。一个元素可以在relation中被多次使用,而一个relation可以包含其他的relation。
标签不是地图基本元素,但是各元素都通过tag来记录数据信息。通过'key' and a 'value'来对数据进行记录(了解xml或者数据库的应该都比较清楚了吧?)。例如,可以通过highway=residential来定义居住区道路;同时,可以使用附加的命名空间来添加附加信息,例如:maxspeed:winter=*就表示冬天的最高限速。
具体的tag分类可参看:http://wiki.openstreetmap.org/wiki/Map_Features
简单的说:
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 | W3C Date and Time Formats | 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 changeset in which the object was created or updated. |
Nodes
timestamp="2009-09-04T13:35:42Z">
显示效果:
Ways
ref =* 代表了连接成线的点。
Relations
表示:从id为"4418767"的way,经
tag
timestamp="2009-09-25T23:04:28Z">
...
使用tag,定义了伦敦市。
参考文献:
http://wiki.openstreetmap.org/wiki/Main_Page
http://lovespss.blog.51cto.com/1907593/515192
注:本博文多为自己参看资料整理翻译所得,能力所限,难免错误。欢迎各位同仁讨论批评指正。