feat 对齐数据

This commit is contained in:
Ironsp
2026-09-17 16:26:30 +08:00
parent c1d2958095
commit faf4ea1155
5 changed files with 82 additions and 60 deletions

View File

@@ -1,12 +1,14 @@
/** 热力图图层与色阶工具 */
/** 热力图图层与色阶工具(字段与 RtkTrack / MockRtkPoint 对齐) */
export type HeatmapLayerKey = 'compaction' | 'speed' | 'temperature' | 'passCount'
import type { MockRtkPoint } from '@/mock/rtkTrack'
export type HeatmapLayerKey = 'compaction_value' | 'speed' | 'steel_wheel_temp' | 'pass_count'
export const HEATMAP_LAYERS: { key: HeatmapLayerKey, label: string }[] = [
{ key: 'compaction', label: '压实度' },
{ key: 'compaction_value', label: '压实度' },
{ key: 'speed', label: '压实速度' },
{ key: 'temperature', label: '温度' },
{ key: 'passCount', label: '碾压遍数' },
{ key: 'steel_wheel_temp', label: '温度' },
{ key: 'pass_count', label: '碾压遍数' },
]
/** 色阶阈值:0–90 绿,90–95 黄,95–100 红 */
@@ -22,46 +24,37 @@ export function colorByScore(score: number): string {
}
/** 各图层原始值映射到 0–100 分,统一用 90/95 分色 */
export function layerScore(
layer: HeatmapLayerKey,
point: { compaction: number, speed: number, temperature: number, passCount: number },
): number {
export function layerScore(layer: HeatmapLayerKey, point: MockRtkPoint): number {
switch (layer) {
case 'compaction':
return point.compaction
case 'compaction_value':
return point.compaction_value
case 'speed': {
// 目标约 4~5 km/h 偏优,偏快偏慢降分
const ideal = 4.2
const diff = Math.abs(point.speed - ideal)
return Math.max(0, Math.min(100, 100 - diff * 18))
}
case 'temperature': {
// 目标约 150℃
case 'steel_wheel_temp': {
const ideal = 150
const diff = Math.abs(point.temperature - ideal)
const diff = Math.abs(point.steel_wheel_temp - ideal)
return Math.max(0, Math.min(100, 100 - diff * 2.5))
}
case 'passCount':
// 目标遍数 6
return Math.max(0, Math.min(100, (point.passCount / 6) * 100))
case 'pass_count':
return Math.max(0, Math.min(100, (point.pass_count / 6) * 100))
default:
return 0
}
}
export function layerRawText(
layer: HeatmapLayerKey,
point: { compaction: number, speed: number, temperature: number, passCount: number },
): string {
export function layerRawText(layer: HeatmapLayerKey, point: MockRtkPoint): string {
switch (layer) {
case 'compaction':
return `${point.compaction}%`
case 'compaction_value':
return `${point.compaction_value}%`
case 'speed':
return `${point.speed}km/h`
case 'temperature':
return `${point.temperature}℃`
case 'passCount':
return `${point.passCount}遍`
case 'steel_wheel_temp':
return `${point.steel_wheel_temp}℃`
case 'pass_count':
return `${point.pass_count}遍`
default:
return '-'
}

View File

@@ -56,7 +56,7 @@ const emit = defineEmits<{
压实度
</text>
<text class="value">
{{ point.compaction }}%
{{ point.compaction_value }}%
</text>
</view>
<view class="row">
@@ -64,7 +64,7 @@ const emit = defineEmits<{
温度
</text>
<text class="value">
{{ point.temperature }}℃
{{ point.steel_wheel_temp }}℃
</text>
</view>
<view class="row">
@@ -72,7 +72,15 @@ const emit = defineEmits<{
碾压遍数
</text>
<text class="value">
{{ point.passCount }}遍
{{ point.pass_count }}遍
</text>
</view>
<view class="row">
<text class="label">
合格率
</text>
<text class="value">
{{ point.qualified_rate }}%
</text>
</view>

View File

@@ -142,7 +142,7 @@ function draw() {
ctx.setLineWidth(ROLLER_WIDTH)
for (let i = 1; i < coords.length; i++) {
ctx.beginPath()
ctx.setStrokeStyle(compactionColor(path[i].compaction))
ctx.setStrokeStyle(compactionColor(path[i].compaction_value))
ctx.moveTo(coords[i - 1].x, coords[i - 1].y)
ctx.lineTo(coords[i].x, coords[i].y)
ctx.stroke()