Zh-hans:OSM XML
基础
XML 是一种所谓的元格式,提供给包括人类可识别的数据交互格式。很多文件格式均采用了类似HTML树型结构的格式,例如: SVG, ODT,...
优点 | 缺点 |
---|---|
|
|
OSM XML文件样式注意点
OSM领域的主要工具使用一种首先只被API使用,遵循这个XML样式定义的XML格式。这基本上是一个原始数据(节点,路径和关系)的实例的列表。
下面是一个缩短的完整的OSM XML文件:
<?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 Primitives了解对象种类的细节。
查看Map features了解真实世界的物体是如何被塑造并分类的。
结构如下:
查看/XSD和/DTD页面for details of attempts to define the format in those languages.
Assumptions
If you develop tools using this format, you can be sure that:
You can not be sure that:
- blocks are there (e.g. only nodes, no ways)
- blocks are sorted
- element IDs are non negative (Not in all osm files. Negative ids are used by editors for new elements)
- elements have to contain tags (Many elements do not. You will even come across Untagged unconnected nodes)
- visible only if false and not in Planet.osm
- id or user name present (Not always, due to anonymous edits in a very early stage)
- Changesets have an attribute num_changes for (This was abandoned from the history export tool because of inconsistencies)
- version ordering is sequential (doesn't have to be)
JOSM uses an 'action' attribute instead of timestamp, version or changeset for new objects
Some #flavours might have other restrictions.
工具
查看Planet.osm以及Import,Export,Convert
Flavours
这里是当前使用的文件格式,都有稍微不同的用途。
JOSM文件样式
- 主条目:JOSM file format
这个文件格式是由JOSM作者设计的。It basically is a logical extension of the data sent from the server. What it adds is an indication of the origin of the data and the bounding box it comes from (if possible). It is actually more of a storage format of data downloaded along with changes made by the user.
pros | cons |
---|---|
|
|
被以下软件支持:
osmChange
- 主条目:OsmChange
OsmChange is a file format was created by the author of osmosis and is a more general format for representing changes.
pros | cons |
---|---|
When sorted properly this file is a continuous stream of changes that can be played in order. In osmosis the option --sort-change will put the change into streamable order. |
|
Placeholders are proposed as an extension though they are not widely supported.
由以下项目支持:
- Osmosis
- Bulk_upload.py (read-only)
- [library]
- osmconvert
- osmchange (read-only)
- osmfilter
Technical features of change formats
This a list of things that are desirable in a change file format for exampe change sets
placeholders
Placeholders are a feature where objects that are created in the file can be used in the creation of the objects that depend on them. So a single file can create two nodes and join them with a segment without knowing beforehand the final IDs.
indication of origin
IDs used in OSM files can not be shared between servers. IDs are allocated by the server, not by clients. Thus it is useful if the change file indicates the source of any IDs used in the file.
streamable
Whether the file can normally be processed in a stream, without breaking referential integrity.