lau572
10 months ago
6 changed files with 214 additions and 2 deletions
@ -0,0 +1,44 @@ |
|||||
|
package com.ruoyi.common.utils; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.math.RoundingMode; |
||||
|
|
||||
|
/** |
||||
|
* @Description 桩号距离计算工具 |
||||
|
* |
||||
|
* @author liuwenge |
||||
|
* @date 2024/1/17 14:43 |
||||
|
*/ |
||||
|
public class StakeMarkUtils { |
||||
|
|
||||
|
/** |
||||
|
* @Description 计算桩号距离(公里) |
||||
|
* |
||||
|
* @author liuwenge |
||||
|
* @date 2024/1/17 14:45 |
||||
|
* @param startStakeMark 开始桩号 |
||||
|
* @param endStakeMark 结束桩号 |
||||
|
* @return java.math.BigDecimal 距离 |
||||
|
*/ |
||||
|
public static BigDecimal getKilometre(String startStakeMark, String endStakeMark){ |
||||
|
String start = startStakeMark.toLowerCase().replace("k","").replace("+","."); |
||||
|
String end = endStakeMark.toLowerCase().replace("k","").replace("+","."); |
||||
|
return new BigDecimal(end).subtract(new BigDecimal(start)).setScale(3, RoundingMode.HALF_UP); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Description 计算桩号距离(米) |
||||
|
* |
||||
|
* @author liuwenge |
||||
|
* @date 2024/1/17 15:04 |
||||
|
* @param startStakeMark 开始桩号 |
||||
|
* @param endStakeMark 结束桩号 |
||||
|
* @return java.math.BigDecimal 距离 |
||||
|
*/ |
||||
|
public static BigDecimal getMetre(String startStakeMark, String endStakeMark){ |
||||
|
String start = startStakeMark.toLowerCase().replace("k","").replace("+","."); |
||||
|
String end = endStakeMark.toLowerCase().replace("k","").replace("+","."); |
||||
|
return new BigDecimal(end).subtract(new BigDecimal(start)).multiply(new BigDecimal("1000")).setScale(0, RoundingMode.HALF_UP); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue