服务定义
面向移动终端、IoT 设备、车载设备,提供基于 GPS、WiFi、蜂窝基站的服务端定位能力。上报终端采集到的定位信号,由服务综合计算位置,返回统一的经纬度、精度、坐标系,并可按需返回逆地理地址。与端侧定位 SDK 不同,本能力是服务端接口:定位运算在云端完成,适合弱算力硬件与自行采集信号的设备。
输入与输出
上报信号
gps / wifi / cell(至少一类)
coord_type 返回坐标系,options.needAddress 是否返回地址
返回位置
经纬度+精度+坐标系+诊断信息
data.location,可含 address;data.diagnosis 定位过程
GPS、WiFi、基站三类信号至少提供一类;响应包含定位来源、置信度与诊断信息,便于判断结果可信度与降级原因。
典型场景
车载 / 物流设备定位
车机、货联终端上报信号,云端返回车辆实时位置。
IoT / 智能硬件
穿戴、追踪器、共享设备等弱算力硬件上报 WiFi / 基站即可定位。
位置 + 地址一体化
需要坐标同时获得省市区街道地址,一次调用完成。
技术参数
智能硬件定位
1. 概述
智能硬件定位接口面向移动终端、IoT 设备、车载设备等场景,提供基于 GPS、WiFi、蜂窝移动通信基站的定位能力。
开发者可上报终端采集到的定位信号,服务将根据可用信号计算设备位置,并返回统一的经纬度、精度、坐标系等定位结果。接口支持按需返回逆地理编码地址信息。
接口特性:
- 支持 GPS、WiFi、基站三类定位信号;
- 支持多源定位信号综合计算;
- 支持指定返回坐标系;
- 支持按需返回地址信息;
- 请求和响应均使用 JSON 格式。
GPS、WiFi、基站三类定位方式至少提供一类有效定位信息。
2. 请求 URL 和请求参数
2.1 请求 URL
POST https://gis-apis.sf-express.com/opsdkapi/v1/location/position
2.2 请求方式
| 项目 | 说明 |
|---|---|
| 请求方式 | POST |
| 请求格式 | application/json |
| 返回格式 | application/json |
| 字符编码 | UTF-8 |
请求头:
| Header | 必填 | 说明 |
|---|---|---|
Content-Type |
是 | application/json |
2.3 请求参数
请求体示例:
{
"request_id": "req_001",
"coord_type": "GCJ02",
"gps": {
"available": true,
"latitude": 31.23041,
"longitude": 121.47369,
"accuracy_meters": 20,
"timestamp_ms": 1717500000000,
"coordinate_type": "WGS84"
},
"wifi": [
{
"bssid": "a0:b1:c2:d3:e4:f5",
"rssi": -55
}
],
"cell": [
{
"mcc": 460,
"mnc": 0,
"lac": 9365,
"cid": 12345678,
"rssi": -86,
"networkType": "4G"
}
],
"options": {
"needAddress": false
}
}
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
request_id |
string | 否 | 请求 ID,用于链路追踪;不传时由服务自动生成 |
coord_type |
string | 否 | 返回结果坐标系,可选值:GCJ02、BD09;不传时使用默认坐标系 |
gps |
object | 否 | GPS 定位信息;与wifi、cell 至少提供一类 |
gps.available |
boolean | 否 | GPS 是否可用 |
gps.latitude |
number | 否 | GPS 纬度 |
gps.longitude |
number | 否 | GPS 经度 |
gps.accuracy_meters |
number | 否 | GPS 精度,单位米 |
gps.timestamp_ms |
number | 否 | GPS 定位时间戳,单位毫秒 |
gps.coordinate_type |
string | 否 | GPS 坐标系,可选值:WGS84、GCJ02、BD09 |
wifi |
array | 否 | WiFi 信号列表;与gps、cell 至少提供一类 |
wifi[].bssid |
string | 否 | WiFi MAC 地址,如00:11:22:33:44:55 |
wifi[].rssi |
number | 否 | WiFi 信号强度,单位 dBm,如-65 |
cell |
array | 否 | 基站信号列表;与gps、wifi 至少提供一类 |
cell[].mcc |
number | 否 | 移动国家代码,如460 表示中国 |
cell[].mnc |
number | 否 | 移动网络代码,如0 |
cell[].lac |
number | 否 | 位置区域码 |
cell[].cid |
number | 否 | 基站编号 |
cell[].rssi |
number | 否 | 基站信号强度,单位 dBm,如-85 |
cell[].networkType |
string | 否 | 网络类型,如2G、3G、4G、5G |
options |
object | 否 | 扩展选项 |
options.needAddress |
boolean | 否 | 是否返回逆地理编码地址信息,默认false |
3. 响应结果
3.1 响应结构
{
"code": "OK",
"message": "success",
"requestId": "req_001",
"data": {
"location": {
"latitude": 30.4475,
"longitude": 114.4008,
"gridCode": "N50H045960C344",
"gridLevel": "L7",
"coordinateType": "WGS84",
"accuracyMeters": 32.4,
"source": "network_location",
"confidence": 0.8,
"timestampMs": 1717500000000,
"address": {
"province": "湖北省",
"city": "武汉市",
"district": "洪山区",
"town": "关东街道",
"street": "光谷大道",
"streetNumber": "88号",
"adcode": "420111",
"description": "光谷大道88号"
}
},
"diagnosis": {
"usedGps": true,
"usedWifi": false,
"usedCell": false,
"usedBle": false,
"fallback": true,
"decision": "network_failed_use_gps",
"gpsNetworkDistanceMeters": null,
"candidateGrids": [
{
"gridCode": "N50H045960C344",
"gridLevel": "L7",
"score": -2.08,
"weight": 0.34
}
]
}
}
}
3.2 响应参数
| 字段 | 类型 | 说明 |
|---|---|---|
code |
string | 响应码,OK 表示请求成功,其他值表示请求失败 |
message |
string | 响应描述 |
requestId |
string | 请求 ID |
data |
object | 定位结果;请求失败时为null |
data.location |
object | 定位坐标信息 |
data.location.latitude |
number | 纬度 |
data.location.longitude |
number | 经度 |
data.location.gridCode |
string | 匹配到的北斗网格码(L7 为 14 位,L6 为 12 位);非网格定位时为 null |
data.location.gridLevel |
string | 匹配到的网格级别:L7(精定位)或 L6(父格验证);非网格定位时为 null |
data.location.coordinateType |
string | 坐标系:WGS84、GCJ02、BD09 |
data.location.accuracyMeters |
number | 定位精度,单位米 |
data.location.source |
string | 定位来源 |
data.location.confidence |
number | 定位置信度,取值范围为0 到 1 |
data.location.timestampMs |
number | 定位时间戳,单位毫秒 |
data.location.address |
object | 地址信息;options.needAddress=true 时返回 |
data.location.address.province |
string | 省份 |
data.location.address.city |
string | 城市 |
data.location.address.district |
string | 区县 |
data.location.address.town |
string | 乡镇 |
data.location.address.street |
string | 街道 |
data.location.address.streetNumber |
string | 门牌号 |
data.location.address.adcode |
string | 行政区划代码 |
data.location.address.description |
string | 地址描述 |
data.diagnosis |
object | 定位过程信息 |
data.diagnosis.usedGps |
boolean | 是否使用 GPS 信息 |
data.diagnosis.usedWifi |
boolean | 是否使用 WiFi 信息 |
data.diagnosis.usedCell |
boolean | 是否使用基站信息 |
data.diagnosis.usedBle |
boolean | 是否使用 BLE 信息(预留,当前固定为 false) |
data.diagnosis.fallback |
boolean | 是否使用降级定位结果 |
data.diagnosis.decision |
string | 定位结果选择原因 |
data.diagnosis.gpsNetworkDistanceMeters |
number | GPS 定位结果与网络定位结果的距离,单位米 |
data.diagnosis.candidateGrids |
array | 网络定位 softmax top-K 候选网格列表(降级定位或 GPS 回退时为 null) |
data.diagnosis.candidateGrids[].gridCode |
string | 候选网格码 |
data.diagnosis.candidateGrids[].gridLevel |
string | 候选网格级别:L7(精定位)或 L6(父格验证) |
data.diagnosis.candidateGrids[].score |
number | 该网格的对数似然得分(负数,越大越匹配,0 为理论满分) |
data.diagnosis.candidateGrids[].weight |
number | 该网格的 softmax 归一化权重(0~1,所有候选之和为 1) |
3.3 定位来源
| 值 | 说明 |
|---|---|
network_location |
使用 WiFi/基站定位结果 |
gps_fallback |
网络定位失败时使用 GPS 定位结果 |
server_fusion_gps_preferred |
综合计算后选择 GPS 定位结果 |
3.4 定位结果选择原因
| 值 | 说明 |
|---|---|
network_only |
仅使用网络定位结果 |
gps_accuracy_better |
GPS 定位精度优于网络定位 |
network_far_from_gps |
网络定位结果与 GPS 定位结果距离较远 |
network_location_preferred |
使用网络定位结果 |
network_failed_use_gps |
网络定位失败,使用 GPS 定位结果 |
3.5 常见响应码
| 响应码 | 说明 |
|---|---|
OK |
请求成功 |
LOCATION_FAILED |
定位失败,无有效定位信号或无法匹配定位数据 |
PARAM_ERROR |
请求参数错误 |
INTERNAL_ERROR |
服务内部异常 |
4. 请求示例
4.1 GPS + WiFi + 基站定位请求示例
curl -sS 'https://gis-apis.sf-express.com/opsdkapi/v1/location/position' \
-H 'Content-Type: application/json' \
-d '{
"request_id": "req_test_001",
"coord_type": "GCJ02",
"gps": {
"available": true,
"latitude": 31.23041,
"longitude": 121.47369,
"accuracy_meters": 20,
"timestamp_ms": 1717500000000,
"coordinate_type": "WGS84"
},
"wifi": [
{
"bssid": "a0:b1:c2:d3:e4:f5",
"rssi": -55
},
{
"bssid": "f6:e5:d4:c3:b2:a1",
"rssi": -70
}
],
"cell": [
{
"mcc": 460,
"mnc": 0,
"lac": 9365,
"cid": 12345678,
"rssi": -86,
"networkType": "4G"
}
],
"options": {
"needAddress": true
}
}'
4.2 WiFi + 基站定位请求示例
curl -sS 'https://gis-apis.sf-express.com/opsdkapi/v1/location/position' \
-H 'Content-Type: application/json' \
-d '{
"request_id": "req_wifi_cell_001",
"coord_type": "GCJ02",
"wifi": [
{
"bssid": "a0:b1:c2:d3:e4:f5",
"rssi": -55
},
{
"bssid": "f6:e5:d4:c3:b2:a1",
"rssi": -70
}
],
"cell": [
{
"mcc": 460,
"mnc": 0,
"lac": 9365,
"cid": 12345678,
"rssi": -86,
"networkType": "4G"
}
],
"options": {
"needAddress": false
}
}'
4.3 GPS 定位请求示例
curl -sS 'https://gis-apis.sf-express.com/opsdkapi/v1/location/position' \
-H 'Content-Type: application/json' \
-d '{
"request_id": "req_gps_001",
"coord_type": "GCJ02",
"gps": {
"available": true,
"latitude": 30.593,
"longitude": 114.305,
"accuracy_meters": 20,
"timestamp_ms": 1717500000000,
"coordinate_type": "WGS84"
},
"options": {
"needAddress": true
}
}'
5. 响应示例
5.1 定位成功
{
"code": "OK",
"message": "success",
"requestId": "req_test_001",
"data": {
"location": {
"latitude": 31.23041,
"longitude": 121.47369,
"coordinateType": "GCJ02",
"accuracyMeters": 20.0,
"source": "server_fusion_gps_preferred",
"confidence": 0.95,
"timestampMs": 1717500000000,
"address": null
},
"diagnosis": {
"usedGps": true,
"usedWifi": true,
"usedCell": true,
"fallback": false,
"decision": "gps_accuracy_better",
"gpsNetworkDistanceMeters": 15.3
}
}
}
5.2 定位成功,返回地址信息
{
"code": "OK",
"message": "success",
"requestId": "req_gps_001",
"data": {
"location": {
"latitude": 30.593,
"longitude": 114.305,
"coordinateType": "GCJ02",
"accuracyMeters": 20.0,
"source": "gps_fallback",
"confidence": 0.95,
"timestampMs": 1717500000000,
"address": {
"province": "湖北省",
"city": "武汉市",
"district": "洪山区",
"town": "关东街道",
"street": "光谷大道",
"streetNumber": "88号",
"adcode": "420111",
"description": "光谷大道88号"
}
},
"diagnosis": {
"usedGps": true,
"usedWifi": false,
"usedCell": false,
"fallback": true,
"decision": "network_failed_use_gps",
"gpsNetworkDistanceMeters": null
}
}
}
5.3 无有效定位信号
{
"code": "LOCATION_FAILED",
"message": "gps, wifi or cell signal is required",
"requestId": "req_error_001",
"data": null
}
5.4 定位失败
{
"code": "LOCATION_FAILED",
"message": "定位失败,无法匹配wifi/cell数据",
"requestId": "req_error_002",
"data": null
}
400-0220-133
联系在线客服







