fix:更新gps数据处理

This commit is contained in:
nnbcccscdscdsc
2026-04-11 13:56:37 +08:00
parent 59990b0e7c
commit 906428fc3b
5 changed files with 42 additions and 6 deletions

View File

@@ -53,6 +53,10 @@ function formatNumber(value: number) {
return value.toFixed(6)
}
function formatHexText(value: string | null | undefined) {
return value || '暂无'
}
async function loadAmapScript(key: string, securityJsCode: string) {
if (window.AMap) {
return window.AMap
@@ -161,8 +165,10 @@ function updateMap(gps: GpsTelemetry | null) {
[
'<div style="min-width: 240px; padding: 6px 2px; line-height: 1.75; font-size: 13px; color: #152033;">',
'<div style="margin-bottom: 8px; font-size: 14px; font-weight: 700; color: #0f172a;">Robot GPS 定位</div>',
`<div><span style="color: #667085;">原始 WGS84:</span> <strong style="color: #0f172a;">${formatNumber(rawLatitude)}, ${formatNumber(rawLongitude)}</strong></div>`,
`<div><span style="color: #667085;">WGS84:</span> <strong style="color: #0f172a;">${formatNumber(rawLatitude)}, ${formatNumber(rawLongitude)}</strong></div>`,
`<div><span style="color: #667085;">高德 GCJ-02:</span> <strong style="color: #0f172a;">${formatNumber(lat)}, ${formatNumber(lng)}</strong></div>`,
`<div><span style="color: #667085;">纬度原始 8B:</span> <strong style="color: #0f172a;">${formatHexText(gps.raw_latitude_hex)}</strong></div>`,
`<div><span style="color: #667085;">经度原始 8B:</span> <strong style="color: #0f172a;">${formatHexText(gps.raw_longitude_hex)}</strong></div>`,
`<div><span style="color: #667085;">UTC 时间:</span> <strong style="color: #0f172a;">${gps.utc_time || '--:--:--'}</strong></div>`,
`<div><span style="color: #667085;">卫星数:</span> <strong style="color: #0f172a;">${gps.satellites ?? '未知'}</strong></div>`,
`<div><span style="color: #667085;">海拔:</span> <strong style="color: #0f172a;">${gps.altitude_m ?? '未知'} m</strong></div>`,
@@ -206,6 +212,17 @@ const rawCoordinateText = computed(() => {
return `${formatNumber(props.gps.latitude)}, ${formatNumber(props.gps.longitude)}`
})
const rawLatitudeHexText = computed(() => formatHexText(props.gps?.raw_latitude_hex))
const rawLongitudeHexText = computed(() => formatHexText(props.gps?.raw_longitude_hex))
const coordinateMetaText = computed(() => {
if (!props.gps) {
return '暂无'
}
return `${props.gps.coordinate_system} / ${props.gps.raw_coordinate_format}`
})
const metaText = computed(() => {
if (!props.gps) {
return '暂无'
@@ -268,13 +285,21 @@ watch(
<div class="details">
<div class="detail-card">
<span>原始 WGS84</span>
<span>WGS84 坐标</span>
<strong>{{ rawCoordinateText }}</strong>
</div>
<div class="detail-card">
<span>高德 GCJ-02</span>
<strong>{{ amapCoordinateText }}</strong>
</div>
<div class="detail-card">
<span>纬度原始 8 字节</span>
<strong class="mono">{{ rawLatitudeHexText }}</strong>
</div>
<div class="detail-card">
<span>经度原始 8 字节</span>
<strong class="mono">{{ rawLongitudeHexText }}</strong>
</div>
<div class="detail-card">
<span>UTC 时间</span>
<strong>{{ gps?.utc_time ?? '--:--:--' }}</strong>
@@ -284,8 +309,8 @@ watch(
<strong>{{ metaText }}</strong>
</div>
<div class="detail-card">
<span>坐标系</span>
<strong>{{ gps?.coordinate_system ?? 'WGS84' }}</strong>
<span>坐标系 / 格式</span>
<strong>{{ coordinateMetaText }}</strong>
</div>
<div class="detail-card">
<span>最近刷新</span>
@@ -397,6 +422,11 @@ h2 {
word-break: break-word;
}
.detail-card strong.mono {
font-family: "JetBrains Mono", "SFMono-Regular", monospace;
font-size: 14px;
}
.map-canvas {
position: relative;
min-height: 420px;