SWITCH2OSM

切换到OPENSTREETMAP

丰富的数据

OpenStreetMap数据丰富而详细,包含与实地人相关的大量数据 - 收集的数据。

功能包括:

  • 道路,铁路,水路等
  • 餐厅,商店,车站,自动取款机等。
  • 步行和自行车道。
  • 建筑物,校园等
  • 为什么要开关?
  • 实例探究
  • 基础
  • 使用瓷砖
  • 服务瓷砖
  • 其他用途
  • 供应商
  • 了解更多

从包中构建瓦片服务器

如果你想建立自己的瓦片服务器,使用软件包可以节省大量的安装工作。

这些软件包与Ubuntu Linux版本12.04 LTS(精确穿山甲)及以上版本配合使用。安装完成后,您应该使用标准的OSM Mapnik样式表使用自己的工作tileer,您可以在其中导入OSM数据的提取以进行渲染。

它基于OSM自己的瓦片服务器使用的相同的软件:

  • mod_tile用于服务
  • renderd作为渲染守护进程
  • mapnik为实际渲染

这些软件包的主要目的是通过将包装脚本尽可能多的自动化来简化安装。

安装

需要将以下命令输入终端进行设置:

如果您没有安装add-apt-repository,请将其添加到:

对于Ubuntu 12.04

sudo apt-get install python-software-properties

对于Ubuntu 12.10及更高版本

sudo apt-get安装软件属性常见
添加包含包的存储库:
sudo add-apt-repository ppa:kakrueger / openstreetmap

更新本地软件包列表以获取新的存储库:

sudo apt-get更新

安装软件包libapache2-mod-tile及其依赖项。在配置过程中,会询问几个问题。要确保自动安装脚本可以工作,您应该保留默认值。但是,在关于数据库用户的权限的问题中,您希望在用户之后添加自己的用户名,该数据由空格分隔,以便能够在用户下导入数据。

sudo apt-get install libapache2-mod-tile

导入地图数据

下载要渲染的OpenStreetMap数据(完整的行星文件可以在planet.openstreetmap.org上找到,国家提要可以在例如download.geofabrik.de上找到)。例如:

wget http://download.geofabrik.de/europe/ireland-and-northern-ireland-latest.osm.pbf

使用osm2pgsql将数据导入到postgresql数据库中。osm2pgsql可以使用许多不同的参数,这些参数取决于您可用的硬件和要导入的数据提取的大小。您需要设置的最有可能的是“-C”,“-slim”和“ - 数字处理”。-C指定Mb osm2pgsql将用于缓存数据的数量。所以这取决于你可用的RAM的数量。-slim将完整的osm数据保存在磁盘上,是更新和低内存环境所必需的。-number-processes指定用于导入过程的某些部分的并行进程数。最佳值主要取决于磁盘系统的速度和可用的处理器内核。

osm2pgsql --slim -C 1500  - 数字处理4 ireland-and-northern-ireland.osm.pbf

根据您正在导入的提取物的大小和计算机的性能,对于小型提取物,可能需要几分钟的时间才能在较慢的硬件上完成行星的几分钟。如果您正在导入完整的行星,强烈建议您设置-C 18000(18 GB的RAM缓存,并随着OSM数据库的增长而增加)。如果您没有足够的内存量,这可能会导致您的服务器在导入期间进行交换,但在许多情况下,它仍然比为节点缓存使用较小的值更快。但是,您需要确保已配置足够的交换内存。

如果要导入完整的行星文件,您可能还需要使用-flat-nodes选项。它为某些数据而不是postgis数据库使用自定义格式文件,使其更有效率,但对区域提取效率较低。在导入期间临时更改PostgreSQL配置也可能是有意义的。(例如,增加检查点数量,减少共享缓冲区大小。)

导入时间的大部分以及数据库的大小都用于创建索引以跟踪更新。如果您不打算使数据库连续不间断地使用“差异文件”,则可能需要使用-drop选项导入数据,该  选项将在导入后删除“slim-tables”,而不需要渲染并且不创建仅需要支持差异导入的索引。一旦您每1 - 2周更频繁地更新一次,可能会更有效地每次完成重新导入,而不是使用更新。

mod_tile旨在始终提供最新的图块(见下文更新)。由于在更改时重新渲染所有已更改的图块通常是不可行的,因此mod_tile会在投放时启动重新渲染过时的图块。这样的mod_tile需要知道什么时候行星被导入。这是通过更改文件planet-import-complete的时间戳来完成的

触摸/ var / lib / mod_tile / planet-import-complete

最后,您需要重新启动渲染守护程序,之后所有应该准备好。

sudo /etc/init.d/renderd重启

如果一切正常,您应该有一个工作的tileerver,您可以通过访问http://localhost/osm/slippymap.html查看其结果

如果您没有在本地主机上打开slippymap.html,并且您只看到粉红色的图块,则需要编辑html页面,并将localhost替换为“new OpenLayers.Layer.Layer.SMM(”Local Tiles“...”)中正确的服务器名称,或将其更改为相对URL。

更新

以下命令说明如何使用最新的OSM数据来保持瓷砖服务器的最新版本。

使用上述osm2pgsql导入初始数据库之后(您将需要在初始导入中使用-slim选项以允许更新),则需要执行以下步骤

安装渗透

sudo apt-get安装渗透

授予用户www数据更新表的权限

sudo /usr/bin/install-postgis-osm-user.sh gis www-data

将渗透复制堆栈初始化为数据导入的数据。选择行星数据的日期,因为这是差异开始的日期。

sudo -u www-data /usr/bin/openstreetmap-tiles-update-expire 2012-04-21

As the packaged script currently uses an outdated service to determine the correct replication start-point, you will need to manually choose and download the correct state.txt from the base_url (see below) which corresponds to slightly before the age of the extract to make sure all modifications are included in your db. This needs to be copied to /var/lib/mod_tile/.osmosis/state.txt

You will next need to update the default configuration of osmosis. In /var/lib/mod_tile/.osmosis/configuration.txt change the base_url to
“http://planet.openstreetmap.org/replication/minute/”

Update your tileserver by up to an hour and expire the corresponding rendered tiles

sudo -u www-data /usr/bin/openstreetmap-tiles-update-expire

If your tile server is behind more than an hour you will need to call the openstreetmap-tiles-expire script multiple times. If you want to continuously keep your server up to data, you need to add the openstreetmap-tiles-expire script to your crontab.

Keeping the data up-to-date can be resource intense, in particular because after the import you may already be multiple days behind. Consider changing maxInterval in /var/lib/mod_tile/.osmosis/configuration.txt to 21600 (six hours) till you have caught up. Further, add “–number-processes 2” to the osm2pgsql command in /usr/bin/openstreetmap-tiles-update-expire or a higher number if this is appropriate for your hardware.

The initial install installed pre-processed coastlines, from time to time it may make sense to replace the files with new versions:

wget http://tile.openstreetmap.org/processed_p.tar.bz2

and extract it to

/etc/mapnik-osm-data/world_boundaries/

Troubleshooting

There are a number of things that can go wrong. Here are a few of the common problems and there solutions:

Connection to database failed in osm2pgsql

If you are getting the following error message when importing data with osm2pgsql, you have probably forgotten to add your username in the allowed users section during the configuration. Connection to database Failed: FATAL: Ident authentication failed for user “xyz”

You can fix this in one of two ways:

Either you reconfigure the package, this time including both www-data and your own user name in a space separated list,

sudo dpkg-reconfigure openstreetmap-postgis-db-setup

Or, you manually grant permissions to your user account with the following command:

sudo /usr/bin/install-postgis-osm-user.sh gis xyz

Hardware

Hardware requirements can be quite demanding if you want to render larger areas, but aren’t too bad if you are only interested in smaller regions. For a standard desktop (approximately 4 GB of ram, standard harddisk, dual – quad core CPU) probably an extract size of about 100 – 300 Mb is reasonable (import time of the order of an hour).

If you want to import and render the whole world, you will need a considerably beefier server than a typical desktop. E.g. starting from about 24Gb of RAM upwards. It is also strongly recomend to use an SSD for the database or at least a fast RAID array. The full planet import is currently around about 256GB, so to store all of the DB on an SSD, you will likely need a 512GB SSD. An import that is not updated and uses the –drop option on the otherhand likely still fits on a 256GB SSD. You can also selectively put the most important parts of the database on an SSD and the rest on slower disks. Osm2pgsql supports using separate tablespaces for different parts of the database for this purpose.

FAQ

Where are the various files (DB / Tiles, etc.) ?

  • Style sheets and coastlines are in /etc/mapnik-osm-data
  • Tiles are in /var/lib/mod_tile
  • Renderd configuration in /etc/renderd.conf
  • mod_tile configuration in /etc/apache2/sites-available/tileserver_site
  • Scripts are in /usr/bin
  • Database configuration is in /etc/postgresql/X.X/main (where X.X is the PostgreSQL version, for example 9.1)
  • osm2pgsql configuration and state.txt is in /var/lib/mod_tile/.osmosis

How do I pre-render tiles ?

You can use render_list to pre-render tiles:

Usage: render_list [OPTION] ...-a, --all render all tiles in given zoom level range instead of reading from STDIN-f, --force render tiles even if they seem current-m, --map=MAP render tiles in this map (defaults to 'default')-l, --max-load=LOAD sleep if load is this high (defaults to 5)-s, --socket=SOCKET unix domain socket name for contacting renderd-n, --num-threads=N the number of parallel request threads (default 1)-t, --tile-dir tile cache directory (defaults to '/var/lib/mod_tile')-z, --min-zoom=ZOOM filter input to only render tiles greater or equal to this zoom level (default is 0)-Z, --max-zoom=ZOOM filter input to only render tiles less than or equal to this zoom level (default is 18)

If you are using –all, you can restrict the tile range by adding these options:

 -x, --min-x=X minimum X tile coordinate-X, --max-x=X maximum X tile coordinate-y, --min-y=Y minimum Y tile coordinate-Y, --max-y=Y maximum Y tile coordinate

Without –all, send a list of tiles to be rendered from STDIN in the format X Y Z, e.g.

0 0 1
0 1 1
1 0 1
1 1 1

The above would cause all 4 tiles at zoom 1 to be rendered

Note that you have to set –socket=/var/run/renderd/renderd.sock

Acknowledgements

感谢Kai Krueger维护包装和准备文件。

  •   英语

搜索

链接

  • OpenStreetMap的
  • OSM数据下载(planet.osm)
  • OSM基金会

©2013 OpenStreetMap和贡献者,CC-BY-SA。
由皮科摩设计。技术支持WordPress的。

从包中构建瓦片服务器相关推荐

  1. aws lambda_我如何在一天内在Node.js中构建无服务器的AWS Lambda Twitter机器人

    aws lambda Have you ever wanted to create a Twitter Bot? It's been on my list of things to do for qu ...

  2. ktor框架用到了netty吗_教你如何构建异步服务器和客户端的 Kotlin 框架 Ktor

    Ktor 是一个使用 Kotlin 以最小的成本快速创建 Web 应用程序的框架. Ktor 是一个用于在连接系统(connected systems)中构建异步服务器和客户端的 Kotlin 框架. ...

  3. web服务器中启用作业储存_如何在Kubernetes中启用无服务器计算

    web服务器中启用作业储存 在本系列的前两篇文章中,介绍了在开放源代码平台上使用无服务器平台的过程,我介绍了如何开始使用无服务器平台,以及如何使用流行的语言编写函数以及如何在Apache OpenWh ...

  4. android 加固服务器,Python 脚本构建Android APK 自动加固、打渠道包并上传服务器

    Python 脚本构建Android APK 自动加固.打渠道包并上传服务器 常规流程 打出原始apk 使用乐固工具加固并打出响应渠道包 将生成的渠道包上传对应服务器,生成推广链接 因为每一步都需要人 ...

  5. jar包升级部署到服务器详细流程,将服务部署在linux中

    假设你已经准备好以下东西,即可进行服务部署 一台服务器(云服务器或虚拟机皆可) 已安装好的jdk 1.8 + 的环境(可自行百度) 打好的jar包(maven打jar包) 1. 在服务器中新建好你的项 ...

  6. R语言使用party包中的ctree函数构建条件推理决策树的流程和步骤、条件推理决策树是传统决策树的一个重要变体、条件推理树的分裂是基于显著性测试而不是熵/纯度/同质性度量来选择分裂

    R语言使用party包中的ctree函数构建条件推理决策树的流程和步骤(Conditional inference trees).条件推理决策树是传统决策树的一个重要变体.条件推理树的分裂是基于显著性 ...

  7. R语言使用party包中的ctree函数构建条件推理决策树(Conditional inference trees)、使用plot函数可视化训练好的条件推理决策树、条件推理决策树的叶子节点的阴影区域表

    R语言使用party包中的ctree函数构建条件推理决策树(Conditional inference trees).使用plot函数可视化训练好的条件推理决策树.条件推理决策树的叶子节点的阴影区域表 ...

  8. R语言构建回归模型并进行模型诊断(线性关系不满足时)、进行变量变换(Transforming variables)、使用car包中的boxTidwell函数对预测变量进行Box–Tidwell变换

    R语言构建回归模型并进行模型诊断(线性关系不满足时).进行变量变换(Transforming variables).使用car包中的boxTidwell函数对预测变量进行Box–Tidwell变换 目 ...

  9. R语言e1071包中的支持向量机:构建nu-classification类型的支持向量机SVM并分析不同nu值惩罚下模型分类螺旋线型(sprials)线性不可分数据集的表现

    R语言e1071包中的支持向量机:构建nu-classification类型的支持向量机SVM并分析不同nu值惩罚下模型分类螺旋线型(sprials)线性不可分数据集的表现 目录

最新文章

  1. 物联网兴起 嵌入式系统安全日益受关注
  2. matlab e 精确到,matlab中用0.618法求minf(x)=e^(-x)+x^2在区间(0,1)上的极小值,精确到0.03....
  3. 程序员保值的五个关键点
  4. 表单的增 删 改 查
  5. PyQt4 的事件与信号 -- 发射信号
  6. libSVM + VS2013 + C++使用介绍
  7. PHP查询文件扩展名
  8. 第九章(三)多阶段决策问题
  9. orange软件使用
  10. NV 3D Vision
  11. Vue+Less换肤方案
  12. 苹果vs剪辑下载_Vlog教程 | 如何在手机剪辑app中添加自己的音乐?
  13. android开发接口调用,Android开发中webService接口调用示例
  14. android 环信录音,环信音视频插件
  15. 微信小程序药店管理系统+后台管理系统|前后分离VUE
  16. Android利用谷歌地图获取并解析经纬度对应的地理位置
  17. 京东、快手及其他小公司Android面试(2020)
  18. IE8兼容性问题及解决方案
  19. 搞定调度算法只需三分钟
  20. 2M口、电口、以太网电口、以太网光口的区别

热门文章

  1. linux的搜索和时间
  2. 在Codeigniter框架中使用NuSOAP
  3. 存款惊人_如何使您的图快速美丽惊人
  4. 流式数据分析_流式大数据分析
  5. 使用K-Means对美因河畔法兰克福的社区进行聚类
  6. 莫烦Pytorch神经网络第二章代码修改
  7. 深入理解InnoDB(1)—行的存储结构
  8. Mybatis—注解开发
  9. 缺失值和异常值的识别与处理_识别异常值-第一部分
  10. 钉钉设置jira机器人_这是当您机器学习JIRA票证时发生的事情