geocode
Resolve coordinates back to a place name.
Provider: https://geocode.com.cn via curl.
Current root response behavior:
- -
GET https://geocode.com.cn/ without params returns INLINECODE3 - returns field labels for Chinese and English display
- demo: INLINECODE4
Quick Start
CODEBLOCK0
When to Use
- - "Reverse geocode 32.9042, 110.805"
- "Coordinates to address"
- "根据经纬度查地点"
- "把经纬度转成地址"
When NOT to Use
- - Address/place name to coordinates (forward geocoding): use another provider
- Rich place details, reviews, opening hours, or POI metadata: use INLINECODE5
- Routing, distance matrices, or navigation
- High-volume batch geocoding
Query Rules
- - Pass decimal latitude and longitude.
- The endpoint supports reverse geocoding only via
GET /?lat=<latitude>&lon=<longitude>. - A bare root request returns a field-label hint payload describing the reverse-geocode result columns.
- INLINECODE7 may still be passed, but the documented contract on the site only guarantees
lat and lon.
Config
- -
GEOCODE_BASE_URL optionally points at another endpoint for testing or self-hosting. - INLINECODE11 overrides the default identifying
User-Agent.
Public API Limits
- - Use public endpoints only for low-frequency, interactive lookups.
- Send an identifying
User-Agent; do not use default curl UA for repeated calls. - Do not loop, bulk geocode, or aggressively retry against the public endpoint.
Commands
Scripted Reverse Geocode
CODEBLOCK1
CODEBLOCK2
Raw Reverse Geocode
CODEBLOCK3
Scripted Root Hint
CODEBLOCK4
Raw Root Hint Response
CODEBLOCK5
Current response body:
CODEBLOCK6
Response Shape
Successful responses return a compact JSON array, not an object. The root hint now documents five display fields instead of the old six-field output description.
Fixed order mapping:
- - index
0: Country / INLINECODE16 - index
1: admin1 / INLINECODE19 - index
2: admin2 / INLINECODE22 - index
3: county-level field when present / INLINECODE24 - index
4: name / INLINECODE27
Example:
CODEBLOCK7
What to Return
- - The original coordinates
- Best available locality/region text assembled from
name, county, admin2, and INLINECODE30 - Country or region value when present
- A note that some positions may be empty, especially the county or
name slot over water or remote areas - A short note if any fields are empty
Notes
- - The bundled script prints raw JSON to stdout and keeps dependencies to
curl only. - INLINECODE33 is intentionally unsupported because geocode.com.cn explicitly says it only supports
GET /?lat=<latitude>&lon=<longitude>. - If the user needs address-to-coordinate lookup, switch to a forward-geocoding provider instead of this endpoint.
geocode
将坐标解析为地名。
提供商:https://geocode.com.cn(通过 curl 调用)。
当前根路径响应行为:
- - GET https://geocode.com.cn/ 不带参数时返回 400 Bad Request
- 返回中英文显示的字段标签
- 示例:https://geocode.com.cn/?lat=39.9042&lon=116.4074
快速开始
bash
{baseDir}/scripts/geocode.sh hint
{baseDir}/scripts/geocode.sh reverse 32.9042 110.805 --lang zh-CN
{baseDir}/scripts/geocode.sh reverse 37.819929 -122.478255 --lang en
使用场景
- - 反向地理编码 32.9042, 110.805
- 坐标转地址
- 根据经纬度查地点
- 把经纬度转成地址
不适用场景
- - 地址/地名转坐标(正向地理编码):请使用其他提供商
- 详细地点信息、评论、营业时间或POI元数据:请使用 goplaces
- 路线规划、距离矩阵或导航
- 大批量地理编码
查询规则
- - 传入十进制经纬度。
- 端点仅支持通过 GET /?lat=<纬度>&lon=<经度> 进行反向地理编码。
- 根路径请求会返回一个描述反向地理编码结果字段的字段标签提示负载。
- 可以传入 accept-language,但站点文档仅保证支持 lat 和 lon。
配置
- - GEOCODEBASEURL 可选地指向另一个端点,用于测试或自托管。
- GEOCODEUSERAGENT 覆盖默认的标识性 User-Agent。
公共API限制
- - 仅将公共端点用于低频交互式查询。
- 发送标识性 User-Agent;重复调用时不要使用默认的curl UA。
- 不要对公共端点进行循环、批量地理编码或激进重试。
命令
脚本化反向地理编码
bash
{baseDir}/scripts/geocode.sh reverse 32.9042 110.805 --lang zh-CN
bash
{baseDir}/scripts/geocode.sh reverse 37.819929 -122.478255 --lang en
原始反向地理编码
bash
curl --get https://geocode.com.cn/ \
-A openclaw-geocode-skill/1.0 (interactive use) \
--data lat=32.9042 \
--data lon=110.805
脚本化根路径提示
bash
{baseDir}/scripts/geocode.sh hint
原始根路径提示响应
bash
curl -iL https://geocode.com.cn/
当前响应体:
json
{
demo: https://geocode.com.cn/?lat=25.7433&lon=123.4733,
zh: [国家/地区, 省, 市, 县, 乡镇/街道],
en: [Country, admin1, admin2, , name]
}
响应格式
成功响应返回紧凑的JSON数组,而非对象。根路径提示现在记录五个显示字段,取代了旧的六字段输出描述。
固定顺序映射:
- - 索引 0:Country / 国家/地区
- 索引 1:admin1 / 省
- 索引 2:admin2 / 市
- 索引 3:县级字段(如有)/ 县
- 索引 4:name / 乡镇/街道
示例:
json
[CN, Taiwan Province, Yilan County, Toucheng Township, ]
返回内容
- - 原始坐标
- 由 name、县、admin2 和 admin1 组装的最佳可用地点/区域文本
- 国家或地区值(如有)
- 提示某些位置可能为空,尤其是水域或偏远地区的县或 name 字段
- 如有字段为空,给出简短说明
备注
- - 捆绑脚本将原始JSON输出到标准输出,仅依赖 curl。
- search 被有意不支持,因为 geocode.com.cn 明确表示仅支持 GET /?lat=<纬度>&lon=<经度>。
- 如果用户需要地址转坐标查询,请改用正向地理编码提供商,而非此端点。