# 简介
918博天堂官网封装了高精度实时定位服务相关 API(Ntrip 协议)的 C++ SDK,降低开发者集成难度,能方便快速调试和接入高精度实时定位服务。
# 开发环境
操作系统:Linux version 4.13.0-36-generic (x86-64/amd64) 及以上
g++ 版本:5.4.0 及以上
# 配置安装
1.下载 SDK 包,starlocation-ntrip-linux-cpp-sdk.zip 包是 x86_64 位系统下编译封装的;如果需要其他嵌入式系统环境的 SDK 包,请联系我们,可以发邮件写明嵌入式 linux 环境或指定的交叉编译工具。
2.so 库引入:libstarlocation-ntrip.so(在 SDK 包的 lib 目录下)。
3.头文件引入:StarLocationData.h 和 StarLocationFactory.h(在 SDK 包的 include 目录下)。
4.我们提供 sample 程序和 makefile 文件供编译参考(在 SDK 包的 sample 目录下)。
# 示例
#include <iostream>
#include <iomanip>
#include <unistd.h>
using namespace std;
#include "../../include/StarLocationFactory.h"
int main()
{
// 1. Please add the username and password:
string username = "***";
string password = "***";
/*
* 2. Please choose the type of the service:
* - STAR_LIGHT - Sub-meter Level
* - STAR_PLUS - Sub-meter Level Plus
* - STAR_PRO - Centimeter Level
* Sample code for Sub-meter Level Plus Service is as follows:
*/
int service_level = STAR_PRO;
StarLocationFactory star_pro;
bool get_pro_result = star_pro.getStarLocationService(username, password, service_level);
if(!get_pro_result)
{
// call onState function to see the fail reason
star_pro.onState();
return -1;
}
// 3. Send gga data. The data source of GGA is mainly read from the location module. It will not send a illegal gga data or a initialized gga data.
// gga_demo is a gga sample
string gga_demo = "$GPGGA,021354.80,2230.01222498,N,11353.07619291,E,1,09,1.8,-1.3276,M,-3.8652,M,,*5D";
int send_result = star_pro.sendGGA(gga_demo);
if(send_result == ILLEGAL_GGA)
{
cout << gga_demo << " is illegal gga data can not get rtcm!" << endl;
}
else if(send_result == INITIAL_GGA)
{
cout << gga_demo << " is initialized gga data can not get rtcm!" << endl;
}
sleep(2);
// 4. Request RTCM data.
VrsRtcmData get_rtcm = star_pro.requestLocRtcm();
if(get_rtcm.rtcm_length <= 0)
{
cout << "Get RTCM fail!" << endl;
}
else
{
// Show RTCM data in hex.
cout << "getRtcm in length: " << get_rtcm.rtcm_length << endl;
for(int i = 0; i < get_rtcm.rtcm_length; ++i)
{
cout << hex << setw(2) << setfill('0') << (int)(unsigned char)get_rtcm.rtcm_buffer[i] << dec;
}
cout << endl << endl;
}
// 5. Close service
star_pro.close();
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
更多示例,请下载工程示例 (opens new window)。
# 接口说明
← androidSdk 相关下载 →