Giter VIP home page Giter VIP logo

vector_tile_download_parser's Introduction

遥感影像地图自动下载工具使用说明

本工具特点

  • 根据按行政区划范围下载瓦片
  • 支持谷歌、天地图、矢量切片,以及各类 x={x}&y={y}&z={z} 形式的瓦片
  • 支持标准 Mapbox 瓦片信息解析

一、硬件准备

  • 能够运行用印象地图下载工具的设备一台。
  • 数据库和下载工具可分开为两个服务器部署,也可放在一起。
  • 操作系统,Windows 和 Linux 均可。

二、系统环境准备

(一)MongoDB 数据库部署

具体步骤略,请自行部署 MongoDB 数据库。 版本无限制,近期可用版均可。

(二) PostgreSQL+PostGIS 数据库部署

具体步骤略,请自行部署 PostgreSQL+PostGIS 数据库。 版本:8.x 以后版本均可。

(三) Nodejs 环境准备

具体步骤略,请自行部署 Nodejs 运行环境。 版本请使用 LTS 版,8.xLTS、10.xLTS、12.xLTS 均可。

(四) Python 环境准备

具体步骤略,请自行部署 Python 运行环境。 版本为:Python3.6 及更新 3.x 版本。

三、 影像下载工具代码部署

(一) Nodejs 代码部署

1、 安装 Node 项目依赖包

联网状态下,执行以下命令:

cd vector_tile_download_parser
npm i

如果下载速度慢,可切换为国内源:

npm config set registry https://registry.npm.taobao.org
# 配置后可通过下面方式来验证是否成功
npm config get registry
# 或npm info express

2、 谷歌或天地图瓦片连接信息配置

config/config.default.js 中配置相关瓦片地址信息,如果需要下载天地图,请注册天地图并使用 服务端 token。

//config/config.default.js
const userConfig = {
  tile_urls: {
    google_image: `http://ditu.google.cn/maps/vt/lyrs=s&x={x}&y={y}&z={z}`, //谷歌影像地址
    tdt_image: `https://t1.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=tianditu_token`, //天地图地址
    vector_tile: `http://mvt_host/{z}/{x}/{y}.pbf`, //矢量切片地址
  },
};

3、配置 Python 瓦片计算服务连接信息

//config/config.default.js
const userConfig = {
  python_cover_host: "http://127.0.0.1:5004",
};

4、 配置数据库连接信息

//config/config.default.js
const userConfig = {
    mongo_config: "mongodb://127.0.0.1:27017/vector_tile",
    sequelize: {
      dialect: "postgres",
      host: "127.0.0.1",
      port: 5432,
      database: "quhua_data",
      username: "postgres",
      password: "postgres",
    }
}

5、启动服务

npm start //正式启动
npm run debug //以调试模式启动,可查看输出

6、服务部署测试

访问以下地址,测试能否正常返回内容。

http://127.0.0.1:7001/

(二) Python 代码部署

1、安装 Python 依赖包

联网状态下,执行以下命令,安装 Python 依赖包:

cd vector_tile_download_parser
pip install -r requirements.txt

2、配置数据库连接信息

# cover_server.py
SQLALCHEMY_DATABASE_URI = 'postgres+psycopg2://postgres:[email protected]/quhua_data' #PostgreSQL数据库连接
myclient = pymongo.MongoClient("mongodb://127.0.0.1:27017/tile_downloader") #MongoDB数据库连接

3、区划边界数表名称配置

quhuaTable = 'data_xian'
if len(area_code) == 6:
    quhuaTable = "data_xian" # 县边界
elif len(area_code) == 4:
    quhuaTable = "quhua_shi"  # 市边界
elif len(area_code) == 2:
    quhuaTable = "quhua_sheng"  # 省边界

4、启动服务

python cover_server.py

6、服务部署测试

访问以下地址,测试能否正常返回内容。

http://127.0.0.1:5004/

四、 区划数据准备

(一)在 PostGIS 中导入区划边界数据

导入带有区划代码的区划编辑数据,并且区划代码字段名称为:code

区划边界数据命名规则:

"data_xian" # 县边界
"quhua_shi"  # 市边界
"quhua_sheng"  # 省边界

如果不符合规则,可在上述 Python 代码中修改。

五、 使用说明

(一)指定下载范围

以下载海淀区范围内的14级谷歌 遥感影像为例,:

  • area_code110108
  • 下载级别为 14
  • 下载内容为:google_image,需要与上述第三章中配置的信息一致。
  • tile_type 是指下载的是影像还是矢量
http://127.0.0.1:7001/cover?area_code=110108&zoom=14&collection=google_image&tile_type=image

以上命令执行后,会在 MongoDB 数据库中创建名字为 google_image 的表(collection)。

(二)开启下载任务

以上述准备的下载任务为例,访问以下地址即可开启下载任务:

  • 下载的 collection 为:google_image,需要与上述创建任务的 collection 一致。
http://127.0.0.1:7001/start_download?collection=google_image

以上命令执行后会自动下载未下载的影像,直到所有下载任务完成。

(三)调用下载的地图服务

以上瓦片下载完成后,可对下载的瓦片调用,使用 QGIS 等工具查看预览,配置内容如下:

http://127.0.0.1:7001/wmts?collection=google_image&x={x}&y={y}&z={z}

vector_tile_download_parser's People

Contributors

wucangeo avatar liii18 avatar

Stargazers

小小冰绿豆 avatar  avatar bardStar avatar  avatar PaoPao avatar  avatar YoungHappy avatar

Watchers

James Cloos avatar

Forkers

kgloveyou lasx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.