【增加坐标切换信息】
This commit is contained in:
parent
d042470c8f
commit
203e1cc521
@ -14,7 +14,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -45,7 +44,7 @@ public class LineGraphicDataRepository {
|
||||
// 构建区段
|
||||
sectionInitLineGraph(publishGi.getLineId(), lineDataMap, storage);
|
||||
// 构建道岔
|
||||
switchInitLineGraph(publishGi.getLineId(), lineDataMap, storage);
|
||||
turnoutInitLineGraph(publishGi.getLineId(), lineDataMap, storage);
|
||||
// 设置公里标
|
||||
setUpKilometerCode(publishGi.getLineId(), lineDataMap, storage);
|
||||
lineGraphMap.put(publishGi.getLineId(), lineDataMap);
|
||||
@ -130,23 +129,47 @@ public class LineGraphicDataRepository {
|
||||
* @param dataMap 缓存数据
|
||||
* @param storage 地图构建数据
|
||||
*/
|
||||
private static void switchInitLineGraph(
|
||||
private static void turnoutInitLineGraph(
|
||||
Integer lineId,
|
||||
Map<String, Map<String, Builder>> dataMap,
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
Map<String, Builder> cacheSwitchMap =
|
||||
storage.getTurnoutsList().stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
t -> t.getCommon().getId(),
|
||||
t -> {
|
||||
DeviceInfoProto.Turnout.Builder switchBuilder =
|
||||
DeviceInfoProto.Turnout.newBuilder();
|
||||
switchBuilder.setId(t.getCommon().getId());
|
||||
switchBuilder.setCode(t.getCode());
|
||||
switchBuilder.addAllKilometerSystem(t.getKilometerSystemList());
|
||||
return switchBuilder;
|
||||
}));
|
||||
Map<String, CoordinateConvertor> convertorMap =
|
||||
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
||||
Map<String, Builder> cacheSwitchMap = new HashMap<>(storage.getTurnoutsList().size());
|
||||
storage.getTurnoutsList().stream()
|
||||
.forEach(
|
||||
t -> {
|
||||
List<KilometerSystem> systemList =
|
||||
t.getKilometerSystemList().stream()
|
||||
.filter(k -> StringUtils.isNotEmpty(k.getCoordinateSystem()))
|
||||
.toList();
|
||||
DeviceInfoProto.Turnout.Builder turnoutBuilder = DeviceInfoProto.Turnout.newBuilder();
|
||||
turnoutBuilder.setId(t.getCommon().getId());
|
||||
turnoutBuilder.setCode(t.getCode());
|
||||
turnoutBuilder.addAllKilometerSystem(systemList);
|
||||
cacheSwitchMap.put(t.getCommon().getId(), turnoutBuilder);
|
||||
// 从道岔中生成坐标转换对象
|
||||
if (systemList.size() > 1) {
|
||||
for (int i = 0, len = systemList.size(); i < len; i++) {
|
||||
KilometerSystem si = systemList.get(i);
|
||||
for (int j = i + 1; j < len; j++) {
|
||||
KilometerSystem sj = systemList.get(j);
|
||||
// 坐标系不一致时,生成转换对象
|
||||
if (!Objects.equals(sj.getCoordinateSystem(), si.getCoordinateSystem())) {
|
||||
String convertorKey =
|
||||
CoordinateConvertor.generateConvertorKey(
|
||||
sj.getCoordinateSystem(), si.getCoordinateSystem());
|
||||
if (!convertorMap.containsKey(convertorKey)) {
|
||||
convertorMap.put(
|
||||
convertorKey,
|
||||
CoordinateConvertor.generate(
|
||||
si, sj.getCoordinateSystem(), sj.getKilometer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
dataMap.put(DeviceType.Turnout.name(), cacheSwitchMap);
|
||||
}
|
||||
|
||||
@ -163,8 +186,8 @@ public class LineGraphicDataRepository {
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
// 初始化转换信息
|
||||
initConvertorCoordinate(lineId, dataMap, storage);
|
||||
Map<String, Builder> sectionMap = dataMap.get(DeviceType.Section.name());
|
||||
Map<String, Builder> turnoutMap = dataMap.get(DeviceType.Turnout.name());
|
||||
Map<String, Builder> sectionMap = dataMap.getOrDefault(DeviceType.Section.name(), Map.of());
|
||||
Map<String, Builder> turnoutMap = dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of());
|
||||
storage.getAxleCountingsList().stream()
|
||||
.filter(ac -> StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem()))
|
||||
.forEach(
|
||||
@ -212,7 +235,14 @@ public class LineGraphicDataRepository {
|
||||
Integer lineId,
|
||||
Map<String, Map<String, Builder>> dataMap,
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
Map<String, Builder> turnoutMap = dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of());
|
||||
// 强制转换道岔
|
||||
Map<String, Builder> turnoutMap = dataMap.get(DeviceType.Turnout.name());
|
||||
if (CollectionUtils.isEmpty(turnoutMap)) {
|
||||
return;
|
||||
}
|
||||
Map<String, CoordinateConvertor> convertorMap =
|
||||
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
||||
// 从计轴中转换信息
|
||||
storage
|
||||
.getAxleCountingsList()
|
||||
.forEach(
|
||||
@ -225,8 +255,7 @@ public class LineGraphicDataRepository {
|
||||
DeviceType.Turnout.equals(ref.getDeviceType())
|
||||
&& turnoutMap.containsKey(ref.getId()))
|
||||
.map(ref -> (DeviceInfoProto.Turnout.Builder) turnoutMap.get(ref.getId()))
|
||||
.filter(turnout -> turnout.getKilometerSystemList().size() != 0)
|
||||
.map(turnout -> turnout.getKilometerSystemList().get(0))
|
||||
.map(t -> t.getKilometerSystemList().get(0))
|
||||
.toList();
|
||||
// 如果关联多个道岔
|
||||
if (kilometerSystemList.size() > 1) {
|
||||
@ -252,8 +281,6 @@ public class LineGraphicDataRepository {
|
||||
String convertorKey =
|
||||
CoordinateConvertor.generateConvertorKey(
|
||||
axleSystem.getCoordinateSystem(), diffSystem.getCoordinateSystem());
|
||||
Map<String, CoordinateConvertor> convertorMap =
|
||||
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
||||
if (!convertorMap.containsKey(convertorKey)) {
|
||||
// 计轴与相同坐标系岔心之间差值
|
||||
long diffValue = axleSystem.getKilometer() - sameSystem.getKilometer();
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 1ab5b1ae7fd44e5b31e424407f3b783b40190c95
|
||||
Subproject commit 8fd000d45907f94410786c3bd6c1ab37edbe91e8
|
Loading…
Reference in New Issue
Block a user