xiepufeng
8 months ago
2 changed files with 141 additions and 1 deletions
@ -0,0 +1,60 @@ |
|||||
|
package com.zc.business.enums; |
||||
|
|
||||
|
/** |
||||
|
* 摄像头方向 |
||||
|
*/ |
||||
|
public enum CameraDirection { |
||||
|
/** |
||||
|
* 摄像头上行 |
||||
|
*/ |
||||
|
UPWARD(0, "上行"), |
||||
|
/** |
||||
|
* 摄像头下行 |
||||
|
*/ |
||||
|
DOWN(1, "下行"), |
||||
|
/** |
||||
|
* 摄像头上下行(双向) |
||||
|
*/ |
||||
|
BIDIRECTIONAL(2, "上下行(双向)"); |
||||
|
|
||||
|
private final int code; |
||||
|
private final String description; |
||||
|
|
||||
|
CameraDirection(int code, String description) { |
||||
|
this.code = code; |
||||
|
this.description = description; |
||||
|
} |
||||
|
|
||||
|
public int getCode() { |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
public String getDescription() { |
||||
|
return description; |
||||
|
} |
||||
|
|
||||
|
// 可选:根据code获取枚举值
|
||||
|
public static CameraDirection fromCode(int code) { |
||||
|
for (CameraDirection direction : values()) { |
||||
|
if (direction.getCode() == code) { |
||||
|
return direction; |
||||
|
} |
||||
|
} |
||||
|
throw new IllegalArgumentException("无效的摄像机方向码: " + code); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public LaneDirection toLaneDirection() { |
||||
|
switch (this) { |
||||
|
case UPWARD: |
||||
|
return LaneDirection.UPWARD; |
||||
|
case DOWN: |
||||
|
return LaneDirection.DOWNWARD; |
||||
|
case BIDIRECTIONAL: |
||||
|
// 假设摄像机双向就映射为车道双向
|
||||
|
return LaneDirection.BIDIRECTIONAL; |
||||
|
default: |
||||
|
throw new IllegalStateException("未知的CameraDirection: " + this); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue