yaelocus 1.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yaelocus-1.3.1/LICENSE +21 -0
- yaelocus-1.3.1/PKG-INFO +297 -0
- yaelocus-1.3.1/README.md +257 -0
- yaelocus-1.3.1/geocode/__init__.py +55 -0
- yaelocus-1.3.1/geocode/__main__.py +8 -0
- yaelocus-1.3.1/geocode/cache.py +303 -0
- yaelocus-1.3.1/geocode/cli.py +1103 -0
- yaelocus-1.3.1/geocode/config.py +128 -0
- yaelocus-1.3.1/geocode/coords.py +126 -0
- yaelocus-1.3.1/geocode/errors.py +73 -0
- yaelocus-1.3.1/geocode/geocoder.py +488 -0
- yaelocus-1.3.1/geocode/logger.py +119 -0
- yaelocus-1.3.1/geocode/main.py +245 -0
- yaelocus-1.3.1/geocode/map_visualizer.py +158 -0
- yaelocus-1.3.1/geocode/models.py +61 -0
- yaelocus-1.3.1/pyproject.toml +82 -0
- yaelocus-1.3.1/setup.cfg +4 -0
- yaelocus-1.3.1/setup.py +8 -0
- yaelocus-1.3.1/tests/test_cache_advanced.py +630 -0
- yaelocus-1.3.1/tests/test_cli.py +739 -0
- yaelocus-1.3.1/tests/test_coords_advanced.py +441 -0
- yaelocus-1.3.1/tests/test_errors.py +386 -0
- yaelocus-1.3.1/tests/test_geocode.py +214 -0
- yaelocus-1.3.1/tests/test_geocoder.py +890 -0
- yaelocus-1.3.1/tests/test_logger.py +552 -0
- yaelocus-1.3.1/tests/test_map_visualizer.py +568 -0
- yaelocus-1.3.1/yaelocus.egg-info/PKG-INFO +297 -0
- yaelocus-1.3.1/yaelocus.egg-info/SOURCES.txt +30 -0
- yaelocus-1.3.1/yaelocus.egg-info/dependency_links.txt +1 -0
- yaelocus-1.3.1/yaelocus.egg-info/entry_points.txt +2 -0
- yaelocus-1.3.1/yaelocus.egg-info/requires.txt +12 -0
- yaelocus-1.3.1/yaelocus.egg-info/top_level.txt +1 -0
yaelocus-1.3.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Yaemikoreal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
yaelocus-1.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yaelocus
|
|
3
|
+
Version: 1.3.1
|
|
4
|
+
Summary: Address to coordinates tool with multi-API support
|
|
5
|
+
Author-email: Yaemikoreal <yaemiko@github.com>
|
|
6
|
+
Maintainer: Yaemikoreal
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/Yaemikoreal/YaeLocus
|
|
9
|
+
Project-URL: Repository, https://github.com/Yaemikoreal/YaeLocus
|
|
10
|
+
Keywords: geocode,geocoding,amap,baidu,tianditu,coordinates,address,latitude,longitude,mapping
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: requests>=2.28.0
|
|
29
|
+
Requires-Dist: pandas>=1.5.0
|
|
30
|
+
Requires-Dist: folium>=0.14.0
|
|
31
|
+
Requires-Dist: tqdm>=4.65.0
|
|
32
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
33
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
34
|
+
Requires-Dist: typer>=0.9.0
|
|
35
|
+
Requires-Dist: rich>=13.0.0
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# YaeLocus - 地址转经纬度工具
|
|
42
|
+
|
|
43
|
+
[](https://www.python.org/downloads/)
|
|
44
|
+
[](https://opensource.org/licenses/MIT)
|
|
45
|
+
[](https://github.com/Yaemikoreal/YaeLocus)
|
|
46
|
+
[](https://pypi.org/project/yaelocus/)
|
|
47
|
+
|
|
48
|
+
**Author: [Yaemikoreal](https://github.com/Yaemikoreal)**
|
|
49
|
+
|
|
50
|
+
基于多API混合调用的地理编码工具,支持批量地址转换、高性能缓存、交互式地图可视化。
|
|
51
|
+
|
|
52
|
+
**项目地址**: https://github.com/Yaemikoreal/YaeLocus
|
|
53
|
+
|
|
54
|
+
## 功能特性
|
|
55
|
+
|
|
56
|
+
- **多API轮换**:高德/百度/天地图三API智能轮换,免费额度合计21000次/日
|
|
57
|
+
- **现代化CLI**:Typer + Rich 彩色输出,交互式配置向导
|
|
58
|
+
- **高性能缓存**:SQLite持久化,延迟提交,写入性能提升10倍+
|
|
59
|
+
- **坐标转换**:自动转换为WGS-84坐标系
|
|
60
|
+
- **交互式地图**:点聚类 + 热力图
|
|
61
|
+
- **多格式支持**:CSV、Excel、JSON、GeoJSON 输入输出
|
|
62
|
+
- **逆地理编码**:经纬度转地址
|
|
63
|
+
- **并行处理**:多线程加速批量转换
|
|
64
|
+
- **断点续传**:跳过已缓存地址,增量处理
|
|
65
|
+
|
|
66
|
+
## 项目结构
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
geocode-tool/
|
|
70
|
+
├── geocode/ # 核心模块
|
|
71
|
+
│ ├── cli.py # CLI入口(Typer)
|
|
72
|
+
│ ├── geocoder.py # 地理编码
|
|
73
|
+
│ ├── cache.py # SQLite缓存(~180行)
|
|
74
|
+
│ ├── errors.py # 异常定义
|
|
75
|
+
│ └── ...
|
|
76
|
+
├── install.bat # Windows一键安装
|
|
77
|
+
├── uninstall.bat # 卸载脚本
|
|
78
|
+
├── .env.example # API密钥模板
|
|
79
|
+
├── CHANGELOG.md # 更新日志
|
|
80
|
+
├── LICENSE # MIT许可证
|
|
81
|
+
└── pyproject.toml # 项目配置
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 快速开始
|
|
85
|
+
|
|
86
|
+
### 安装
|
|
87
|
+
|
|
88
|
+
**方式1:PyPI 安装(推荐)**
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install yaelocus
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**方式2:从源码安装**
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
git clone https://github.com/Yaemikoreal/YaeLocus.git
|
|
98
|
+
cd YaeLocus
|
|
99
|
+
pip install -e .
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**方式3:Windows 一键安装**
|
|
103
|
+
|
|
104
|
+
双击 `install.bat` 即可自动安装。
|
|
105
|
+
|
|
106
|
+
安装完成后,可通过以下方式使用:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 方式1:使用命令(推荐)
|
|
110
|
+
yaelocus --help
|
|
111
|
+
|
|
112
|
+
# 方式2:模块方式
|
|
113
|
+
python -m geocode.cli --help
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 配置
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# 交互式配置(推荐)
|
|
120
|
+
yaelocus config
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
只需配置至少一个API密钥:
|
|
124
|
+
|
|
125
|
+
| API | 免费额度 | 申请地址 |
|
|
126
|
+
|-----|---------|----------|
|
|
127
|
+
| 高德地图 | 5000次/日 | https://lbs.amap.com |
|
|
128
|
+
| 天地图 | 10000次/日 | https://www.tianditu.gov.cn |
|
|
129
|
+
| 百度地图 | 6000次/日 | https://lbsyun.baidu.com |
|
|
130
|
+
|
|
131
|
+
### 运行
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# 执行地理编码
|
|
135
|
+
yaelocus run -i data/清单.xlsx
|
|
136
|
+
|
|
137
|
+
# 多格式输出
|
|
138
|
+
yaelocus run -i data/清单.xlsx -f xlsx # Excel 输出
|
|
139
|
+
yaelocus run -i data/清单.xlsx -f geojson # GeoJSON 输出
|
|
140
|
+
|
|
141
|
+
# 并行处理(5线程)
|
|
142
|
+
yaelocus run -i data/清单.xlsx -w 5
|
|
143
|
+
|
|
144
|
+
# 断点续传(跳过已缓存)
|
|
145
|
+
yaelocus run -i data/清单.xlsx --skip-cached
|
|
146
|
+
|
|
147
|
+
# 查看可用文件
|
|
148
|
+
yaelocus files
|
|
149
|
+
yaelocus files --detail
|
|
150
|
+
|
|
151
|
+
# 查看配额使用
|
|
152
|
+
yaelocus quota
|
|
153
|
+
|
|
154
|
+
# 环境诊断
|
|
155
|
+
yaelocus doctor
|
|
156
|
+
|
|
157
|
+
# 查看缓存统计
|
|
158
|
+
yaelocus cache stats
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## CLI 命令
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# 单地址转换
|
|
165
|
+
yaelocus geocode "北京市朝阳区" # 转换单个地址
|
|
166
|
+
yaelocus geocode "天安门" --json # JSON格式输出
|
|
167
|
+
|
|
168
|
+
# 逆地理编码(经纬度转地址)
|
|
169
|
+
yaelocus reverse 39.9 116.4
|
|
170
|
+
yaelocus reverse 39.9 116.4 --json
|
|
171
|
+
|
|
172
|
+
# 坐标转换
|
|
173
|
+
yaelocus convert 39.9 116.4 --from gcj02 --to wgs84
|
|
174
|
+
yaelocus convert 39.9 116.4 --from bd09 --to wgs84 --json
|
|
175
|
+
|
|
176
|
+
# 批量转换
|
|
177
|
+
yaelocus run -i <文件> # 执行地理编码
|
|
178
|
+
yaelocus run -i <文件> -f xlsx # Excel 输出
|
|
179
|
+
yaelocus run -i <文件> -w 5 # 5线程并行
|
|
180
|
+
yaelocus run -i <文件> --skip-cached # 断点续传
|
|
181
|
+
|
|
182
|
+
# 文件列表
|
|
183
|
+
yaelocus files # 列出可处理文件
|
|
184
|
+
yaelocus files --detail # 显示详细信息
|
|
185
|
+
|
|
186
|
+
# 配额管理
|
|
187
|
+
yaelocus quota # 查看配额使用
|
|
188
|
+
|
|
189
|
+
# 缓存管理
|
|
190
|
+
yaelocus cache stats # 查看缓存统计
|
|
191
|
+
yaelocus cache cleanup # 清理过期缓存
|
|
192
|
+
yaelocus cache export # 导出缓存数据
|
|
193
|
+
|
|
194
|
+
# 配置与诊断
|
|
195
|
+
yaelocus config # 交互式配置API密钥
|
|
196
|
+
yaelocus doctor # 环境诊断
|
|
197
|
+
yaelocus test-api # 测试API连通性
|
|
198
|
+
yaelocus --version # 显示版本信息
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### run 命令参数
|
|
202
|
+
|
|
203
|
+
| 参数 | 说明 | 默认值 |
|
|
204
|
+
|------|------|--------|
|
|
205
|
+
| `-i, --input` | 输入文件(CSV/Excel) | 必填 |
|
|
206
|
+
| `-c, --column` | 地址列名 | `地址` |
|
|
207
|
+
| `-o, --output` | 输出文件 | 自动生成 |
|
|
208
|
+
| `-f, --format` | 输出格式(csv/xlsx/json/geojson) | `csv` |
|
|
209
|
+
| `-w, --workers` | 并行线程数 | `1` |
|
|
210
|
+
| `--skip-cached` | 跳过已缓存地址 | `False` |
|
|
211
|
+
| `-m, --map` | 输出地图HTML | 自动生成 |
|
|
212
|
+
| `--ttl` | 缓存过期时间(秒) | 永不过期 |
|
|
213
|
+
| `--cleanup` | 清理过期缓存 | - |
|
|
214
|
+
| `-v, --verbose` | 详细输出 | - |
|
|
215
|
+
|
|
216
|
+
## Python API
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
from geocode import Geocoder, CacheManager, create_map
|
|
220
|
+
|
|
221
|
+
# 使用上下文管理器自动关闭
|
|
222
|
+
with CacheManager("cache.db") as cache:
|
|
223
|
+
geocoder = Geocoder(cache)
|
|
224
|
+
|
|
225
|
+
# 单个地址转换
|
|
226
|
+
result = geocoder.geocode("北京市朝阳区建国路88号")
|
|
227
|
+
print(result['longitude'], result['latitude'])
|
|
228
|
+
|
|
229
|
+
# 逆地理编码
|
|
230
|
+
address = geocoder.reverse_geocode(39.9, 116.4)
|
|
231
|
+
print(address['formatted_address'])
|
|
232
|
+
|
|
233
|
+
# 批量转换
|
|
234
|
+
results = geocoder.batch_geocode(["地址1", "地址2", "地址3"])
|
|
235
|
+
|
|
236
|
+
# 生成地图
|
|
237
|
+
valid = [r for r in results if r.get("success")]
|
|
238
|
+
create_map(valid, output_file="map.html")
|
|
239
|
+
|
|
240
|
+
# 缓存统计
|
|
241
|
+
print(geocoder.get_cache_stats())
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## API配额
|
|
245
|
+
|
|
246
|
+
| API | 免费额度 | 坐标系 |
|
|
247
|
+
|-----|---------|--------|
|
|
248
|
+
| 高德地图 | 5000次/日 | GCJ-02 |
|
|
249
|
+
| 天地图 | 10000次/日 | CGCS2000 |
|
|
250
|
+
| 百度地图 | 6000次/日 | BD-09 |
|
|
251
|
+
|
|
252
|
+
三者合计 **21000次/日**,智能轮换优先使用高德。
|
|
253
|
+
|
|
254
|
+
## 输出文件
|
|
255
|
+
|
|
256
|
+
| 文件 | 说明 |
|
|
257
|
+
|------|------|
|
|
258
|
+
| `output/地址_经纬度_结果.csv` | 转换结果 |
|
|
259
|
+
| `output/地图输出.html` | 交互式地图 |
|
|
260
|
+
| `output/geocache.db` | SQLite缓存 |
|
|
261
|
+
| `output/api调用日志.csv` | API调用记录 |
|
|
262
|
+
|
|
263
|
+
## 常见问题
|
|
264
|
+
|
|
265
|
+
**Q: 首次运行找不到命令?**
|
|
266
|
+
```bash
|
|
267
|
+
# 确保已安装
|
|
268
|
+
pip install yaelocus
|
|
269
|
+
|
|
270
|
+
# 检查环境
|
|
271
|
+
yaelocus doctor
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Q: API配额用完了?**
|
|
275
|
+
工具会自动轮换三个API,合计21000次/日,通常足够。
|
|
276
|
+
|
|
277
|
+
**Q: 如何获取API密钥?**
|
|
278
|
+
- 高德:https://lbs.amap.com(注册→控制台→应用管理→创建应用→添加Key)
|
|
279
|
+
- 天地图:https://www.tianditu.gov.cn(注册→开发资源→申请Key)
|
|
280
|
+
- 百度:https://lbsyun.baidu.com(注册→控制台→创建应用)
|
|
281
|
+
|
|
282
|
+
**Q: 如何卸载?**
|
|
283
|
+
```bash
|
|
284
|
+
pip uninstall yaelocus
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## 更新日志
|
|
288
|
+
|
|
289
|
+
见 [CHANGELOG.md](CHANGELOG.md)
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
|
|
293
|
+
[MIT License](LICENSE)
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
**YaeLocus** - Made with ❤️ by [Yaemikoreal](https://github.com/Yaemikoreal)
|
yaelocus-1.3.1/README.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# YaeLocus - 地址转经纬度工具
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/Yaemikoreal/YaeLocus)
|
|
6
|
+
[](https://pypi.org/project/yaelocus/)
|
|
7
|
+
|
|
8
|
+
**Author: [Yaemikoreal](https://github.com/Yaemikoreal)**
|
|
9
|
+
|
|
10
|
+
基于多API混合调用的地理编码工具,支持批量地址转换、高性能缓存、交互式地图可视化。
|
|
11
|
+
|
|
12
|
+
**项目地址**: https://github.com/Yaemikoreal/YaeLocus
|
|
13
|
+
|
|
14
|
+
## 功能特性
|
|
15
|
+
|
|
16
|
+
- **多API轮换**:高德/百度/天地图三API智能轮换,免费额度合计21000次/日
|
|
17
|
+
- **现代化CLI**:Typer + Rich 彩色输出,交互式配置向导
|
|
18
|
+
- **高性能缓存**:SQLite持久化,延迟提交,写入性能提升10倍+
|
|
19
|
+
- **坐标转换**:自动转换为WGS-84坐标系
|
|
20
|
+
- **交互式地图**:点聚类 + 热力图
|
|
21
|
+
- **多格式支持**:CSV、Excel、JSON、GeoJSON 输入输出
|
|
22
|
+
- **逆地理编码**:经纬度转地址
|
|
23
|
+
- **并行处理**:多线程加速批量转换
|
|
24
|
+
- **断点续传**:跳过已缓存地址,增量处理
|
|
25
|
+
|
|
26
|
+
## 项目结构
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
geocode-tool/
|
|
30
|
+
├── geocode/ # 核心模块
|
|
31
|
+
│ ├── cli.py # CLI入口(Typer)
|
|
32
|
+
│ ├── geocoder.py # 地理编码
|
|
33
|
+
│ ├── cache.py # SQLite缓存(~180行)
|
|
34
|
+
│ ├── errors.py # 异常定义
|
|
35
|
+
│ └── ...
|
|
36
|
+
├── install.bat # Windows一键安装
|
|
37
|
+
├── uninstall.bat # 卸载脚本
|
|
38
|
+
├── .env.example # API密钥模板
|
|
39
|
+
├── CHANGELOG.md # 更新日志
|
|
40
|
+
├── LICENSE # MIT许可证
|
|
41
|
+
└── pyproject.toml # 项目配置
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 快速开始
|
|
45
|
+
|
|
46
|
+
### 安装
|
|
47
|
+
|
|
48
|
+
**方式1:PyPI 安装(推荐)**
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install yaelocus
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**方式2:从源码安装**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/Yaemikoreal/YaeLocus.git
|
|
58
|
+
cd YaeLocus
|
|
59
|
+
pip install -e .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**方式3:Windows 一键安装**
|
|
63
|
+
|
|
64
|
+
双击 `install.bat` 即可自动安装。
|
|
65
|
+
|
|
66
|
+
安装完成后,可通过以下方式使用:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# 方式1:使用命令(推荐)
|
|
70
|
+
yaelocus --help
|
|
71
|
+
|
|
72
|
+
# 方式2:模块方式
|
|
73
|
+
python -m geocode.cli --help
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 配置
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# 交互式配置(推荐)
|
|
80
|
+
yaelocus config
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
只需配置至少一个API密钥:
|
|
84
|
+
|
|
85
|
+
| API | 免费额度 | 申请地址 |
|
|
86
|
+
|-----|---------|----------|
|
|
87
|
+
| 高德地图 | 5000次/日 | https://lbs.amap.com |
|
|
88
|
+
| 天地图 | 10000次/日 | https://www.tianditu.gov.cn |
|
|
89
|
+
| 百度地图 | 6000次/日 | https://lbsyun.baidu.com |
|
|
90
|
+
|
|
91
|
+
### 运行
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 执行地理编码
|
|
95
|
+
yaelocus run -i data/清单.xlsx
|
|
96
|
+
|
|
97
|
+
# 多格式输出
|
|
98
|
+
yaelocus run -i data/清单.xlsx -f xlsx # Excel 输出
|
|
99
|
+
yaelocus run -i data/清单.xlsx -f geojson # GeoJSON 输出
|
|
100
|
+
|
|
101
|
+
# 并行处理(5线程)
|
|
102
|
+
yaelocus run -i data/清单.xlsx -w 5
|
|
103
|
+
|
|
104
|
+
# 断点续传(跳过已缓存)
|
|
105
|
+
yaelocus run -i data/清单.xlsx --skip-cached
|
|
106
|
+
|
|
107
|
+
# 查看可用文件
|
|
108
|
+
yaelocus files
|
|
109
|
+
yaelocus files --detail
|
|
110
|
+
|
|
111
|
+
# 查看配额使用
|
|
112
|
+
yaelocus quota
|
|
113
|
+
|
|
114
|
+
# 环境诊断
|
|
115
|
+
yaelocus doctor
|
|
116
|
+
|
|
117
|
+
# 查看缓存统计
|
|
118
|
+
yaelocus cache stats
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## CLI 命令
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# 单地址转换
|
|
125
|
+
yaelocus geocode "北京市朝阳区" # 转换单个地址
|
|
126
|
+
yaelocus geocode "天安门" --json # JSON格式输出
|
|
127
|
+
|
|
128
|
+
# 逆地理编码(经纬度转地址)
|
|
129
|
+
yaelocus reverse 39.9 116.4
|
|
130
|
+
yaelocus reverse 39.9 116.4 --json
|
|
131
|
+
|
|
132
|
+
# 坐标转换
|
|
133
|
+
yaelocus convert 39.9 116.4 --from gcj02 --to wgs84
|
|
134
|
+
yaelocus convert 39.9 116.4 --from bd09 --to wgs84 --json
|
|
135
|
+
|
|
136
|
+
# 批量转换
|
|
137
|
+
yaelocus run -i <文件> # 执行地理编码
|
|
138
|
+
yaelocus run -i <文件> -f xlsx # Excel 输出
|
|
139
|
+
yaelocus run -i <文件> -w 5 # 5线程并行
|
|
140
|
+
yaelocus run -i <文件> --skip-cached # 断点续传
|
|
141
|
+
|
|
142
|
+
# 文件列表
|
|
143
|
+
yaelocus files # 列出可处理文件
|
|
144
|
+
yaelocus files --detail # 显示详细信息
|
|
145
|
+
|
|
146
|
+
# 配额管理
|
|
147
|
+
yaelocus quota # 查看配额使用
|
|
148
|
+
|
|
149
|
+
# 缓存管理
|
|
150
|
+
yaelocus cache stats # 查看缓存统计
|
|
151
|
+
yaelocus cache cleanup # 清理过期缓存
|
|
152
|
+
yaelocus cache export # 导出缓存数据
|
|
153
|
+
|
|
154
|
+
# 配置与诊断
|
|
155
|
+
yaelocus config # 交互式配置API密钥
|
|
156
|
+
yaelocus doctor # 环境诊断
|
|
157
|
+
yaelocus test-api # 测试API连通性
|
|
158
|
+
yaelocus --version # 显示版本信息
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### run 命令参数
|
|
162
|
+
|
|
163
|
+
| 参数 | 说明 | 默认值 |
|
|
164
|
+
|------|------|--------|
|
|
165
|
+
| `-i, --input` | 输入文件(CSV/Excel) | 必填 |
|
|
166
|
+
| `-c, --column` | 地址列名 | `地址` |
|
|
167
|
+
| `-o, --output` | 输出文件 | 自动生成 |
|
|
168
|
+
| `-f, --format` | 输出格式(csv/xlsx/json/geojson) | `csv` |
|
|
169
|
+
| `-w, --workers` | 并行线程数 | `1` |
|
|
170
|
+
| `--skip-cached` | 跳过已缓存地址 | `False` |
|
|
171
|
+
| `-m, --map` | 输出地图HTML | 自动生成 |
|
|
172
|
+
| `--ttl` | 缓存过期时间(秒) | 永不过期 |
|
|
173
|
+
| `--cleanup` | 清理过期缓存 | - |
|
|
174
|
+
| `-v, --verbose` | 详细输出 | - |
|
|
175
|
+
|
|
176
|
+
## Python API
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from geocode import Geocoder, CacheManager, create_map
|
|
180
|
+
|
|
181
|
+
# 使用上下文管理器自动关闭
|
|
182
|
+
with CacheManager("cache.db") as cache:
|
|
183
|
+
geocoder = Geocoder(cache)
|
|
184
|
+
|
|
185
|
+
# 单个地址转换
|
|
186
|
+
result = geocoder.geocode("北京市朝阳区建国路88号")
|
|
187
|
+
print(result['longitude'], result['latitude'])
|
|
188
|
+
|
|
189
|
+
# 逆地理编码
|
|
190
|
+
address = geocoder.reverse_geocode(39.9, 116.4)
|
|
191
|
+
print(address['formatted_address'])
|
|
192
|
+
|
|
193
|
+
# 批量转换
|
|
194
|
+
results = geocoder.batch_geocode(["地址1", "地址2", "地址3"])
|
|
195
|
+
|
|
196
|
+
# 生成地图
|
|
197
|
+
valid = [r for r in results if r.get("success")]
|
|
198
|
+
create_map(valid, output_file="map.html")
|
|
199
|
+
|
|
200
|
+
# 缓存统计
|
|
201
|
+
print(geocoder.get_cache_stats())
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## API配额
|
|
205
|
+
|
|
206
|
+
| API | 免费额度 | 坐标系 |
|
|
207
|
+
|-----|---------|--------|
|
|
208
|
+
| 高德地图 | 5000次/日 | GCJ-02 |
|
|
209
|
+
| 天地图 | 10000次/日 | CGCS2000 |
|
|
210
|
+
| 百度地图 | 6000次/日 | BD-09 |
|
|
211
|
+
|
|
212
|
+
三者合计 **21000次/日**,智能轮换优先使用高德。
|
|
213
|
+
|
|
214
|
+
## 输出文件
|
|
215
|
+
|
|
216
|
+
| 文件 | 说明 |
|
|
217
|
+
|------|------|
|
|
218
|
+
| `output/地址_经纬度_结果.csv` | 转换结果 |
|
|
219
|
+
| `output/地图输出.html` | 交互式地图 |
|
|
220
|
+
| `output/geocache.db` | SQLite缓存 |
|
|
221
|
+
| `output/api调用日志.csv` | API调用记录 |
|
|
222
|
+
|
|
223
|
+
## 常见问题
|
|
224
|
+
|
|
225
|
+
**Q: 首次运行找不到命令?**
|
|
226
|
+
```bash
|
|
227
|
+
# 确保已安装
|
|
228
|
+
pip install yaelocus
|
|
229
|
+
|
|
230
|
+
# 检查环境
|
|
231
|
+
yaelocus doctor
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Q: API配额用完了?**
|
|
235
|
+
工具会自动轮换三个API,合计21000次/日,通常足够。
|
|
236
|
+
|
|
237
|
+
**Q: 如何获取API密钥?**
|
|
238
|
+
- 高德:https://lbs.amap.com(注册→控制台→应用管理→创建应用→添加Key)
|
|
239
|
+
- 天地图:https://www.tianditu.gov.cn(注册→开发资源→申请Key)
|
|
240
|
+
- 百度:https://lbsyun.baidu.com(注册→控制台→创建应用)
|
|
241
|
+
|
|
242
|
+
**Q: 如何卸载?**
|
|
243
|
+
```bash
|
|
244
|
+
pip uninstall yaelocus
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## 更新日志
|
|
248
|
+
|
|
249
|
+
见 [CHANGELOG.md](CHANGELOG.md)
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
[MIT License](LICENSE)
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
**YaeLocus** - Made with ❤️ by [Yaemikoreal](https://github.com/Yaemikoreal)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
YaeLocus - 地址转经纬度工具
|
|
3
|
+
|
|
4
|
+
支持高德、百度、天地图三个API的智能轮换
|
|
5
|
+
|
|
6
|
+
Author: Yaemikoreal
|
|
7
|
+
Project: https://github.com/Yaemikoreal/YaeLocus
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
from geocode import Geocoder, CacheManager, APILogger
|
|
11
|
+
|
|
12
|
+
# 初始化
|
|
13
|
+
cache = CacheManager()
|
|
14
|
+
logger = APILogger()
|
|
15
|
+
geocoder = Geocoder(cache, logger)
|
|
16
|
+
|
|
17
|
+
# 单个地址转换
|
|
18
|
+
result = geocoder.geocode("北京市朝阳区建国路88号")
|
|
19
|
+
|
|
20
|
+
# 逆地理编码
|
|
21
|
+
result = geocoder.reverse_geocode(39.9, 116.4)
|
|
22
|
+
|
|
23
|
+
# 批量转换
|
|
24
|
+
results = geocoder.batch_geocode(["地址1", "地址2"])
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from .cache import CacheManager
|
|
28
|
+
from .config import Config
|
|
29
|
+
from .coords import gcj02_to_wgs84, bd09_to_wgs84, bd09_to_gcj02, wgs84_to_gcj02
|
|
30
|
+
from .errors import GeocodeError, ConfigError, APIError, FileError, NetworkError
|
|
31
|
+
from .geocoder import Geocoder
|
|
32
|
+
from .logger import APILogger
|
|
33
|
+
from .map_visualizer import create_map
|
|
34
|
+
from .models import GeocodeResult, APILog, APIConfig
|
|
35
|
+
|
|
36
|
+
__version__ = "1.3.1"
|
|
37
|
+
__all__ = [
|
|
38
|
+
"Geocoder",
|
|
39
|
+
"CacheManager",
|
|
40
|
+
"APILogger",
|
|
41
|
+
"create_map",
|
|
42
|
+
"Config",
|
|
43
|
+
"GeocodeResult",
|
|
44
|
+
"APILog",
|
|
45
|
+
"APIConfig",
|
|
46
|
+
"gcj02_to_wgs84",
|
|
47
|
+
"bd09_to_wgs84",
|
|
48
|
+
"bd09_to_gcj02",
|
|
49
|
+
"wgs84_to_gcj02",
|
|
50
|
+
"GeocodeError",
|
|
51
|
+
"ConfigError",
|
|
52
|
+
"APIError",
|
|
53
|
+
"FileError",
|
|
54
|
+
"NetworkError",
|
|
55
|
+
]
|