From d460bcd44950adf169a637e4c83ad4966cad0997 Mon Sep 17 00:00:00 2001 From: SuiteForge Date: Tue, 21 Jul 2026 00:12:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=A0=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E6=9E=90=20centroid=20CRS=20=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=EF=BC=88=E4=BD=BF=E7=94=A8=E6=8A=95=E5=BD=B1=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=EF=BC=89=20-=20=E6=94=B9=E7=94=A8=20EPSG:3857=20?= =?UTF-8?q?=E6=8A=95=E5=BD=B1=E5=9D=90=E6=A0=87=E7=B3=BB=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E7=82=B9=20-=20=E6=B6=88=E9=99=A4=20geograph?= =?UTF-8?q?ic=20CRS=20centroid=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- suites/test-linux/scripts/overlay.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/suites/test-linux/scripts/overlay.py b/suites/test-linux/scripts/overlay.py index fc4e6c9..ff102e3 100644 --- a/suites/test-linux/scripts/overlay.py +++ b/suites/test-linux/scripts/overlay.py @@ -30,8 +30,10 @@ def main(): sys.exit(1) # 确保坐标系一致 - target_crs = province.crs or "EPSG:4326" - province = province.to_crs(target_crs) + source_crs = province.crs or "EPSG:4326" + # 使用投影坐标系(墨卡托)计算中心点以避免 geographic CRS 警告 + projected_crs = "EPSG:3857" + province_proj = province.to_crs(projected_crs) # 查找所有城市 SHP city_shp_files = glob.glob(os.path.join(cities_dir, "*.shp")) @@ -54,14 +56,14 @@ def main(): "reason": "数据为空", "status": "跳过"}) continue - city = city.to_crs(target_crs) + city = city.to_crs(projected_crs) - # 空间判断:城市中心点是否在省界内 + # 空间判断:城市中心点是否在省界内(使用投影坐标系避免 CRS 警告) city_centroid = city.geometry.centroid.iloc[0] - in_province = province.geometry.contains(city_centroid).any() + in_province = province_proj.geometry.contains(city_centroid).any() # 也检查 intersect 作为辅助判断 - intersects = province.geometry.intersects(city.geometry).any() + intersects = province_proj.geometry.intersects(city.geometry).any() status = "通过 ✅" if in_province else "不通过 ❌"