从数据库中获取所有符合查询条件的城市。当用户需要查询城市信息、城市坐标、城市名称时使用。
目前仅支持通过 Astrox WebAPI 的 GET /city
{BASE_URL}/city 发送 GET 请求,Content-Type: application/json。GET /city
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
cityName | string | 否 |
| 城市名称(英文或者汉语拼音) |
provinceName | string | 否 | 省份名称 |
countryName | string | 否 | 国家名称 |
typeOfCity | string | 否 | 城市类型(PopulatedPlace/AdministrationCenter/NationalCapital/TerritorialCapital) |
| 字段名 | 类型 | 说明 |
|---|---|---|
IsSuccess | boolean | 结果(True:成功;False:失败) |
Message | string | 结果信息(主要是存储失败的原因) |
Cities | array CityDatabaseEntry[] | null | 所有符合的城市列表 |
| 字段名 | 类型 | 说明 |
|---|---|---|
CentralBodyName | string | null | 城市所处中心天体(缺省为Earth) |
CityName | string | null | 城市名称 |
CountryName | string | null | 城市所属国家名称 |
Latitude | number | 城市纬度(单位:rad) |
Longitude | number | 城市经度(单位:rad) |
Population | integer | 城市人口 |
ProvinceName | string | null | 城市所属省名称 |
ProvinceRank | integer | 城市所属省份等级 |
TypeOfCity | string | null | 城市类型(PopulatedPlace/AdministrationCenter/NationalCapital/TerritorialCapital) |
{
"IsSuccess": true,
"Message": "Success",
"Cities": [
{
"CityName": "Nanjing",
"TypeOfCity": "AdministrationCenter",
"ProvinceName": "Jiangsu",
"CountryName": "CHINA",
"ProvinceRank": 0,
"Population": 0,
"Latitude": 0.5595816528280128,
"Longitude": 2.0730633043028854,
"CentralBodyName": "Earth"
}
]
}
IsSuccessIsSuccess = false 时优先返回 Message场景 1:按城市名称查询
export BASE_URL=http://astrox.cn:8765
curl "${BASE_URL}/city?cityName=Beijing" \
--request GET \
--header 'Content-Type: application/json'
场景 2:按省份名称查询
export BASE_URL=http://astrox.cn:8765
curl "${BASE_URL}/city?provinceName=Hebei" \
--request GET \
--header 'Content-Type: application/json'
场景 3:按国家名称查询
export BASE_URL=http://astrox.cn:8765
curl "${BASE_URL}/city?cityName=Beijing&countryName=China" \
--request GET \
--header 'Content-Type: application/json'
场景 4:按城市类型查询(首都)
export BASE_URL=http://astrox.cn:8765
curl "${BASE_URL}/city?typeOfCity=NationalCapital" \
--request GET \
--header 'Content-Type: application/json'
场景 5:组合查询
export BASE_URL=http://astrox.cn:8765
curl "${BASE_URL}/city?countryName=China&typeOfCity=NationalCapital" \
--request GET \
--header 'Content-Type: application/json'