首页 > 其他分享 >地图瓦片服务器搭建

地图瓦片服务器搭建

时间:2024-06-22 21:58:10浏览次数:12  
标签:shp water 3857 split icesheet 瓦片 服务器 polygons 搭建

文章目录


本次瓦片服务器我们主要基于OpenStreetMap-Tile-Server来做,以下是这个项目的介绍和具体操作流程

一、OpenStreetMap-Tile-Server

项目地址:https://gitcode.com/Overv/openstreetmap-tile-server
该容器基于最新的Ubuntu 18.04 LTS指南由switch2osm.org提供,允许您轻松地使用.osm.pbf文件设置OpenStreetMap PNG瓦片服务器,并采用默认的OpenStreetMap样式。
涉及的技术:Docker、OpenStreetMap、Osm2pgsql、PostgreSQL 数据库

二、OpenStreetMap地图资源下载

https://download.geofabrik.de/asia/china.html(国内可访问,本次使用国内地图,也可下载全球其他地区)
image.png

三、加载地图资源

OpenStreetMap-Tile-Server运行以及加载OpenStreetMap资源到项目中,这里是通过解析pdf文件到PostgreSql中实现,命令如下:

docker run --name osm-server-china 
-v D:\docker\osm\china-latest.osm.pbf:/data/region.osm.pbf 
-v osm-data-china:/data/database/ 
overv/openstreetmap-tile-server  import

image.png
该命令时间会长一点,底层的主要操作如下:

①移动本地osm.pbf文件到docker容器中

②解析osm.pbf文件

Node数据(约154754k),Way数据(约11620k),Relation数据(约150050B)
image.png

③创建Postgre账号:renderer,表结构创建,地图数据导入数据库

④下载地图公共资源,这里有点坑,这里详细说一下

到这一步时,OpenStreetMap-Tile-Server会自动下载一些地图公共资源的图层包,通过进入容器,查看启动脚本知道,项目中有一个external-data.yml的文件(/data/style/),内容如下:

settings:
  temp_schema: loading
  schema: public
  data_dir: data
  database: gis
  metadata_table: external_data
sources:
  simplified_water_polygons:
    # The type of file this source is
    type: shp
    # Where to get it
    url: https://osmdata.openstreetmap.de/download/simplified-water-polygons-split-3857.zip
    # The location within the archive
    file: simplified-water-polygons-split-3857/simplified_water_polygons.shp
    archive:
      format: zip
      # Files to extract from the archive
      files:
        - simplified-water-polygons-split-3857/simplified_water_polygons.cpg
        - simplified-water-polygons-split-3857/simplified_water_polygons.dbf
        - simplified-water-polygons-split-3857/simplified_water_polygons.prj
        - simplified-water-polygons-split-3857/simplified_water_polygons.shp
        - simplified-water-polygons-split-3857/simplified_water_polygons.shx
  water_polygons:
    type: shp
    url: https://osmdata.openstreetmap.de/download/water-polygons-split-3857.zip
    file: water-polygons-split-3857/water_polygons.shp
    archive:
      format: zip
      files:
        - water-polygons-split-3857/water_polygons.cpg
        - water-polygons-split-3857/water_polygons.dbf
        - water-polygons-split-3857/water_polygons.prj
        - water-polygons-split-3857/water_polygons.shp
        - water-polygons-split-3857/water_polygons.shx
  icesheet_polygons:
    type: shp
    url: https://osmdata.openstreetmap.de/download/antarctica-icesheet-polygons-3857.zip
    file: antarctica-icesheet-polygons-3857/icesheet_polygons.shp
    archive:
      format: zip
      files:
        - antarctica-icesheet-polygons-3857/icesheet_polygons.cpg
        - antarctica-icesheet-polygons-3857/icesheet_polygons.dbf
        - antarctica-icesheet-polygons-3857/icesheet_polygons.prj
        - antarctica-icesheet-polygons-3857/icesheet_polygons.shp
        - antarctica-icesheet-polygons-3857/icesheet_polygons.shx
  icesheet_outlines:
    type: shp
    url: https://osmdata.openstreetmap.de/download/antarctica-icesheet-outlines-3857.zip
    file: antarctica-icesheet-outlines-3857/icesheet_outlines.shp
    ogropts:
      - "-explodecollections"
    archive:
      format: zip
      files:
        - antarctica-icesheet-outlines-3857/icesheet_outlines.cpg
        - antarctica-icesheet-outlines-3857/icesheet_outlines.dbf
        - antarctica-icesheet-outlines-3857/icesheet_outlines.prj
        - antarctica-icesheet-outlines-3857/icesheet_outlines.shp
        - antarctica-icesheet-outlines-3857/icesheet_outlines.shx

  ne_110m_admin_0_boundary_lines_land:
    type: shp
    url: https://naturalearth.s3.amazonaws.com/110m_cultural/ne_110m_admin_0_boundary_lines_land.zip
    file: ne_110m_admin_0_boundary_lines_land.shp
    ogropts: &ne_opts
      - "--config"
      - "SHAPE_ENCODING"
      - "WINDOWS-1252"
      - "-explodecollections"
      # needs reprojecting
      - '-t_srs'
      - 'EPSG:3857'
    archive:
      format: zip
      files:
        - ne_110m_admin_0_boundary_lines_land.dbf
        - ne_110m_admin_0_boundary_lines_land.prj
        - ne_110m_admin_0_boundary_lines_land.shp
        - ne_110m_admin_0_boundary_lines_land.shx

上面代码中,sources的内容即为地图公共资源包,可能会出现本地docker环境中,链接无法访问的情况,可以通过如下两种操作处理:
1、把文件下载下来,然后本地部署web容器,通过本机ip访问,同时,需要替换url为 你的容器地址/资源名
2、本地git clone我的码云项目:https://gitee.com/1390893380/osm-tile-source.git,打包运行即可(water-polygons-split-3857.zip资源八百多兆,无法上传码云,需要自己本地下载后,放在项目的pubilc目录下,如果嫌慢的话可以用我百度云链接下载:链接:https://pan.baidu.com/s/1I6xumrlnUfsJuJReeQ0D8A 提取码:nb4k),启动成功后,替换上面yml的url为http://你的ip/资源名,如下为我替换后的样例

settings:
  temp_schema: loading
  schema: public
  data_dir: data
  database: gis
  metadata_table: external_data
sources:
  simplified_water_polygons:
    # The type of file this source is
    type: shp
    # Where to get it
    url: http://172.16.18.36:80/simplified-water-polygons-split-3857.zip
    # The location within the archive
    file: simplified-water-polygons-split-3857/simplified_water_polygons.shp
    archive:
      format: zip
      # Files to extract from the archive
      files:
        - simplified-water-polygons-split-3857/simplified_water_polygons.cpg
        - simplified-water-polygons-split-3857/simplified_water_polygons.dbf
        - simplified-water-polygons-split-3857/simplified_water_polygons.prj
        - simplified-water-polygons-split-3857/simplified_water_polygons.shp
        - simplified-water-polygons-split-3857/simplified_water_polygons.shx
  water_polygons:
    type: shp
    url: http://172.16.18.36:80/water-polygons-split-3857.zip
    file: water-polygons-split-3857/water_polygons.shp
    archive:
      format: zip
      files:
        - water-polygons-split-3857/water_polygons.cpg
        - water-polygons-split-3857/water_polygons.dbf
        - water-polygons-split-3857/water_polygons.prj
        - water-polygons-split-3857/water_polygons.shp
        - water-polygons-split-3857/water_polygons.shx
  icesheet_polygons:
    type: shp
    url: http://172.16.18.36:80/antarctica-icesheet-polygons-3857.zip
    file: antarctica-icesheet-polygons-3857/icesheet_polygons.shp
    archive:
      format: zip
      files:
        - antarctica-icesheet-polygons-3857/icesheet_polygons.cpg
        - antarctica-icesheet-polygons-3857/icesheet_polygons.dbf
        - antarctica-icesheet-polygons-3857/icesheet_polygons.prj
        - antarctica-icesheet-polygons-3857/icesheet_polygons.shp
        - antarctica-icesheet-polygons-3857/icesheet_polygons.shx
  icesheet_outlines:
    type: shp
    url: http://172.16.18.36:80/antarctica-icesheet-outlines-3857.zip
    file: antarctica-icesheet-outlines-3857/icesheet_outlines.shp
    ogropts:
      - "-explodecollections"
    archive:
      format: zip
      files:
        - antarctica-icesheet-outlines-3857/icesheet_outlines.cpg
        - antarctica-icesheet-outlines-3857/icesheet_outlines.dbf
        - antarctica-icesheet-outlines-3857/icesheet_outlines.prj
        - antarctica-icesheet-outlines-3857/icesheet_outlines.shp
        - antarctica-icesheet-outlines-3857/icesheet_outlines.shx
  ne_110m_admin_0_boundary_lines_land:
    type: shp
    url: http://172.16.18.36:80/ne_110m_admin_0_boundary_lines_land.zip
    file: ne_110m_admin_0_boundary_lines_land.shp
    ogropts: &ne_opts
      - "--config"
      - "SHAPE_ENCODING"
      - "WINDOWS-1252"
      - "-explodecollections"
      # needs reprojecting
      - '-t_srs'
      - 'EPSG:3857'
    archive:
      format: zip
      files:
        - ne_110m_admin_0_boundary_lines_land.dbf
        - ne_110m_admin_0_boundary_lines_land.prj
        - ne_110m_admin_0_boundary_lines_land.shp
        - ne_110m_admin_0_boundary_lines_land.shx

注意:上述操作后,拿到的__external-data.yml内容,需要在步骤④之前替换掉原始的external-data.yml内容
image.png
⑤结束,中国地图1G左右,加载完成后,docker中volume为osm-data-china的磁盘空间占用大概在32G
image.png

四、启动瓦片服务器

docker run  osm-server-china-tile -p 8080:80 
-v osm-data-china:/data/database -d overv/openstreetmap-tile-server run

五、访问瓦片服务器

http://localhost:8080
image.png

标签:shp,water,3857,split,icesheet,瓦片,服务器,polygons,搭建
From: https://blog.csdn.net/qq_33538365/article/details/139856576

相关文章

  • Gitlab服务器邮箱配置,实现自动为用户发送邮件(注册发送验证链接)
    一.配置前准备工作及说明服务器系统版本:CentOS7postfix,并在终端运行systemctlstatuspostfix检查服务是否已在运行状态,如果显示activate则表示正在运行[root@sage~]$systemctlstatuspostfix●postfix.service-PostfixMailTransportAgentLoaded:loaded(/......
  • springboot+vue前后端分离项目-vue项目搭建2
    1.创建springboot项目,进入https://start.spring.io生成 2.新建模块,创建Maven模块 springbootdemo模块下src和pom都删除,导入第一步新建的springboot项目 直接将src和pom都复制到springbootdemo下即可手动刷新Maven,下载依赖  3. 项目结构优化,vue和java区分,新建文件......
  • k8s集群搭建及对一些组件的简单理解(一)
    背景k8s的学习环境(用kubeadm方式搭建),我也搭过几次了,但都有点问题。要么在云服务器上弄,这个的问题是就只有一台轻量服务器,只能搭个单节点的;后来买了一台便宜的,所以就有了两台,但是不在一个zone,一个是广州,一个是成都,内网不通,感觉搭起来很麻烦,还没试过。要么是在本机的虚拟机上搞(vm......
  • 尚玩助手app对接广告模式开发源码搭建
    当涉及到“尚玩助手”这样的App对接广告模式并进行源码搭建时,你需要遵循一系列步骤来确保广告的有效集成和App的稳定运行。以下是一个基本的流程指南:1.明确需求和广告模式需求分析:明确App需要对接的广告类型(如横幅广告、插屏广告、视频广告等)和广告展示策略。广告模式选择:根......
  • 纯html如何识别.vue文件并搭建vue项目
    前言使用原生html写vue项目。注意:是项目,而不是页面,此方式是不推荐的,毕竟有脚手架,但在一些及其特殊场景下,可能会需要类似的方式,因此作为一个记录。这种方式唯一的优点就是写完可以直接扔服务器上了-_-对html写vue的认知很多人对在html中运行vue项目这种内容,认知只......
  • 【阿里云服务器】【弹性云服务ECS】通过ssh登录远程服务器
    一、操作系统使用Windows11主机上的Ubuntu子系统,如下图所示:二、云服务器登录方法需知道:服务器ip地址、登录名和自己设置的登录密码:上述系统用户名为root,需要在Ubuntu子系统中同样切换至root用户,才能正常登录:登录命令:sshxx.xx.xx.xx(服务器ip地址)然后按照提示输......
  • PHP环境搭建之使用PhpStudy
    目录1PhpStudy1.1简介1.2下载&安装1.3修改配置1.3.1Apache配置1.3.2MySQL配置1.3.3MySQL启动问题1.4Composer1.4.1简介1.4.2下载安装1.4.3修改配置1.4.4使用命令1PhpStudy1.1简介phpstudy是一个php运行环境的集成包,用户不需要去配置运行环境,就可以使用,phpstudy不......
  • 【云服务器介绍】选择指南 腾讯云 阿里云全配置对比 搭建web 个人开发 app 游戏服务器
    ​省流目录:适用于博客建站(2-4G)、个人开发/小型游戏[传奇/我的世界/饥荒](4-8G)、数据分析/大型游戏[幻兽帕鲁/雾锁王国]服务器(16-64G)1.京东云-618专属活动 官方采购季专属活动地址:京东云-618采购季服务器活动专区https://3.cn/20-J4jjX京东云又双叒降价了!活动页大改,增加两......
  • readhat8搭建SFTP双机高可用并配置Rsync数据实时同步
    环境准备:主机host-61-118:192.168.61.118host-61-119:192.168.61.119vip:192.168.61.220检测openssh版本,版本必须大于4.8.p1,否则需要升级openssh版本[root@host-61-118~]#ssh-VOpenSSH_7.4p1,OpenSSL1.0.2k-fips26Jan2017关闭防火墙systemctlstopfirew......
  • Jemter代理服务器录制脚本,优化后形成性能测试场景
    在进行性能测试(压力、负载)等,先要有对应的测试场景,比如添加功能:要先登录成功,然后调用添加接口,输入添加的内容,才可以添加成功。那么可以通过Jemter代理服务器,设置代理,打开测试的网站,录制脚本,当然,也可以根据接口文档,使用接口文档添加对应的接口形成业务测试脚本。HTPP代理服务器设置......