From 41e59960ee94254d9920ddee4c9d0237888f5085 Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Thu, 14 Nov 2024 14:46:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E9=87=8C=E8=A1=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/station/Station.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/graphics/station/Station.ts b/src/graphics/station/Station.ts index 12b2394..ed3934a 100644 --- a/src/graphics/station/Station.ts +++ b/src/graphics/station/Station.ts @@ -195,14 +195,26 @@ export class Station extends JlGraphic { codeGraph.anchor.set(0.5); const kilometerCode = this.datas.kilometerSystem?.kilometer || 12345678; if (Math.floor(kilometerCode * 1000).toString().length > 3) { - const kiloBit = Math.floor(Number(kilometerCode) / 1000000).toString(); - kilometerGraph.text = - 'K' + - kiloBit + - '+' + - ( - Number(kilometerCode.toString().substring(kiloBit.length)) / 1000 - ).toFixed(3); + if (Number(kilometerCode) > 0) { + const kiloBit = Math.floor(Number(kilometerCode) / 1000000).toString(); + kilometerGraph.text = + 'K' + + kiloBit + + '+' + + ( + Number(kilometerCode.toString().substring(kiloBit.length)) / 1000 + ).toFixed(3); + } else { + const fuKilometerCode = Number(kilometerCode) * -1; + const kiloBit = Math.floor(fuKilometerCode / 1000000).toString(); + kilometerGraph.text = + 'K-' + + kiloBit + + '-' + + ( + Number(kilometerCode.toString().substring(kiloBit.length)) / 1000 + ).toFixed(3); + } } else { kilometerGraph.text = (kilometerCode * 1000).toFixed(3); }