【坐标转换逻辑修改】
This commit is contained in:
parent
c059ac912f
commit
4a37fd70b2
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.ats.cache;
|
||||
|
||||
import club.joylink.xiannccda.dto.protos.DeviceInfoProto;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.Turnout;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.KilometerSystem;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType;
|
||||
@ -24,7 +25,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
public class LineGraphicDataRepository {
|
||||
|
||||
/** 线路数据信息 */
|
||||
private static final Map<Integer, Map<String, Map<String, ? extends Builder>>> lineGraphMap =
|
||||
private static final Map<Integer, Map<String, Map<String, Builder>>> lineGraphMap =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
/** 线路各坐标系转换关系 */
|
||||
@ -51,7 +52,7 @@ public class LineGraphicDataRepository {
|
||||
if (publishGi.getLineId() != null) {
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage =
|
||||
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(publishGi.getProto());
|
||||
Map<String, Map<String, ? extends Builder>> lineDataMap = new HashMap<>();
|
||||
Map<String, Map<String, Builder>> lineDataMap = new HashMap<>();
|
||||
// 构建区段
|
||||
sectionInitLineGraph(publishGi.getLineId(), lineDataMap, storage);
|
||||
// 构建道岔
|
||||
@ -73,9 +74,9 @@ public class LineGraphicDataRepository {
|
||||
* @return 公里标
|
||||
*/
|
||||
public static List<Long> getSectionDefaultKmCodeList(int lineId, String sectionName) {
|
||||
Map<String, Map<String, ? extends Builder>> lineDataMap = lineGraphMap.get(lineId);
|
||||
Map<String, Map<String, Builder>> lineDataMap = lineGraphMap.get(lineId);
|
||||
if (CollectionUtils.isNotEmpty(lineDataMap)) {
|
||||
Map<String, ? extends Builder> sectionMap = lineDataMap.get(DeviceType.Section.name());
|
||||
Map<String, Builder> sectionMap = lineDataMap.get(DeviceType.Section.name());
|
||||
for (Builder v : sectionMap.values()) {
|
||||
DeviceInfoProto.Section.Builder builder = (DeviceInfoProto.Section.Builder) v;
|
||||
if (Objects.equals(builder.getCode(), sectionName)) {
|
||||
@ -95,18 +96,19 @@ public class LineGraphicDataRepository {
|
||||
*/
|
||||
private static void sectionInitLineGraph(
|
||||
Integer lineId,
|
||||
Map<String, Map<String, ? extends Builder>> dataMap,
|
||||
Map<String, Map<String, Builder>> dataMap,
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
// 地图
|
||||
List<Section> sectionList = storage.getSectionList();
|
||||
// 存储的地图数据
|
||||
Map<String, DeviceInfoProto.Section.Builder> cacheSectionMap =
|
||||
new HashMap<>(sectionList.size());
|
||||
Map<String, Builder> cacheSectionMap = new HashMap<>(sectionList.size());
|
||||
sectionList.forEach(
|
||||
section -> {
|
||||
String sid = section.getCommon().getId();
|
||||
DeviceInfoProto.Section.Builder sectionBuilder =
|
||||
cacheSectionMap.getOrDefault(sid, DeviceInfoProto.Section.newBuilder().setId(sid));
|
||||
cacheSectionMap.containsKey(sid)
|
||||
? (DeviceInfoProto.Section.Builder) cacheSectionMap.get(sid)
|
||||
: DeviceInfoProto.Section.newBuilder().setId(sid);
|
||||
sectionBuilder.setCode(section.getCode());
|
||||
sectionBuilder.setType(section.getSectionType());
|
||||
List<String> childList = section.getChildrenList();
|
||||
@ -114,7 +116,9 @@ public class LineGraphicDataRepository {
|
||||
childList.forEach(
|
||||
id -> {
|
||||
DeviceInfoProto.Section.Builder cb =
|
||||
cacheSectionMap.getOrDefault(id, DeviceInfoProto.Section.newBuilder());
|
||||
cacheSectionMap.containsKey(id)
|
||||
? (DeviceInfoProto.Section.Builder) cacheSectionMap.get(id)
|
||||
: DeviceInfoProto.Section.newBuilder().setId(id);
|
||||
cb.setId(id);
|
||||
sectionBuilder.addChildren(cb);
|
||||
cacheSectionMap.put(id, cb);
|
||||
@ -134,9 +138,9 @@ public class LineGraphicDataRepository {
|
||||
*/
|
||||
private static void switchInitLineGraph(
|
||||
Integer lineId,
|
||||
Map<String, Map<String, ? extends Builder>> dataMap,
|
||||
Map<String, Map<String, Builder>> dataMap,
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
Map<String, DeviceInfoProto.Turnout.Builder> cacheSwitchMap =
|
||||
Map<String, Builder> cacheSwitchMap =
|
||||
storage.getTurnoutsList().stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
@ -161,14 +165,12 @@ public class LineGraphicDataRepository {
|
||||
*/
|
||||
private static void setUpKilometerCode(
|
||||
Integer lineId,
|
||||
Map<String, Map<String, ? extends Builder>> dataMap,
|
||||
Map<String, Map<String, Builder>> dataMap,
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
// 初始化转换信息
|
||||
initConvertorCoordinate(lineId, dataMap, storage);
|
||||
Map<String, ? extends Builder> sectionMap =
|
||||
dataMap.getOrDefault(DeviceType.Section.name(), Map.of());
|
||||
Map<String, ? extends Builder> turnoutMap =
|
||||
dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of());
|
||||
Map<String, Builder> sectionMap = dataMap.get(DeviceType.Section.name());
|
||||
Map<String, Builder> turnoutMap = dataMap.get(DeviceType.Turnout.name());
|
||||
storage.getAxleCountingsList().stream()
|
||||
.filter(ac -> StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem()))
|
||||
.forEach(
|
||||
@ -214,10 +216,9 @@ public class LineGraphicDataRepository {
|
||||
*/
|
||||
private static void initConvertorCoordinate(
|
||||
Integer lineId,
|
||||
Map<String, Map<String, ? extends Builder>> dataMap,
|
||||
Map<String, Map<String, Builder>> dataMap,
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
Map<String, ? extends Builder> turnoutMap =
|
||||
dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of());
|
||||
Map<String, Builder> turnoutMap = dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of());
|
||||
storage
|
||||
.getAxleCountingsList()
|
||||
.forEach(
|
||||
|
Loading…
Reference in New Issue
Block a user