优化配置,更新默认坐标系为 EPSG:4490,调整日志等级为 ERROR;清理未使用的导入和常量。
This commit is contained in:
@@ -30,149 +30,11 @@ except PackageNotFoundError:
|
|||||||
# ── 配置 & 日志 ───────────────────────────────────────────────────────────────
|
# ── 配置 & 日志 ───────────────────────────────────────────────────────────────
|
||||||
from geo_tools.config.settings import settings
|
from geo_tools.config.settings import settings
|
||||||
from geo_tools.utils.logger import get_logger, set_global_level
|
from geo_tools.utils.logger import get_logger, set_global_level
|
||||||
from geo_tools.utils.validators import (
|
|
||||||
SUPPORTED_VECTOR_EXTENSIONS,
|
|
||||||
is_supported_vector_format,
|
|
||||||
is_valid_crs,
|
|
||||||
validate_crs,
|
|
||||||
validate_geometry,
|
|
||||||
validate_vector_path,
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── IO ────────────────────────────────────────────────────────────────────────
|
|
||||||
from geo_tools.io.readers import (
|
|
||||||
list_gdb_layers,
|
|
||||||
list_gpkg_layers,
|
|
||||||
read_csv_points,
|
|
||||||
read_gdb,
|
|
||||||
read_gpkg,
|
|
||||||
read_vector,
|
|
||||||
)
|
|
||||||
from geo_tools.io.writers import (
|
|
||||||
write_csv,
|
|
||||||
write_gdb,
|
|
||||||
write_gpkg,
|
|
||||||
write_vector,
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── 核心处理 ──────────────────────────────────────────────────────────────────
|
|
||||||
from geo_tools.core.geometry import (
|
|
||||||
buffer_geometry,
|
|
||||||
bounding_box,
|
|
||||||
centroid,
|
|
||||||
contains,
|
|
||||||
convex_hull,
|
|
||||||
difference,
|
|
||||||
distance_between,
|
|
||||||
fix_geometry,
|
|
||||||
intersect,
|
|
||||||
intersects,
|
|
||||||
is_valid_geometry,
|
|
||||||
symmetric_difference,
|
|
||||||
unary_union,
|
|
||||||
union,
|
|
||||||
within,
|
|
||||||
)
|
|
||||||
from geo_tools.core.projection import (
|
|
||||||
CGCS2000,
|
|
||||||
CGCS2000_UTM_50N,
|
|
||||||
WEB_MERCATOR,
|
|
||||||
WGS84,
|
|
||||||
crs_to_epsg,
|
|
||||||
get_crs_info,
|
|
||||||
suggest_projected_crs,
|
|
||||||
transform_coordinates,
|
|
||||||
transform_point,
|
|
||||||
)
|
|
||||||
from geo_tools.core.vector import (
|
|
||||||
add_area_column,
|
|
||||||
clip_to_extent,
|
|
||||||
dissolve_by,
|
|
||||||
drop_invalid_geometries,
|
|
||||||
explode_multipart,
|
|
||||||
reproject,
|
|
||||||
set_crs,
|
|
||||||
spatial_join,
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── 空间分析 ──────────────────────────────────────────────────────────────────
|
|
||||||
from geo_tools.analysis.spatial_ops import (
|
|
||||||
buffer_and_overlay,
|
|
||||||
nearest_features,
|
|
||||||
overlay,
|
|
||||||
select_by_location,
|
|
||||||
)
|
|
||||||
from geo_tools.analysis.stats import (
|
|
||||||
area_weighted_mean,
|
|
||||||
count_by_polygon,
|
|
||||||
summarize_attributes,
|
|
||||||
)
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"__version__",
|
"__version__",
|
||||||
"settings",
|
"settings",
|
||||||
# utils
|
# utils
|
||||||
"get_logger",
|
"get_logger",
|
||||||
"set_global_level",
|
"set_global_level"
|
||||||
"is_valid_crs",
|
|
||||||
"validate_crs",
|
|
||||||
"validate_geometry",
|
|
||||||
"is_supported_vector_format",
|
|
||||||
"validate_vector_path",
|
|
||||||
"SUPPORTED_VECTOR_EXTENSIONS",
|
|
||||||
# io - readers
|
|
||||||
"read_vector",
|
|
||||||
"read_gdb",
|
|
||||||
"list_gdb_layers",
|
|
||||||
"read_gpkg",
|
|
||||||
"list_gpkg_layers",
|
|
||||||
"read_csv_points",
|
|
||||||
# io - writers
|
|
||||||
"write_vector",
|
|
||||||
"write_gdb",
|
|
||||||
"write_gpkg",
|
|
||||||
"write_csv",
|
|
||||||
# core - geometry
|
|
||||||
"is_valid_geometry",
|
|
||||||
"fix_geometry",
|
|
||||||
"buffer_geometry",
|
|
||||||
"centroid",
|
|
||||||
"bounding_box",
|
|
||||||
"convex_hull",
|
|
||||||
"intersect",
|
|
||||||
"union",
|
|
||||||
"difference",
|
|
||||||
"symmetric_difference",
|
|
||||||
"unary_union",
|
|
||||||
"contains",
|
|
||||||
"within",
|
|
||||||
"intersects",
|
|
||||||
"distance_between",
|
|
||||||
# core - projection
|
|
||||||
"WGS84",
|
|
||||||
"CGCS2000",
|
|
||||||
"WEB_MERCATOR",
|
|
||||||
"CGCS2000_UTM_50N",
|
|
||||||
"get_crs_info",
|
|
||||||
"crs_to_epsg",
|
|
||||||
"transform_coordinates",
|
|
||||||
"transform_point",
|
|
||||||
"suggest_projected_crs",
|
|
||||||
# core - vector
|
|
||||||
"reproject",
|
|
||||||
"set_crs",
|
|
||||||
"clip_to_extent",
|
|
||||||
"dissolve_by",
|
|
||||||
"explode_multipart",
|
|
||||||
"drop_invalid_geometries",
|
|
||||||
"spatial_join",
|
|
||||||
"add_area_column",
|
|
||||||
# analysis
|
|
||||||
"buffer_and_overlay",
|
|
||||||
"overlay",
|
|
||||||
"nearest_features",
|
|
||||||
"select_by_location",
|
|
||||||
"area_weighted_mean",
|
|
||||||
"summarize_attributes",
|
|
||||||
"count_by_polygon",
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class GeoToolsSettings(BaseSettings):
|
|||||||
"""日志文件目录。"""
|
"""日志文件目录。"""
|
||||||
|
|
||||||
# ── 坐标系配置 ────────────────────────────────────────────
|
# ── 坐标系配置 ────────────────────────────────────────────
|
||||||
default_crs: str = "EPSG:4326"
|
default_crs: str = "EPSG:4490"
|
||||||
"""默认地理坐标系,使用 EPSG 代码字符串。
|
"""默认地理坐标系,使用 EPSG 代码字符串。
|
||||||
常见值:
|
常见值:
|
||||||
- ``EPSG:4326`` — WGS84 经纬度
|
- ``EPSG:4326`` — WGS84 经纬度
|
||||||
@@ -51,7 +51,7 @@ class GeoToolsSettings(BaseSettings):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# ── 日志配置 ──────────────────────────────────────────────
|
# ── 日志配置 ──────────────────────────────────────────────
|
||||||
log_level: str = "INFO"
|
log_level: str = "ERROR"
|
||||||
"""日志等级:DEBUG / INFO / WARNING / ERROR / CRITICAL。"""
|
"""日志等级:DEBUG / INFO / WARNING / ERROR / CRITICAL。"""
|
||||||
|
|
||||||
log_to_file: bool = True
|
log_to_file: bool = True
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ from geo_tools.utils.logger import get_logger
|
|||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
# ── 常用 CRS 快捷常量 ──────────────────────────────────────────────────────────
|
|
||||||
WGS84 = "EPSG:4326" # 地理坐标系(经纬度)
|
|
||||||
CGCS2000 = "EPSG:4490" # 中国国家大地坐标系 2000
|
|
||||||
WEB_MERCATOR = "EPSG:3857" # Web Mercator(米)
|
|
||||||
CGCS2000_UTM_50N = "EPSG:4508" # CGCS2000 / 3-degree Gauss-Kruger zone 50N
|
|
||||||
|
|
||||||
|
|
||||||
def get_crs_info(crs_input: str | int) -> dict[str, str | int | None]:
|
def get_crs_info(crs_input: str | int) -> dict[str, str | int | None]:
|
||||||
"""获取 CRS 的基本信息。
|
"""获取 CRS 的基本信息。
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user