Osmosis 工具代码解读
功能
先将 Osmosis 的主要功能列出如下,大体包括了 Osm 文件服务常用的功能。
XML Tasks
- 3.3.1–read-xml (–rx)
- outPipe.0 生产出一个entity Stream
- 3.3.2–fast-read-xml (no short option available)
- 3.3.3–write-xml (–wx)
- inPipe.0 消费一个 Entity Stream
- 3.3.4–read-xml-change (–rxc)
- 3.3.5–write-xml-change (–wxc)
Area Filtering Tasks
- 3.4.1–bounding-box (–bb)
- inPipe.0 outPipe.0
- 3.4.2–bounding-polygon (–bp)
Changeset Derivation and Merging 提供 osc 和 osm 的分离合并
- 3.5.1–derive-change (–dc)
- 比较两份osm,产出一份 osc
- inPipe.0 – entity stream. inPipe.1-- entity stream outPipe.0 – change stream
- 3.5.2–apply-change (–ac)
- 将一份更改应用到一份 osm 上
Pipeline Control 控制Pipeline 的结构,不操作数据
- 3.6.1–write-null (–wn)
- 弃掉所有的输入数据
- inPipe.0
- 3.6.2–write-null-change (–wnc)
- 3.6.3–buffer (–b)
- 可将一个Pipeline分离到多个线程上。input Task 的线程会将数据传送到一个固定容量大小的缓冲区中,当缓冲区满,block。该任务还会产生一个新Thread从缓冲区中读取数据,缓冲区空,block
- inPipe.0 outPipe.0
- 3.6.4–buffer-change (–bc)
- 3.6.5–log-progress (–lp)
- 加入到Pipeline中,固定时间间隔记录下log
- 3.6.6–log-progress-change(–lpc)
- 3.6.7–tee (–t)
- 接受一个数据流,将其送到多个目的地。当读取一个数据源并要在上面应用多个操作时可用
- inPipe.0
- outPipe.0 ~ n-1
- 3.6.8–tee-change (–tc)
- 3.6.9–read-empty (–rem)
- 3.6.10–ready-empty-change (–remc)
Set Manipulation Tasks
- 3.7.1–sort (–s)
- 3.7.2–sort-change (–sc)
- 3.7.3–merge (–m)
- 3.7.3.1Bound entity processing
- 将两份文件合成一份,使用前要先按照 TypeThenId sort
- 3.7.4–merge-change (–mc)
- 3.7.5–append-change (–apc)
- 3.7.6–simplify-change (–simc)
- 3.7.7–convert-change-to-full-history (–cctfh)
Data Manipulation Tasks
- 3.8.1–node-key (–nk)
- 给定 KeyList,所有 node 中只有有至少一个List中的key的才会被留下来
- 3.8.2–node-key-value (–nkv)
- 3.8.3–way-key (–wk)
- 3.8.4–way-key-value (–wkv)
- 3.8.5–tag-filter (–tf)
- 3.8.6–used-node (–un)
- 只留下那些被用到的 nodes
- 3.8.7–used-way (–uw)
- 3.8.8–tag-transform (–tt)
例子
下面通过两个例子演示 Osmosis 工具的基本使用方法。
osmosis \
--read-xml input.osm \
--tf accept-ways highway=* \
--tf reject-ways highway=motorway,motorway_link \
--tf reject-relations \
--used-node \
--write-xml output.osm
- 只保留有 highway 标签的所有 way
- 保留下的 way 中,剔除掉 highway 标签值为 motorway, motorway_link 的way
- 删除所有 Relation
- 只保留被用到的 nodes
- 写出
osmosis
--rx /Users/cs