随着我国对北斗卫星导航系统的大力发展,北斗导航系统已经跻身国际四大导航系统之列。正好小编对导航系统的理论知识也有一定的掌握,这里从老牌的GPS卫星导航系统入手,做了一套导航卫星可视化系统(界面),给大家分享一下,先看下主界面。
主要技术分为两大块:
1)卫星轨道数据的获取计算
卫星轨道数据,是从BKG(https://igs.bkg.bund.de/)数据中心下载的rinex广播星历,通过卫星轨道计算算法公式得到外推坐标,最终生成CZML数据,在前端通过Cesium加载。这一块轨道计算基于Qt平台使用C++完成,封装成.so文件,供Java调用。
2)数据的可视化展示
数据可视化展示,后端采用的是springboot框架和postgresql数据库,前端使用Vue框架和Cesium三维地图引擎以及echart完成开发。整个服务部署在云服务器上。
卫星轨道计算
卫星数据从数据中心定时下载,然后在Qt平台下完成文件读取,数据解算,格式化输出等一系列处理。
数据的可视化展示
数据可视化后端使用的是springboot框架和postgresql数据库开发。前端主要使用Vue框架和Cesium三维地图引擎以及echart开发。后端主要包括使用quartz定时任务框架对卫星数据定时下载,调用Qt生成的动态链接库计算卫星外推坐标。采用rabbitmq消息中间件将计算的卫星外推坐标推送到前端。
定时任务
/**
* 在构造函数中创建调度器,加载任务
**/
public void init() throws SchedulerException {
//1 创建调度器 必须从容器中拿,如果new的话,则无法注入,还是脱离了spring容器
this.scheduler = schedulerFactoryBean.getScheduler();
//2 创建JobDetail实例,并与PrintWordsJob类绑定(Job执行的内容)
this.jobDetail = JobBuilder.newJob(ephDWJob.getClass())
.withIdentity("ephJobDetailDataDownLoadIdentity", "ephJobDetailDataDownLoadIdentityGroup1")
.usingJobData("ephJobDetailDataDownLoadJobData", "ephJobDetailDataDownLoadValue")
.build();
//3 构建触发trigger实例,每隔1s执行一次
// 根据不同环境启用不同的任务策略
String cronSchedule = "0 */10 * * * ?";
switch (SpringUtil.getActiveProfiles()[0]){
case "test":
case "dev":
cronSchedule = "31 42 * * * ?";
break;
case "prod":
cronSchedule = "0 20 */2 * * ?";
break;
}
this.cronTrigger = TriggerBuilder.newTrigger()
.withIdentity("ephTriggerDownLoadIdentity", "ephTriggerDownLoadIdentityGroup1")
.usingJobData("ephTriggerDownLoadJobData", "ephTriggerDownLoadDataValue")
//.withSchedule(CronScheduleBuilder.cronSchedule("55 56 23 * * ?")) //每秒钟执行一次
//.withSchedule(CronScheduleBuilder.cronSchedule("0 20 */2 * * ?")) //每两个小时的第20分钟0秒执行一次
.withSchedule(CronScheduleBuilder.cronSchedule(cronSchedule)) //每5分钟的第0秒执行一次
.build();
this.triggerKey = TriggerKey.triggerKey("ephTriggerDownLoadIdentity", "ephTriggerDownLoadIdentityGroup1");
this.jobKey = JobKey.jobKey("ephJobDetailDataDownLoadIdentity", "ephJobDetailDataDownLoadIdentityGroup1");
}
消息推送
for(int i=0; i<czmlList.size(); i++){
rabbitTemplate.convertAndSend(
"myOriDirectExchange",
"my.ori.direct.routing",
czmlList.get(i));
}
rabbitTemplate.convertAndSend("myOriDirectExchange",
"my.ori.direct.routing",
"1");
}
JAVA调用Qt动态链接库
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary(
"/opt/oriFolder/lib/libsatelliteEphSo.so",
CLibrary.class);
//获取最新的卫星列表 GPS, BD, Galileo, GLONASS
String getSatelliteList(String ss);
//对每一个系统的卫星做外推计算
//32个
String getGPSSatelliteInfoByPRN(int prn, int secondIndex);
//61个
String getBDSatelliteInfoByPrn(int prn, int secondIndex);
//36个
String getGalileoSatelliteInfoByPrn(int prn, int secondIndex);
//24个
String getGLONASSSatelliteInfoByPrn(int prn, int secondIndex);
//分批将起始星历数据发送回来
String getSateEphByPrnP1(int prn);
String getSateEphByPrnP2(int prn);
String getSateEphByPrnP3(int prn);
String getSateEphByPrnP4(int prn);
String getGPSSateEphByPRN(int prn);
// 根据卫星类型和编号获取历元信息
String getSatelliteEphByTypeAndPRN(String type, int prn, int flag);
}
前端使用stomp.js接收后端推送过来的数据,在Cesium中以CZML的形式加载。由于分享篇幅有限的原因,仅截出部分代码。
cesiumInit(){
window.viewer = new Cesium.Viewer("cesiumContent");
this.flyHome();
},
flyHome(){
window.viewer.camera.flyTo({
destination: new Cesium.Cartesian3.fromDegrees(118, 30, 120000000),
orientation:{
heading:0,
pitch: Cesium.Math.toRadians(-90),
roll:0
},
duration: 6
});
},
/*
*@description: websocket连接
*/
webSocketInit(){
if (window.WebSocket) {
console.log("您的浏览器支持websocket");
var ws = new WebSocket(`ws://${this.websocketUrl}:${this.websocketPort}/ws`);
this.client = this.$stomp.over(ws);
this.client.heartbeat.incoming = 0;
this.client.heartbeat.outgoing = 1 * 60 * 1000;
this.client.debug = null;
this.connect();
}
},
/*
*@description: 连接 rabbitmq
*/
connect() {
let headers = {
login: this.websocketuser,
passcode: this.websocketpassword,
};
this.client.connect(headers, this.on_connected, this.on_failed);
},
/*
*@description: 连接 rabbitmq 成功
*/
on_connected(){
console.log(`websocket已连接: ${this.websocketUrl}:${this.websocketPort}`);
this.client.subscribe("/queue/myOriDirectQueue", this.on_rabbitMQRevCallback, this.on_failed);
},
至此,整个可视化界面完成。系统部署在 访问地址。欢迎大家访问。PS:本来想做一套完整的可视化系统,实现数据的回看、查询、卫星的跟踪,对地面的扫描,还有卫星模型想通过Three.js用代码生成,结果越做越跑偏了,仅做了这样的一个可视化界面。不过后续也将在此基础上着重在这几个方面继续开发,同时把北斗、格洛纳斯、伽利略导航系统都囊括进来。
有喜欢的朋友欢迎收藏点赞转发,有业务需求的朋友也欢迎私信我,web全栈开发。