北斗卫星数据监测展示互动系统
This commit is contained in:
@@ -1,58 +1,67 @@
|
||||
import { Helpers } from 'nmea'
|
||||
import { Helpers } from 'nmea';
|
||||
|
||||
const getPosition = (nmea) => {
|
||||
if (!nmea) return
|
||||
if (!nmea) return;
|
||||
|
||||
const { RMC } = nmea
|
||||
const position = { lng: Helpers.parseLongitude(RMC.lon, RMC.lonPole), lat: Helpers.parseLatitude(RMC.lat, RMC.latPole) }
|
||||
const { RMC } = nmea;
|
||||
const position = { lng: Helpers.parseLongitude(RMC.lon, RMC.lonPole), lat: Helpers.parseLatitude(RMC.lat, RMC.latPole) };
|
||||
|
||||
return position
|
||||
}
|
||||
return position;
|
||||
};
|
||||
|
||||
const getBaseInfo = (nmea) => {
|
||||
if (!nmea) return
|
||||
if (!nmea) return;
|
||||
|
||||
const { RMC, GGA } = nmea
|
||||
const { RMC, GGA } = nmea;
|
||||
try {
|
||||
const longitude = (!RMC.lon || !RMC.lonPole) ? '' : Helpers.parseLongitude(RMC.lon, RMC.lonPole)
|
||||
const latitude = (!RMC.lat || !RMC.latPole) ? '' : Helpers.parseLatitude(RMC.lat, RMC.latPole)
|
||||
const altitude = GGA.alt + GGA.altUnit
|
||||
const date = (!RMC.date) ? '' : '20' + RMC.date.slice(4, 6) + '-' + RMC.date.slice(2, 4) + '-' + RMC.date.slice(0, 2)
|
||||
let UTCTime = '', BJTime = ''
|
||||
const longitude = (!RMC.lon || !RMC.lonPole) ? '' : Helpers.parseLongitude(RMC.lon, RMC.lonPole);
|
||||
const latitude = (!RMC.lat || !RMC.latPole) ? '' : Helpers.parseLatitude(RMC.lat, RMC.latPole);
|
||||
const altitude = GGA.alt + GGA.altUnit;
|
||||
const date = (!RMC.date) ? '' : '20' + RMC.date.slice(4, 6) + '-' + RMC.date.slice(2, 4) + '-' + RMC.date.slice(0, 2);
|
||||
let UTCTime = '', BJTime = '';
|
||||
if (RMC.timestamp) {
|
||||
const hour = parseInt(RMC.timestamp.slice(0, 2))
|
||||
const bjHour = (hour + 8) % 24
|
||||
UTCTime = hour.toString().padStart(2, '0') + ':' + RMC.timestamp.slice(2, 4) + ':' + RMC.timestamp.slice(4, 6)
|
||||
BJTime = bjHour.toString().padStart(2, '0') + ':' + RMC.timestamp.slice(2, 4) + ':' + RMC.timestamp.slice(4, 6)
|
||||
const hour = parseInt(RMC.timestamp.slice(0, 2));
|
||||
const bjHour = (hour + 8) % 24;
|
||||
UTCTime = hour.toString().padStart(2, '0') + ':' + RMC.timestamp.slice(2, 4) + ':' + RMC.timestamp.slice(4, 6);
|
||||
BJTime = bjHour.toString().padStart(2, '0') + ':' + RMC.timestamp.slice(2, 4) + ':' + RMC.timestamp.slice(4, 6);
|
||||
}
|
||||
|
||||
const baseInfo = { longitude, latitude, altitude, date, UTCTime, BJTime }
|
||||
return baseInfo
|
||||
const baseInfo = { longitude, latitude, altitude, date, UTCTime, BJTime };
|
||||
return baseInfo;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getSNROption = (nmea) => {
|
||||
if (!nmea) return
|
||||
if (!nmea) return;
|
||||
|
||||
const { GSV, GSA } = nmea
|
||||
const GSVArr = GSV.filter((gsv) => gsv.talker_id === 'BD')
|
||||
const GSAArr = GSA.filter((gsa) => gsa.talker_id === 'BD')
|
||||
const { GSV, GSA } = nmea;
|
||||
const GSVArr = GSV.filter((gsv) => gsv.talker_id === 'BD' || gsv.talker_id === 'GB');
|
||||
const GSAArr = GSA.filter((gsa) => gsa.talker_id === 'BD' || gsa.talker_id === 'GB');
|
||||
|
||||
try {
|
||||
let yAxis_data = [], series_data = []
|
||||
const in_positioning_id = get_in_positioning_id(GSAArr)
|
||||
|
||||
let yAxis_data = [], series_data = [];
|
||||
const in_positioning_id = get_in_positioning_id(GSAArr);
|
||||
GSVArr.forEach(({ satellites }) => {
|
||||
satellites.forEach(({ id, SNRdB }) => {
|
||||
yAxis_data.push(id)
|
||||
if (in_positioning_id.indexOf(parseInt(id)) < 0) {
|
||||
series_data.push([SNRdB, id, false])
|
||||
} else {
|
||||
series_data.push([SNRdB, id, true])
|
||||
let compatibleVersion = false;
|
||||
if (satellites[satellites.length-1].elevationDeg == null && satellites[satellites.length-1].azimuthTrue == null && satellites[satellites.length-1].SNRdB == null) {
|
||||
compatibleVersion = true;
|
||||
let type = satellites.pop();
|
||||
if (type.id == 0 || type.id == 1) {
|
||||
compatibleVersion = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!compatibleVersion) {
|
||||
satellites.forEach(({ id, SNRdB }) => {
|
||||
yAxis_data.push(id);
|
||||
if (in_positioning_id.indexOf(parseInt(id)) < 0) {
|
||||
series_data.push([SNRdB, id, false]);
|
||||
} else {
|
||||
series_data.push([SNRdB, id, true]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const SNROption = {
|
||||
@@ -62,52 +71,52 @@ const getSNROption = (nmea) => {
|
||||
series: [{
|
||||
data: series_data
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
return SNROption
|
||||
return SNROption;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getPlanisphereOption = (nmea) => {
|
||||
if (!nmea) return
|
||||
if (!nmea) return;
|
||||
|
||||
const { GSV, GSA } = nmea
|
||||
const GSVArr = GSV.filter((gsv) => gsv.talker_id === 'BD')
|
||||
const GSAArr = GSA.filter((gsa) => gsa.talker_id === 'BD')
|
||||
const { GSV, GSA } = nmea;
|
||||
const GSVArr = GSV.filter((gsv) => gsv.talker_id === 'BD' || gsv.talker_id === 'GB');
|
||||
const GSAArr = GSA.filter((gsa) => gsa.talker_id === 'BD' || gsa.talker_id === 'GB');
|
||||
|
||||
try {
|
||||
let data = []
|
||||
const in_positioning_id = get_in_positioning_id(GSAArr)
|
||||
let data = [];
|
||||
const in_positioning_id = get_in_positioning_id(GSAArr);
|
||||
|
||||
GSVArr.forEach(({ satellites }) => {
|
||||
satellites.forEach(({ id, elevationDeg, azimuthTrue }) => {
|
||||
if (in_positioning_id.indexOf(parseInt(id)) < 0) {
|
||||
data.push([parseInt(elevationDeg), azimuthTrue, id, false])
|
||||
data.push([parseInt(elevationDeg), azimuthTrue, id, false]);
|
||||
} else {
|
||||
data.push([parseInt(elevationDeg), azimuthTrue, id, true])
|
||||
data.push([parseInt(elevationDeg), azimuthTrue, id, true]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const planisphereOption = {
|
||||
series: [{ data }]
|
||||
}
|
||||
};
|
||||
|
||||
return planisphereOption
|
||||
return planisphereOption;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const get_in_positioning_id = (GSAArr) => {
|
||||
let in_positioning_id = []
|
||||
let in_positioning_id = [];
|
||||
GSAArr.forEach(({ satellites }) => {
|
||||
in_positioning_id.push(...satellites)
|
||||
in_positioning_id.push(...satellites);
|
||||
});
|
||||
|
||||
return in_positioning_id
|
||||
}
|
||||
return in_positioning_id;
|
||||
};
|
||||
|
||||
export { getPosition, getBaseInfo, getSNROption, getPlanisphereOption }
|
||||
export { getPosition, getBaseInfo, getSNROption, getPlanisphereOption };
|
||||
Reference in New Issue
Block a user