# 首先创建文件夹
mkdir maps
cd maps
# 下载osmosis
wget http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-latest.tgz
mkdir osmosis
# 解压到osmosis文件夹
tar zxvf osmosis-latest.tgz -C osmosis
# 下载一个.pbf地图文件
wget http://download.geofabrik.de/asia/turkmenistan-latest.osm.pbf
# 尝试转换, file参数是文件变量
osmosis/bin/osmosis --rb file=/Users/lixiang/maps/turkmenistan-latest.osm.pbf --mapfile-writer file=a.map
这个地方会报一个没有mapsforge-map-writer的错误
在用户目录下创建文件夹 ~/.openstreetmap/osmosis/plugins/, 然后把mapsforge-map-writer放入plugins文件夹
cd ..
mkdir .openstreetmap
cd .openstreetmap
mkdir osmosis
cd osmosis
mkdir plugins
wget https://repo1.maven.org/maven2/org/mapsforge/mapsforge-map-writer/0.7.0-rc2/mapsforge-map-writer-0.7.0-rc2-jar-with-dependencies.jar
如果是0.6.x版本的需要进行以下步骤:
# 重新进入maps文件夹, 尝试转换,这里汇报一个trove找不到一个类的问题,尝试重新下载这个trove版本3.0.2
cd ~/maps
osmosis/bin/osmosis --rb file=/Users/lixiang/maps/turkmenistan-latest.osm.pbf --mapfile-writer file=a.map
cd .openstreetmap/osmosis/plugins
wget https://svwh.dl.sourceforge.net/project/trove4j/trove/3.0.2/trove-3.0.2.zip
# 解压trove-3.0.3.zip, 在其中的3.0.2/lib/trove-3.0.2.jar文件,放入osmosis/lib/default文件中
unzip trove-3.0.2.zip
mv 3.0.2/lib/trove-3.0.2.jar osmosis/lib/default
# 再次尝试转换, 会出现mapsforge-core的错误, 那就重新弄个文件放入osmosis/lib/default文件中
osmosis/bin/osmosis --rb file=/Users/lixiang/maps/turkmenistan-latest.osm.pbf --mapfile-writer file=a.map
cd osmosis/lib/default
wget https://repo1.maven.org/maven2/org/mapsforge/mapsforge-core/0.6.1-rc2/mapsforge-core-0.6.1-rc2.jar
cd ..
# 继续尝试转换, 会出现jts的错误, 那就重新弄个文件放入osmosis/lib/default文件中
osmosis/bin/osmosis --rb file=/Users/lixiang/maps/turkmenistan-latest.osm.pbf --mapfile-writer file=a.map
cd osmosis/lib/default
wget https://downloads.sourceforge.net/project/jts-topo-suite/jts/1.14/jts-1.14.zip
unzip jts-1.14.zip
mv lib/jts-1.14.jar osmosis/lib/default
# 清除一下无用的东西
ls
rm -rf bin
rm -rf doc
rm -rf lib
rm -rf testxml
rm -rf jtsio
rm -rf 3.0.2
# 再次尝试转换,出现了guava相关错误, 那就重新弄个文件放入osmosis/lib/default文件中
osmosis/bin/osmosis --rb file=/Users/lixiang/maps/turkmenistan-latest.osm.pbf --mapfile-writer file=a.map
wget http://central.maven.org/maven2/com/google/guava/guava/22.0/guava-22.0.jar
mv guava-22.0.jar osmosis/lib/default
# 再次尝试转换成功
osmosis/bin/osmosis --rb file=/Users/lixiang/maps/turkmenistan-latest.osm.pbf --mapfile-writer file=a.map
信息如下:
file-writer file=a.map八月 01, 2017 7:55:11 下午 org.openstreetmap.osmosis.core.Osmosis run信息: Osmosis Version 0.45八月 01, 2017 7:55:11 下午 org.openstreetmap.osmosis.core.Osmosis run信息: Preparing pipeline.八月 01, 2017 7:55:12 下午 org.mapsforge.map.writer.osmosis.MapFileWriterTask信息: mapfile-writer version: mapsforge-map-writer-0.6.1-rc2八月 01, 2017 7:55:12 下午 org.mapsforge.map.writer.osmosis.MapFileWriterTask信息: mapfile format specification version: 3
八月 01, 2017 7:55:12 下午 org.openstreetmap.osmosis.core.Osmosis run
信息: Launching pipeline execution.
八月 01, 2017 7:55:12 下午 org.openstreetmap.osmosis.core.Osmosis run
信息: Pipeline executing, waiting for completion.
八月 01, 2017 7:55:12 下午 org.mapsforge.map.writer.osmosis.MapFileWriterTask process
信息: start reading data...
八月 01, 2017 7:55:15 下午 org.mapsforge.map.writer.osmosis.MapFileWriterTask complete
信息: completing read...
八月 01, 2017 7:56:25 下午 org.mapsforge.map.writer.osmosis.MapFileWriterTask complete
信息: start writing file...
八月 01, 2017 7:56:28 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 100% of sub file for zoom interval index 0
八月 01, 2017 7:56:29 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 10.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:29 下午 org.mapsforge.map.writer.util.GeoUtils clipToTile
警告: invalid geometry prior to tile clipping, trying to repair 142048828
八月 01, 2017 7:56:29 下午 org.mapsforge.map.writer.util.GeoUtils clipToTile
警告: invalid geometry even after attempt to fix 142048828
八月 01, 2017 7:56:30 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 20.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:31 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 30.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:32 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 40.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:33 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 50.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:34 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 60.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:36 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 70.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:37 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 80.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:37 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 90.0% of sub file for zoom interval index 1
八月 01, 2017 7:56:37 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 100% of sub file for zoom interval index 1
八月 01, 2017 7:57:59 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 10.0% of sub file for zoom interval index 2
八月 01, 2017 7:58:30 下午 org.mapsforge.map.writer.util.GeoUtils clipToTile
警告: invalid geometry prior to tile clipping, trying to repair 142048828
八月 01, 2017 7:58:30 下午 org.mapsforge.map.writer.util.GeoUtils clipToTile
警告: invalid geometry even after attempt to fix 142048828
八月 01, 2017 7:59:33 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 20.0% of sub file for zoom interval index 2
八月 01, 2017 8:01:50 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 30.0% of sub file for zoom interval index 2
八月 01, 2017 8:03:48 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 40.0% of sub file for zoom interval index 2
八月 01, 2017 8:06:57 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 50.0% of sub file for zoom interval index 2
八月 01, 2017 8:10:44 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 60.0% of sub file for zoom interval index 2
八月 01, 2017 8:14:11 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 70.0% of sub file for zoom interval index 2
八月 01, 2017 8:17:38 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 80.0% of sub file for zoom interval index 2
八月 01, 2017 8:17:51 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 90.0% of sub file for zoom interval index 2
八月 01, 2017 8:17:51 下午 org.mapsforge.map.writer.MapFileWriter writeSubfile
信息: written 100% of sub file for zoom interval index 2
八月 01, 2017 8:17:51 下午 org.mapsforge.map.writer.MapFileWriter writeFile
信息: JTS Geometry cache hit rate: 1.0
八月 01, 2017 8:17:51 下午 org.mapsforge.map.writer.MapFileWriter writeFile
信息: JTS Geometry total load time: 0
八月 01, 2017 8:17:51 下午 org.mapsforge.map.writer.MapFileWriter writeFile
信息: Finished writing file.
八月 01, 2017 8:17:51 下午 org.mapsforge.map.writer.osmosis.MapFileWriterTask complete
信息: finished...
八月 01, 2017 8:17:51 下午 org.mapsforge.map.writer.osmosis.MapFileWriterTask complete
信息: estimated memory consumption: 330.51MB
八月 01, 2017 8:17:51 下午 org.openstreetmap.osmosis.core.Osmosis run
信息: Pipeline complete.
八月 01, 2017 8:17:51 下午 org.openstreetmap.osmosis.core.Osmosis run
信息: Total execution time: 1360616 milliseconds.