# 首先創(chuàng)建文件夾
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
# 下載一個(gè).pbf地圖文件
wget http://download.geofabrik.de/asia/turkmenistan-latest.osm.pbf
# 嘗試轉(zhuǎn)換崭篡, file參數(shù)是文件變量
osmosis/bin/osmosis --rb file=/Users/lixiang/maps/turkmenistan-latest.osm.pbf --mapfile-writer file=a.map
這個(gè)地方會(huì)報(bào)一個(gè)沒有mapsforge-map-writer的錯(cuò)誤
在用戶目錄下創(chuàng)建文件夾 ~/.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版本的需要進(jìn)行以下步驟:
# 重新進(jìn)入maps文件夾, 嘗試轉(zhuǎn)換,這里匯報(bào)一個(gè)trove找不到一個(gè)類的問題刻两,嘗試重新下載這個(gè)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
# 再次嘗試轉(zhuǎn)換以现, 會(huì)出現(xiàn)mapsforge-core的錯(cuò)誤, 那就重新弄個(gè)文件放入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 ..
# 繼續(xù)嘗試轉(zhuǎn)換择懂, 會(huì)出現(xiàn)jts的錯(cuò)誤喻喳, 那就重新弄個(gè)文件放入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
# 再次嘗試轉(zhuǎn)換,出現(xiàn)了guava相關(guān)錯(cuò)誤困曙, 那就重新弄個(gè)文件放入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
# 再次嘗試轉(zhuǎn)換成功
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.