Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion cnmaps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
except ModuleNotFoundError:
pass

__version__ = "2.0.1"
__version__ = "2.1.0"

if cartopy is not None:
CARTOPY_DIGIT_VERSION = re.match(r"(\d*\.\d*\.\d*)", cartopy.__version__).group(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ If the user is mixing `cnmaps` with scientific Python or GIS tooling and the res
- `geometry` is only exposed as `geometry`. Do not invent a Chinese alias for it.
- With `engine="geopandas"`, `get_adm_maps` returns a `GeoDataFrame`.
- With `only_polygon=True`, `get_adm_maps` returns `MapPolygon` objects instead of records.
- Official data is now provided by `cnmaps-data`, and `cnmaps` expects `cnmaps-data>=1.1.1`.
- Official data is now provided by `cnmaps-data`, and `cnmaps` expects `cnmaps-data>=1.1.2`.

## Centroid And Labeling Workflow

Expand Down
8 changes: 0 additions & 8 deletions cnmaps/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from math import sqrt, fabs, sin, atan2, cos

import numpy as np
from numba import jit


X_PI = np.pi * 3000.0 / 180.0
Expand All @@ -32,7 +31,6 @@
EER = 0.00669342162296594323 # 偏心率平方


@jit(nopython=True)
def transform(lon: float, lat: float):
"""计算坐标偏移模型中的 `(delta_lon, delta_lat)`。

Expand Down Expand Up @@ -68,7 +66,6 @@ def transform(lon: float, lat: float):
return nlon, nlat


@jit(nopython=True)
def gcj02_to_bd09(lon: float, lat: float) -> tuple:
"""火星坐标系 (GCJ-02) 转百度坐标系 (BD-09)。

Expand All @@ -86,7 +83,6 @@ def gcj02_to_bd09(lon: float, lat: float) -> tuple:
return bd_lon, bd_lat


@jit(nopython=True)
def bd09_to_gcj02(lon: float, lat: float) -> tuple:
"""百度坐标系 (BD-09) 转火星坐标系 (GCJ-02)。

Expand All @@ -106,7 +102,6 @@ def bd09_to_gcj02(lon: float, lat: float) -> tuple:
return gcj_lon, gcj_lat


@jit(nopython=True)
def wgs84_to_gcj02(lon: float, lat: float) -> tuple:
"""WGS84 转 GCJ-02(火星坐标系)。

Expand All @@ -131,7 +126,6 @@ def wgs84_to_gcj02(lon: float, lat: float) -> tuple:
return gcj_lon, gcj_lat


@jit(nopython=True)
def gcj02_to_wgs84(lon: float, lat: float) -> tuple:
"""GCJ-02(火星坐标系)转 WGS84。

Expand Down Expand Up @@ -159,7 +153,6 @@ def gcj02_to_wgs84(lon: float, lat: float) -> tuple:
return new_lon, new_lat


@jit(nopython=True)
def bd09_to_wgs84(lon: float, lat: float) -> tuple:
"""百度坐标系 (BD-09) 转 WGS84。

Expand All @@ -174,7 +167,6 @@ def bd09_to_wgs84(lon: float, lat: float) -> tuple:
return gcj02_to_wgs84(lon, lat)


@jit(nopython=True)
def wgs84_to_bd09(lon: float, lat: float) -> tuple:
"""WGS84 转百度坐标系 (BD-09)。

Expand Down
5 changes: 2 additions & 3 deletions cnmaps/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from shapely import wkb
from shapely.strtree import STRtree
import fiona
import geojson
import orjson

try:
Expand Down Expand Up @@ -606,8 +605,8 @@ def to_file(
feature = mapping(self)
feature.update({"properties": meta})

with open(savefp, "w") as f:
geojson.dump(feature, f)
with open(savefp, "wb") as f:
f.write(orjson.dumps(feature))

def maskout(self, lons: np.ndarray, lats: np.ndarray, data: np.ndarray):
"""
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
author = "Clarmy"

# The full version, including alpha/beta/rc tags
release = "2.0.1"
version = "2.0.1"
release = "2.1.0"
version = "2.1.0"

# -- General configuration ---------------------------------------------------

Expand Down
17 changes: 16 additions & 1 deletion docs/source/content/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
版本日志
===========

2.1.0
-------
*发布日以 PyPI 为准。*

* **版本与数据依赖**:主包版本提升到 ``2.1.0`` ,并将官方数据包依赖提升到 ``cnmaps-data>=1.1.2`` 。
* **行政区记录增强**:``get_adm_maps`` 返回的 ``MapRecord`` 现在显式提供 ``longitude`` / ``latitude`` 中心点坐标字段,便于直接做标注、打点和文本放置;相关文档、示例和技能说明同步补全。
* **多名称批量筛选**:``get_adm_maps`` / ``get_adm_names`` 支持在同一 ``level`` 下使用 ``province`` / ``city`` / ``district`` / ``country`` 的多值筛选,一次查询可返回多个精确命名对象,但仍不支持在单次调用中混合 ``国`` / ``省`` / ``市`` / ``区县`` 层级。
* **命令行工具扩展**:新增 ``cnmaps export`` 子命令,可直接按照接近 ``get_adm_maps`` 的筛选规则导出 GeoJSON / Shapefile;文档新增独立“命令行工具”章节,并补充 CLI 相关测试。
* **外部边界规范与校验**:新增 ``validate_boundary_file(...)``、``read_boundary_file(...)`` 和 ``cnmaps check-boundary`` ,为自定义 GeoJSON / Shapefile 接入 ``MapPolygon`` 工作流提供统一的 boundary spec、校验入口与读取入口。
* **绘图裁剪能力扩展**:新增 ``clip_streamplot_by_map(...)`` 与 ``clip_imshow_by_map(...)`` ,分别支持对 ``streamplot`` 流线图和 ``imshow`` 图像对象(包括 hillshade)按行政区边界裁剪。
* **EPS / PS 导出经验沉淀**:新增“常见问题”文档,记录复杂边界裁剪后导出 ``EPS`` / ``PS`` 可能失效的场景,并补充 ``simplify=True`` 的 workaround 与相关技能说明。
* **AI Skill 体系上线**:主包内置 bundled skill 结构,支持通过 ``cnmaps install-skill`` 安装到 Codex、Cursor、Claude Code 等助手环境;同时补充共享 references / examples,使 AI 更稳定地理解 ``cnmaps`` 的查询、绘图、裁剪、遮罩、导出与能力边界。
* **依赖清理**:移除了仅用于坐标转换加速的 ``numba`` 运行时依赖,并清理了未实际使用的 ``geojson`` 依赖。
* **文档与示例重构**:整体刷新 README 与 Sphinx 文档,新增 CLI、FAQ、数据来源、国家中心点、世界地图与能力边界等内容,补充大量静态示例图和可运行示例脚本,并统一本地文档构建脚本。

2.0.1
-------
*发布日以 PyPI 为准。*

* **数据依赖约束**:将官方数据包依赖明确收紧为 ``cnmaps-data>=1.1.1``,确保国家级边界、``iso3`` 查询和最新争议地区处理规则能够稳定生效。
* **性能测试**:重构 benchmark 项目与性能页面统计口径,避免将不同 workload 的历史曲线混在同一条线上。
* **性能优化**:对 ``maskout`` / ``make_mask_array`` 的核心路径进行了针对性优化,改善重复网格计算场景下的性能表现。
* **Python / CI**:项目 Python 版本范围更新为 ``>=3.9,<3.13``,主 CI 覆盖 Python 3.9–3.12 与 macOS / Ubuntu / Windows;绘图测试统一使用 ``MPLBACKEND=Agg``,依赖安装步骤增加自动重试以减少网络抖动导致的偶发失败。
* **测试与文档**:补齐国家级查询、文档示例和性能测试用例的查询口径,使其与 ``cnmaps-data`` 拆分后的语义保持一致。

2.0.0
Expand All @@ -18,7 +34,6 @@
* **数据提供者机制**:运行时默认通过已安装的 ``cnmaps-data`` 或兼容 ``cnmaps.data_providers`` entry point 协议的第三方数据包提供数据,不再回退到仓库内置数据目录。
* **Shapely 2.0**:本版本最重要的变更是将依赖与实现全面对齐 Shapely 2.x(``pyproject.toml`` 中为 ``shapely>=2.0.0``),在保留 ``MapPolygon`` 等既有 API 的前提下,消除此前与 Shapely 2.0 迁移相关的兼容性问题;该项变更对应 `Issue 106 <https://github.com/cnmetlab/cnmaps/issues/106>`_。
* **Cartopy 兼容**:绘图裁剪逻辑同时兼容新版 ``cartopy.mpl.path.shapely_to_path`` 与旧版 ``cartopy.mpl.patch.geos_to_path``,并适配新的 ``GeoContourSet`` 接口。
* **Python / CI**:项目 Python 版本范围更新为 ``>=3.9,<3.13``,主 CI 覆盖 Python 3.9–3.12 与 macOS / Ubuntu / Windows;绘图测试统一使用 ``MPLBACKEND=Agg``,依赖安装步骤增加自动重试以减少网络抖动导致的偶发失败。
* **性能**:对样例数据加载、GeoJSON 读取、行政区查询与 ``MapPolygon`` 内部重复多边形清理进行了缓存和热点优化,全量测试耗时显著下降。
* 文档:安装说明、贡献者指南、API 参考等与当前工程及 CI 同步(Python/NumPy/Shapely 约束、GitHub Actions、函数签名与返回行为等)。

Expand Down
2 changes: 1 addition & 1 deletion docs/source/content/contributor-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ cnmaps 的文档(当前 Sphinx 工程)源码位于主仓库的 ``docs/`` 目
-----------
主分支与 Pull Request 使用 **GitHub Actions**,主要包括:

* ``python-package.yml`` :在 macOS / Ubuntu / Windows 上对 Python ``3.9–3.12`` 执行 flake8,并运行主单元测试。工作流统一设置 ``MPLBACKEND=Agg`` ,以避免不同平台图形后端差异影响绘图测试。
* ``python-package.yml`` :在 macOS / Ubuntu / Windows 上对 Python ``3.9–3.14`` 执行 flake8,并运行主单元测试。工作流统一设置 ``MPLBACKEND=Agg`` ,以避免不同平台图形后端差异影响绘图测试。
* ``perf-test.yml`` :在 Ubuntu、Python ``3.9`` 上对 ``tests/test_perf.py`` 运行带 **pytest-benchmark** 与 **memray** 的测试,并将基准结果推送到 ``gh-pages`` ;随后对主测试文件运行 **pytest-cov** 并通过 Codecov 上传覆盖率(需仓库配置 ``CODECOV_TOKEN`` )。依赖安装步骤带自动重试,以降低网络抖动导致的偶发失败。
* ``pypi-publish.yml`` :在发布 Release 时向 PyPI 发布。

Expand Down
2 changes: 1 addition & 1 deletion docs/source/content/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
安装
=====

**Python 版本**:需要 **Python 3.9 及以上、3.13 以下**。项目根目录 :file:`pyproject.toml` 中 ``python`` 字段为 ``>=3.9`` 且 ``<3.13`` (与 PyPI 元数据一致;详见 `PyPI <https://pypi.org/project/cnmaps/>`_)。
**Python 版本**:需要 **Python 3.9 及以上**。项目根目录 :file:`pyproject.toml` 中 ``python`` 字段为 ``>=3.9`` (当前不对 Python 3 的上限做额外限制;详见 `PyPI <https://pypi.org/project/cnmaps/>`_)。

**多平台**:本项目已在 macOS、Linux、Windows 等环境经过测试,可在上述平台正常使用。

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
channels:
- conda-forge
dependencies:
- python<3.12
- python>=3.9
- matplotlib>=3.4.2
- Cartopy>=0.21.0
- Shapely>=2.0.0
Expand Down
Loading
Loading