# 简介
星舆封装了高精度实时定位服务相关 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
#include
#include
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 相关下载 →