HERE API是否提供GSM小区信息的三角剖分?

时间:2019-10-21 09:06:36

标签: here-api

当前正在测试用于GSM定位应用程序的HERE API。似乎没有发生单元三角剖分,但是为什么可以将多个GSM数据点传递到API中呢?

我尝试传递最多7个GSM小区位置,但估计的位置始终以其中一个小区结尾,并且不靠近设备的实际位置。

###############################################################################
# cell tower info for HERE API
###############################################################################
here_cell_0 = {"cid": 17078,
          "lac": 314,
          "mcc": 234,
          "mnc": 15,
          "rxlevel": -52,
          "nmr": [{"bsic": 18, "bcch": 25, "rxlevel": -52}]}

here_cell_1 = {"cid": 13491,
          "lac": 165,
          "mcc": 234,
          "mnc": 15,
          "rxlevel": -61,
          "nmr": [{"bsic": 27, "bcch": 33, "rxlevel": -61}]}

here_cell_2 = {"cid": 16191,
          "lac": 316,
          "mcc": 234,
          "mnc": 15,
          "rxlevel": -62,
          "nmr": [{"bsic": 38, "bcch": 26, "rxlevel": -62}]}

here_cell_3 = {"cid": 13492,
          "lac": 165,
          "mcc": 234,
          "mnc": 15,
          "rxlevel": -65,
          "nmr": [{"bsic": 8, "bcch": 30, "rxlevel": -65}]}

here_cell_4 = {"cid": 18119,
          "lac": 316,
          "mcc": 234,
          "mnc": 15,
          "rxlevel": -65,
          "nmr": [{"bsic": 35, "bcch": 36, "rxlevel": -65}]}

here_cell_5 = {"cid": 13564,

          "lac": 165,
          "mcc": 234,
          "mnc": 15,
          "rxlevel": -66,
          "nmr": [{"bsic": 37, "bcch": 29, "rxlevel": -66}]}

here_cell_6 = {"cid": 17079,
          "lac": 314,
          "mcc": 234,
          "mnc": 15,
          "rxlevel": -69,
          "nmr": [{"bsic": 41, "bcch": 37, "rxlevel": -69}]}

ALL_CELLS_HERE = [here_cell_0,here_cell_1,here_cell_2,here_cell_3,here_cell_4,here_cell_5,here_cell_6]

###############################################################################
# HERE API data
###############################################################################
# API KEY
APP_ID = ""
APP_CODE = ""
APP_ID_RESOURCE = "app_id=" + APP_ID
APP_CODE_RESOURCE = "app_code=" + APP_CODE

# position API
POS_BASE_URL = "https://pos.api.here.com/positioning/v1/locate"
POS_URL = POS_BASE_URL + "?" + APP_ID_RESOURCE + "&" + APP_CODE_RESOURCE

###############################################################################
# get positions of cells and estimated position
###############################################################################
CELL_COORDINATES = []

# get cell tower postions
for CELL in ALL_CELLS_HERE:
    POST_BODY = {"gsm": [CELL]}
    headers = {'Content-type': 'application/json'}
    r = requests.post(url = POS_URL, json = POST_BODY, headers=headers)
    if( r.status_code == 200):
        data = r.json()
        print(data)
        CELL_COORDINATES.append(data)
    else:
        print("Request failed, status code: " + str(r.status_code) )

# get estimated position HERE API
POST_BODY = {"gsm": ALL_CELLS_HERE}
headers = {'Content-type': 'application/json'}
r = requests.post(url = POS_URL, json = POST_BODY, headers=headers)
if( r.status_code == 200):
    ESTIMATED_COORDINATE_HERE_API = r.json()
    print(ESTIMATED_COORDINATE_HERE_API)
else:
    print("Request failed, status code: " + str(r.status_code) )

这是当前我调用API的方式。

1 个答案:

答案 0 :(得分:0)

我认为您列出附近的单元格有误。它们应位于“ nmr”内部的主单元之后。如果您的服务(主)单元格为17078,则格式应为:

{
  "gsm": [{
  "mcc": 234,
  "mnc": 15,
  "lac": 314,
  "cid": 17078,
  "rxlevel": -52,
  "nmr": [
    {"bsic": 27, "bcch": 33, "rxlevel": -61,"lac":165,"cid":13491},
    {"bsic": 38, "bcch": 26, "rxlevel": -62,"lac":316,"cid":16191},
    {"bsic": 8, "bcch": 30, "rxlevel": -65,"lac":165,"cid":13492},
    {"bsic": 35, "bcch": 36, "rxlevel": -65,"lac":316,"cid":18119},
    {"bsic": 37, "bcch": 29, "rxlevel": -66,"lac":165,"cid":13564},
    {"bsic": 41, "bcch": 37, "rxlevel": -69,"lac":314,"cid":17079}
  ]
  }]
}

列出了格式here