基站定位API:无GPS环境下实现快速定位

一、接口功能:三网基站,秒级定位

该API直连三大运营商基站数据库,通过输入基站编码(MNC、LAC、CellID),即可返回:

  • 经纬度坐标(WGS84坐标系,可直接用于地图标注)

  • 覆盖半径(精度范围,单位:米)

  • 详细地址(省市区+道路+地标描述)

二、实战演示:根据基站信息查询位置

下面通过 C# 代码调用该接口

using System;
using System.IO;
using System.Net;
using System.Text;
using System.Security.Cryptography.X509Certificates;

public class CellLocationTest
{
    private const string host = "https://market.aliyun.com/detail/cmapi00065871"#接口地址;
    private const string path = "/cell/index";
    private const string method = "GET";
    private const string appcode = "你自己的AppCode";   // 替换为真实 AppCode

    public static void Main(string[] args)
    {
        string querys = "mnc=0&lac=33204&cellid=202944490";
        string url = host + path;
        if (!string.IsNullOrEmpty(querys))
        {
            url = url + "?" + querys;
        }

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (host.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = 
                new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        string result = reader.ReadToEnd();
        Console.WriteLine(result);
    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, 
        X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}

三、返回字段解析

字段类型说明
latstring纬度(WGS84坐标系)
lngstring经度(WGS84坐标系)
radiusint定位精度半径(米),值越小精度越高
addrstring结构化地址描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值