博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OpenStreetMap初探(二)——osm的数据结构
阅读量:4032 次
发布时间:2019-05-24

本文共 3783 字,大约阅读时间需要 12 分钟。

在(一)中大体了解了OpenStreetMap。

地图是如何花花绿绿地呈现出来的呢?首先,看一下OpenStreetMap的数据结构:

OpenStreetMap的元素(数据基元)主要包括三种:点()、路()和关系(R),这三种原始构成了整个地图画面。其中,定义了空间中点的位置;定义了线或区域;R(可选的)定义了元素间的关系。

Node 

通过经纬度定义了一个地理坐标点。同时,还可以=*标示物体所海拔;通过=* 和 =*,可以标示物体所在的地图层面与所在建筑物内的层数;通过=* and =*来表示对象的名称。同时,也是通过多个点()连接成线(面)来构成的。

Way   

通过2-2000个点(nodes)构成了way。way可表示如下3种图形事物(非闭合线、闭合线、区域)。对于超过2000 nodes的way,可以通过分割来处理。

Open polyline 

非闭合线:收尾不闭合的线段。通常可用于表示现实中的道路、河流、铁路等。

Closed polyline 

闭合线:收尾相连的线。例如可以表示现实中的环线地铁。

Area 

区域:闭合区域。通常使用=* 来标示区域等。

Relation 

一个可由一系列nodes, ways 或者其他的relations来组成,相互的关系通过来定义。一个元素可以在relation中被多次使用,而一个relation可以包含其他的relation。

Tag 

标签不是地图基本元素,但是各元素都通过tag来记录数据信息。通过'key' and a 'value'来对数据进行记录(了解xml或者数据库的应该都比较清楚了吧?)。例如,可以通过=来定义居住区道路;同时,可以使用附加的命名空间来添加附加信息,例如:=*就表示冬天的最高限速。

具体的tag分类可参看:

简单的说:

OSM数据由以下元素组成:

  • 节点(Nodes): 最基本的要素,是其它要素的组成部分.
  • 路线(Ways): 有方向性的节点序列, 在编辑器里显示成连接起来的线段.
  • 闭合路线(Closed Ways): 闭合路线是完全闭合的路线. 一般用来表示区域如公园,湖泊,岛屿等.

所以这些元素都有标签,以描述地名,道路类型等信息。你可以用各种编辑器来创建元素和标签。

共同属性

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/

你可能感兴趣的文章
关于AIS编码解码的两个小问题
查看>>
GitHub 万星推荐:黑客成长技术清单
查看>>
可以在线C++编译的工具站点
查看>>
关于无人驾驶的过去、现在以及未来,看这篇文章就够了!
查看>>
所谓的进步和提升,就是完成认知升级
查看>>
昨夜今晨最大八卦终于坐实——人类首次直接探测到了引力波
查看>>
如何优雅、机智地和新公司谈薪水?
查看>>
为什么读了很多书,却学不到什么东西?
查看>>
长文干货:如何轻松应对工作中最棘手的13种场景?
查看>>
如何确保自己的Mac数据安全呢?这里有四个“小秘诀”
查看>>
如何用好碎片化时间,让思维更有效率?
查看>>
第一性原理:戳中问题本质的人是怎么思考的?
查看>>
No.147 - LeetCode1108
查看>>
No.148 - LeetCode771
查看>>
No.174 - LeetCode1305 - 合并两个搜索树
查看>>
No.175 - LeetCode1306
查看>>
No.176 - LeetCode1309
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>
mac:移动python包路径
查看>>
mysql:sql create database新建utf8mb4 数据库
查看>>