Skip to main content

SinoTiles

自托管矢量瓦片地图服务 — PMTiles + MapLibre GL JS 一键启动,带中文模糊搜索与企业银行分析。

PyPI License

安装

pip install siontiles       # 基础安装
pip install siontiles[geo]  # 含 CNAPS 就近银行分析

特性

  • 零配置启动 — 一个脚本,浏览器打开即用
  • 外部数据目录 — PMTiles 和 POI 数据独立存放,通过 config.env 配置
  • PMTiles 矢量瓦片 — 单文件存储,支持 HTTP Range 按需加载
  • 中文模糊搜索 — Bigram Jaccard + 字符集预筛选,支持换序匹配,支持联动企业搜索
  • 13 层样式 — 道路、水系、建筑、公交站、红绿灯、收费站等
  • 联动企业图层 — 810 家企业点位,含银行距离分析,点击查看详情弹窗
  • 企业分析弹窗 — 银行机构统计、账户清单、基本户/就近/外省标签、驾车距离
  • 一键复制 Markdown — 弹窗内 📋 按钮将企业分析数据复制为 Markdown 表格
  • 暗色模式 — 🌙/☀️ 一键切换,地图、面板、弹窗、zoom 控件全适配
  • 全国 z12 图层 — 支持 Protomaps 全国高精度瓦片(z0-12),多数据源切换
  • 最近银行分析 — 非就近账户显示最近同银行网点名称和距离
  • 跨省判定修复 — 城市→省份映射表,省对省精确比较;境外企业自动识别;银行名提取城市回退
  • 国界/省界/十段线 — 省界细虚线 + 陆上国界粗实线 + 十段线粗虚线,8 大边境区域经纬度可配
  • 海岸线不画国界 — 14 个沿海省份海岸线自动剔除,land_border_zones.json 按经纬度配置
  • 自定义 POI — 独立 GeoJSON 源,GCJ-02 自动转 WGS-84
  • 185K+ 地名索引 — 搜索响应毫秒级
  • 暗色模式标签适配 — 基本户/就近/外埠标签暗底亮字

快速开始

# 1. 安装
pip install siontiles

# 2. 配置数据路径(环境变量)
export SIONTILES_PMTILES_DIR=~/path/to/pmtiles
export SIONTILES_POI_DIR=~/path/to/poi

# 3. 启动
siontiles serve
# 浏览器打开 http://localhost:8765

配置

编辑 config.env 或通过环境变量覆盖:

变量 默认值 说明
SIONTILES_PORT 8765 服务端口
SIONTILES_PMTILES_DIR ~/NutstoreFiles/8-MyData/GeoData/pmtiles PMTiles 瓦片目录
SIONTILES_POI_DIR ~/NutstoreFiles/8-MyData/GeoData/poi POI 数据目录

命令行覆盖:SIONTILES_PORT=9999 ./start.sh

目录结构

├── config.env                  # 配置文件(数据路径、端口)
├── web/
│   ├── index.html              # 前端 (MapLibre + 搜索 + 企业弹窗)
│   ├── style.json              # 地图样式(亮色)
│   ├── style-dark.json         # 地图样式(暗色)
│   ├── server.py               # HTTP 服务器 (Range + gzip + 路由映射)
│   ├── start.sh                # 启动脚本
│   ├── search_index.json.gz    # 预构建搜索索引 (~2.6MB)
│   ├── convert_poi.py          # POI 坐标转换 (GCJ-02→WGS-84)
│   └── dedup_enterprise.py     # 企业数据去重修复工具
│
├── $SIONTILES_PMTILES_DIR/     # ← 外部 PMTiles 目录
│   └── *.pmtiles
│
└── $SIONTILES_POI_DIR/         # ← 外部 POI 目录
    ├── custom-poi_wgs84.geojson      # 自定义 POI (WGS-84)
    ├── geo_enterprise_wgs84.geojson  # 企业分析数据 (WGS-84)
    └── geo_bank_branch_wgs84.geojson # 银行网点原始数据 (WGS-84)

Server 内部路由:

  • /pmtiles/* → $SIONTILES_PMTILES_DIR
  • /poi/* → $SIONTILES_POI_DIR
  • 其他 → web/

技术栈

组件 方案
瓦片格式 PMTiles v4
地图渲染 MapLibre GL JS v4.7
HTTP 服务 Python 3 (Range + gzip)
搜索算法 Bigram Jaccard 相似度
坐标转换 GCJ-02 → WGS-84 (内置)
企业分析 Parquet → GeoJSON (Haversine + 驾车距离)

企业数据更新

# 1. 重建企业分析(需要 Excel 司库账户数据 + 高德 API Key)
cd ~/NutstoreFiles/8-MyData/GeoData/poi
python3 rebuild_bank_analysis.py

# 2. 复制为 server 读取的文件名
cp geo_enterprise_analysis_wgs84.geojson geo_enterprise_wgs84.geojson
gzip -k -f geo_enterprise_wgs84.geojson

# 3. 去重 + 修复 n_nearest
cd /path/to/SionTiles/web
python3 dedup_enterprise.py

# 4. CNAPS 就近分析(标记 isNearestBranch,自动验证)
cd /path/to/SionTiles
python scripts/update_bank_branches.py

# 5. 部署到现网(脚本运行后会提示具体命令)
cp geo_enterprise_wgs84.geojson geo_enterprise_wgs84.geojson.backup-$(date +%Y%m%d)
cp geo_enterprise_updated_wgs84.geojson geo_enterprise_wgs84.geojson

License

MIT

Metadata

Release files for siontiles 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for siontiles 0.3.1
File Size Uploaded Provenance Actions
siontiles-0.3.1.tar.gz 3.0 MB Without provenance Details for siontiles-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for siontiles 0.3.1
File Interpreter ABI Platform Actions
siontiles-0.3.1-py3-none-any.whl Python 3 none any Details for siontiles-0.3.1-py3-none-any.whl

Total release size: 6.1 MB

Release files / siontiles-0.3.1.tar.gz

Download URL siontiles-0.3.1.tar.gz
Size 3.0 MB
Tags Source
SHA-256 checksum
How to use checksums
851cd68f996403d4d7478719d766517f57e7ba773cdcbcf396cc16ee6acbca77
BLAKE2b-256 checksum
How to use checksums
927a3694b0b5bfd9acaad1ce57fd20f7ca8de769a59d76e7f967e0c5a8cc0040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / siontiles-0.3.1-py3-none-any.whl

Download URL siontiles-0.3.1-py3-none-any.whl
Size 3.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b69459f485bfd180cbc4b227ba039ee17d5d833bf60ef6a5661d29a781077334
BLAKE2b-256 checksum
How to use checksums
e60abc91904c48a8a5b7568a6435f5d23c6a458bc16d01b84b8ede9144e138c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for siontiles 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page