xml 为OsmAnd生成最新的离线地图
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 为OsmAnd生成最新的离线地图相关的知识,希望对你有一定的参考价值。
## Install
Download [OsmAndMapCreator](http://download.osmand.net/latest-night-build/OsmAndMapCreator-main.zip) and extract.
Install `osmupdate` and `osmconvert` into path.
```
cd ~/bin
wget -O - http://m.m.i24.cc/osmupdate.c | cc -x c - -o osmupdate
wget -O - http://m.m.i24.cc/osmconvert.c | cc -x c - -lz -O3 -o osmconvert
```
## Download full map data for the first time
Download dump of China area PBF file from http://download.geofabrik.de/asia/china-latest.osm.pbf
## Create map
Put PBF file and files in this gist into working directory. In my example it's `/Users/leoliang/tmp/osm-mapbuild`.
Run `createmap.sh`. It does these steps:
1. Download latest patch to make map data up to date.
2. Generate OBF map file used by OsmAnd.
Generating full China map takes 90 minutes and output OBF file is 845M. Current script uses `-b` parameter to filter out middle Guangdong area to reduce time.
To automatically run everyday, add a cron job:
```
17 6 * * * PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/bin"; cd ~/tmp/osm-mapbuild; ./createmap.sh > /tmp/osm-mapbuild.log 2>&1
```
## Copy OBF file to Android
```
adb push China-latest_2.obf /sdcard/Android/data/net.osmand/files/
```
#!/bin/bash
set -e
# Where OsmAndMapCreator is extracted
OsmAndMapCreatorPath=/Users/LeoLiang/apps/OsmAndMapCreator
# Crop centra Guangdong: -b=111,21,115,25 (-b="x1,y1,x2,y2"). You could change to the area you want.
osmupdate --base-url=http://download.geofabrik.de/asia/china-updates/ -b=111,21,115,25 china-latest.osm.pbf china-updated.osm.pbf
mv china-updated.osm.pbf china-latest.osm.pbf
osmconvert china-latest.osm.pbf --out-statistics
dir=`pwd`
cd $OsmAndMapCreatorPath
java -Djava.util.logging.config.file=logging.properties -Xms64M -Xmx10G -cp "./OsmAndMapCreator.jar:lib/OsmAnd-core.jar:./lib/*.jar" net.osmand.data.index.IndexBatchCreator $dir/batch.xml
cd $dir
mv China-latest_2.obf Guangdong.obf
<?xml version="1.0" encoding="utf-8"?>
<batch_process>
<process_attributes mapZooms="" renderingTypesFile="" zoomWaySmoothness=""
osmDbDialect="sqlite" mapDbDialect="sqlite"/>
<!-- There are 3 subprocess :
1. Download fresh osm files from servers to 'directory_for_osm_files' (override existings).
2. Generate index files from all files in 'directory_for_osm_files' and put all indexes into 'directory_for_index_files'
3. Upload index files from 'directory_for_index_files' to googlecode.
If directory directory_for_uploaded_files is specified all uploaded files will be moved to it
All these subprocess could be ran independently ! So you can create some files check them and after that try to upload on googlecode,
or you can upload any file you have to googlecode (just put into 'directory_for_index_files')
-->
<!-- zoomWaySmoothness - 1-4, typical mapZooms - 11;12;13-14;15- -->
<process
directory_for_osm_files="/Users/leoliang/tmp/osm-mapbuild"
directory_for_index_files="/Users/leoliang/tmp/osm-mapbuild"
directory_for_generation="/Users/leoliang/tmp/osm-mapbuild"
indexPOI="true"
indexRouting="true"
indexMap="true"
indexTransport="false"
indexAddress="true">
<!-- Add wget="C:/Program Files/GNUWin32/bin/wget.exe" to process, to use wget for download.
On linux systems if wget is in your path it can be wget="wget" or you can make own script with wget command:
wget="/path/to/script/wget.sh"
Defaultly enabled parameter of wget is: &-&-read-timeout=5 that prevents hanging of download from cloudmade/geofabrik server
-->
</process>
</batch_process>
以上是关于xml 为OsmAnd生成最新的离线地图的主要内容,如果未能解决你的问题,请参考以下文章