我正在使用osmosis 0.42和PostGIS 2.0.1,我正在尝试将一些postGIS表导出到.OSM xml文件。
我使用--read-pgsql命令从postgis读取(而不是--read-apidb,因为它在连接到数据库时抛出错误)..
不幸运行:
osmosis --read-pgsql host="x" database="x" user="x" password="x" --write-xml file="myfile.osm"
产生以下错误:
Task 2-write-xml does not support data provided by default pipe stored at level 1 in the default pipe stack
有任何想法吗?
非常感谢!
信仰
问题是--read-pgsql
产生了一个数据集,但--write-xml
期望一个实体流。
在这两个步骤之间使用--dataset-dump
将数据集转换为实体流:
osmosis --read-pgsql host="x" database="x" user="x" password="x" --dataset-dump --write-xml file="myfile.osm"
问题是您的数据库不是Osmosis理解的格式。 Osmosis只支持几种模式,因此您需要编写自定义导出器。
尽管postgis中的数据具有“快照”模式,但我还没有找到解决方案。
我找到了http://marcusjenkins.com/maps/plumbing-with-openstreetmap-osmosis/的解决方案
解决方案是:osmosis --read-pgsql host =“localhost”database =“foo”user =“foo”password =“foo”outPipe.0 = pg --dd inPipe.0 = pg outPipe.0 = dd - write-pbf inPipe.0 = dd file = wherever_munged.osm.pbf
要获得有限的区域:
osmosis --read-pgsql database=egypt-osm user=gisuser password='test0199' outPipe.0=pg --dataset-bounding-box inPipe.0=pg top=30.1332509 left=31.1400604 bottom=29.9400604 right=31.3220215 outPipe.0=dd --write-xml inPipe.0=dd file=- | bzip2 > cairo.osm.bz2
为了得到一切:
osmosis --read-pgsql database=egypt-osm user=gisuser password='test0199' outPipe.0=pg --dd inPipe.0=pg outPipe.0=dd --write-xml inPipe.0=dd file=- | bzip2 > everything.osm.bz2
如果出现“java.util.HashMap无法转换为org.openstreetmap.osmosis.hstore.PGHStore”等错误,请记住使用最新的渗透。