码迷,mamicode.com
首页 > 其他好文 > 详细

switch2osm使用open street map离线地图中文乱码方框解决办法

时间:2015-08-28 12:36:40      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:

----------written by shenwenkai-------------

ubuntu linux环境下,按照网址(https://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/提供的方式,执行至sudo /etc/init.d/renderd restart

打开http://localhost/osm/slippymap.html就可以看到样例图;但是如果不出意外,中文会出现方框,无法正常显示。

下面说明解决方法:

  • 1)安装unifont字体

sudo apt-get install unifont

  • 2)修改/etc/mapnik-osm-data/inc/fontset-settings.xml.inc的内容为:

<!--Settings for Mapnik Fonts

To see the fonts you have installed with Mapnik do:

ls `python -c "import mapnik;print mapnik.fontscollectionpath"`-->

<FontSet name="book-fonts">

  <Font face-name="unifont Medium" />

</FontSet>

<FontSet name="bold-fonts">

  <Font face-name="unifont Medium" />

</FontSet>

<FontSet name="oblique-fonts">

  <Font face-name="unifont Medium" />

</FontSet>

修改/etc/renderd.conf的内容为:

[renderd]

stats_file=/var/run/renderd/renderd.stats

socketname=/var/run/renderd/renderd.sock

num_threads=4

tile_dir=/var/lib/mod_tile ; DOES NOT WORK YET

[mapnik]

plugins_dir=/usr/lib/mapnik/2.0/input

font_dir=/usr/share/fonts/truetype/unifont

font_dir_recurse=true

 

[default]

URI=/osm/

XML=/etc/mapnik-osm-data/osm.xml

DESCRIPTION=This is the standard osm mapnik style

;ATTRIBUTION=&copy;<a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a> and <a href=\"http://wiki.openstreetmap.org/w\

iki/Contributors\">contributors</a>, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>

;HOST=tile.openstreetmap.org

;SERVER_ALIAS=http://a.tile.openstreetmap.org

;SERVER_ALIAS=http://b.tile.openstreetmap.org

;HTCPHOST=proxy.openstreetmap.org

  • 3)修改/etc/mapnik-osm-data/osm.xml的关键词,把配置文件中的FontSet name="bold-fonts"等字体集设置全部改为字符类型设置face-name="unifont Medium"。
  • 4)删除缓存文件 sudo rm -rf /var/lib/mod_tile/default/*

再次打开,中文名称应该就可以正常显示了。

附加:

可以根据如下命令的运行情况,来判断mapnik是否正确运行。

sudo su www-data

$ renderd –f

 

renderd[26014]: Rendering daemon started

renderd[26014]: Parsing section renderd

renderd[26014]: Parsing render section 0

renderd[26014]: Parsing section mapnik

renderd[26014]: Parsing section default

renderd[26014]: config renderd: unix socketname=/var/run/renderd/renderd.sock

renderd[26014]: config renderd: num_threads=4

renderd[26014]: config renderd: num_slaves=0

renderd[26014]: config renderd: tile_dir=/var/lib/mod_tile

renderd[26014]: config renderd: stats_file=/var/run/renderd/renderd.stats

renderd[26014]: config mapnik:  plugins_dir=/usr/lib/mapnik/2.0/input

renderd[26014]: config mapnik:  font_dir=/usr/share/fonts/truetype/unifont

renderd[26014]: config mapnik:  font_dir_recurse=1

renderd[26014]: config renderd(0): Active

renderd[26014]: config renderd(0): unix socketname=/var/run/renderd/renderd.sock

renderd[26014]: config renderd(0): num_threads=4

renderd[26014]: config renderd(0): tile_dir=/var/lib/mod_tile

renderd[26014]: config renderd(0): stats_file=/var/run/renderd/renderd.stats

renderd[26014]: config map 0:   name(default) file(/etc/mapnik-osm-data/osm.xml) uri(/osm/) htcp() host()

renderd[26014]: Initialising unix server socket on /var/run/renderd/renderd.sock

renderd[26014]: Created server socket 5

renderd[26014]: Renderd is using mapnik version 2.0.0

renderd[26014]: DEBUG: Loading font: /usr/share/fonts/truetype/unifont/unifont.ttf

Running in foreground mode...

renderd[26014]: Starting stats thread

switch2osm使用open street map离线地图中文乱码方框解决办法

标签:

原文地址:http://www.cnblogs.com/shenwenkai/p/4755088.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!