Metadata-Version: 2.4
Name: geocode-amap
Version: 0.1.0
Summary: 地理编码工具 — 高德地图 API 地址 → 坐标 + GeoJSON
Author: songwupei
License: MIT
Keywords: geocoding,amap,gaode,china,address,coordinates
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: GIS
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: aiohttp>=3.9

# geocode-amap

高德地图 API 地理编码工具 — 地址 → 坐标，输出 GeoJSON / CSV。

## 安装

```bash
pip install geocode-amap
```

## 配置

```bash
export AMAP_API_KEY_S=your_amap_key
```

## 使用

```bash
# 单个地址
geocode-amap "成都市武侯区阳光幼儿园"

# 批量 — 文件（一行一个，# 注释）
geocode-amap addresses.txt

# 指定输出
geocode-amap addresses.txt -o result.geojson

# CSV 格式
geocode-amap addresses.txt --format csv

# 跳过逆地理编码（更快）
geocode-amap addresses.txt --no-reverse
```

## 子命令

### `geocode-amap search` — POI 搜索

```bash
geocode-amap search "星巴克" -c 北京 -n 10
geocode-amap search "加油站" -c 成都 --csv
```

### POI GeoJSON 字段

```json
{
  "type": "FeatureCollection",
  "features": [{
    "type": "Feature",
    "geometry": { "type": "Point", "coordinates": [lon, lat] },
    "properties": {
      "id":         "B001C051A4",        // 高德 POI ID
      "name":       "星巴克(太古里店)",    // 名称
      "type":       "餐饮服务;咖啡厅",     // 类别
      "typecode":   "050300",            // 类别代码
      "location":   "104.080,30.650",    // lon,lat
      "lon":        104.080,             // 经度
      "lat":        30.650,              // 纬度
      "address":    "太古里1层",          // 地址
      "cityname":   "成都市",             // 城市
      "adname":     "锦江区",             // 区县
      "pname":      "四川省",             // 省份
      "tel":        "028-88888888",      // 电话
      "distance":   "150"                // 距中心点距离(米)
    }
  }]
}
```

---

## 输出

### 地理编码 GeoJSON (geocode + reverse)

| 字段 | 来源 | 类型 | 说明 |
|------|------|------|------|
| `name` | 输入 | string | 查询地址 |
| `query_time` | 本地 | string | 查询时间 (ISO 8601) |
| `location` | geocode | string | `lon,lat` |
| `formatted_address` | geocode | string | 结构化地址 |
| `province` | geocode | string | 省 |
| `city` | geocode | string | 市 |
| `district` | geocode | string | 区/县 |
| `adcode` | geocode | string | 行政区划代码 |
| `level` | geocode | string | 匹配级别 (省/市/区县/兴趣点) |
| `regeo_formatted` | reverse | string | 逆地理编码完整地址 |
| `township` | reverse | string | 街道/乡镇 |
| `citycode` | reverse | string | 城市区号 |
| `roads` | reverse | array | 周边道路 [{name, distance, direction}] |
| `nearby_pois` | reverse | array | 周边POI [{name, type, address, tel, distance}] |

### CSV 格式

| 列 | 来源 | 说明 |
|------|------|------|
| `name` | 输入 | 查询地址 |
| `lon` | geocode | 经度 (WGS-84) |
| `lat` | geocode | 纬度 (WGS-84) |
| `province` | geocode | 省 |
| `city` | geocode | 市 |
| `district` | geocode | 区/县 |
| `address` | geocode | 结构化地址 |

```csv
name,lon,lat,province,city,district,address
郭公庄,116.301403,39.812832,北京市,北京市,丰台区,北京市丰台区郭公庄
```

## License

MIT
