package com.mes.interaction.vehicle.model;
|
|
import lombok.Data;
|
|
/**
|
* 车辆位置信息
|
*
|
* @author huang
|
* @since 2025-11-21
|
*/
|
@Data
|
public class VehiclePosition {
|
/**
|
* X坐标
|
*/
|
private Double x;
|
|
/**
|
* Y坐标
|
*/
|
private Double y;
|
|
/**
|
* Z坐标(如果需要)
|
*/
|
private Double z;
|
|
/**
|
* 位置编码(如:POS1, POS2)
|
*/
|
private String positionCode;
|
|
/**
|
* 位置值(PLC中的位置值)
|
*/
|
private Integer positionValue;
|
|
public VehiclePosition() {
|
}
|
|
public VehiclePosition(Double x, Double y) {
|
this.x = x;
|
this.y = y;
|
}
|
|
public VehiclePosition(String positionCode, Integer positionValue) {
|
this.positionCode = positionCode;
|
this.positionValue = positionValue;
|
}
|
|
/**
|
* 计算到目标位置的距离
|
*/
|
public double distanceTo(VehiclePosition target) {
|
if (x == null || y == null || target.x == null || target.y == null) {
|
return 0.0;
|
}
|
double dx = target.x - x;
|
double dy = target.y - y;
|
return Math.sqrt(dx * dx + dy * dy);
|
}
|
}
|