PTopoParser.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * *********************************************************************************************************************
  3. *
  4. * !!
  5. * .F88X
  6. * X8888Y
  7. * .}888888N;
  8. * i888888N; .:! .I$WI:
  9. * R888888I .'N88~ i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
  10. * .R888888I .;N8888~ .X8' "8I.!,/8" !%NY8`"8I8~~8>,88I
  11. * +888888N; .8888888Y "&&8Y.}8,
  12. * ./888888N; .R888888Y .'}~ .>}'.`+> i}! "i' +/' .'i~ !11,.:">, .~]! .i}i
  13. * ~888888%: .I888888l .]88~`1/iY88Ii+1'.R$8$8]"888888888> Y8$ W8E X8E W8888'188Il}Y88$*
  14. * 18888888 E8888881 .]W%8$`R8X'&8%++N8i,8N%N8+l8%` .}8N:.R$RE%N88N%N$K$R 188,FE$8%~Y88I
  15. * .E888888I .i8888888' .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
  16. * 8888888I .,N888888~ ~88i"8W,!N8*.I88.}888%F,i$88"F88" 888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
  17. * i888888N' I888Y ]88;/EX*IFKFK88X K8R .l8W 88Y ~88}'88E&%8W.X8N``]88!.$8K .:W8I
  18. * .i888888N; I8Y .&8$ .X88! i881.:%888>I88 ;88] +88+.';;;;:.Y88X 18N.,88l .+88/
  19. * .:R888888I
  20. * .&888888I Copyright (c) 2009-2020. 博锐尚格科技股份有限公司
  21. * ~8888'
  22. * .!88~ All rights reserved.
  23. *
  24. * ****/
  25. import { SParser } from '@persagy-web/big/lib';
  26. import { Legend, Marker, Relation, ElementData } from "@persagy-web/big"
  27. import { topuFactory } from "./topuFactory"
  28. /**
  29. * 拓扑图解析器
  30. *
  31. * @author 韩耀龙 <han_yao_long@163.com>
  32. */
  33. export class PTopoParser extends SParser {
  34. /**图例节点 */
  35. nodes: any = []; // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
  36. /**图例节点 */ // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
  37. markers: any = [];
  38. /** 管线对象 */
  39. relations: any = [];
  40. constructor() {
  41. super(new topuFactory());
  42. }
  43. /**
  44. * 解析拓扑图绘制数据
  45. *
  46. * @param data 业务空间数据
  47. */
  48. parseData(data: ElementData): void {
  49. // 生成遍历基本图例
  50. if (data.markers && data.markers.length) {
  51. data.markers.forEach((item) => {
  52. this.addMarker(item);
  53. })
  54. }
  55. // 生成遍历Node图例
  56. if (data.nodes && data.nodes.length) {
  57. data.nodes.forEach((item: any) => {
  58. this.addNode(item)
  59. })
  60. }
  61. // 生成遍历关系图例
  62. if (data.relations && data.relations.length) {
  63. data.relations.forEach((item: any) => {
  64. this.addRelation(item)
  65. })
  66. }
  67. }
  68. /**
  69. * 添加生成 mark 实例
  70. *
  71. * @param data Marker 图例类型数据
  72. */
  73. addMarker(data: Marker) {
  74. if (data.properties && data.properties.type) {
  75. switch (data.properties.type) {
  76. case "BaseLine":
  77. this.markers.push(this.factory.createBaseLineEdit(data));
  78. break;
  79. case "BaseText":
  80. this.markers.push(this.factory.createBaseTextEdit(data));
  81. break;
  82. case "BaseImage":
  83. this.markers.push(this.factory.createBaseImageEdit(data));
  84. break;
  85. case "BaseExplain":
  86. this.markers.push(this.factory.createBaseExpainEdit(data));
  87. break;
  88. case "BaseCircle":
  89. this.markers.push(this.factory.createBaseCircleEdit(data));
  90. break;
  91. case "BaseArrow":
  92. this.markers.push(this.factory.createBaseArrow(data));
  93. break;
  94. case "BaseRect":
  95. this.markers.push(this.factory.createBaseRectEdit(data));
  96. break;
  97. case "BasePolygon":
  98. this.markers.push(this.factory.createBasePolygonEdit(data));
  99. break;
  100. case "BaseArrowPolygon":
  101. this.markers.push(this.factory.createBasePolygonArrowEdit(data));
  102. }
  103. }
  104. }
  105. /**
  106. * 添加生成 Node 实例
  107. *
  108. * @param data Legend 图例类型数据
  109. */
  110. addNode(data: Legend) {
  111. let node = null;
  112. if (data.properties && data.properties.type) {
  113. switch (data.properties.type) {
  114. case "BaseEquipment":
  115. node = this.factory.createBaseSEquipment(data)
  116. break;
  117. }
  118. }
  119. if (node) {
  120. this.nodes.push(node);
  121. }
  122. return node
  123. }
  124. /**
  125. * 添加生成 Re 实例
  126. *
  127. * @param data Legend 图例类型数据
  128. */
  129. addRelation(data: Relation) {
  130. let relation = null;
  131. if (data.properties && data.properties.type) {
  132. switch (data.properties.type) {
  133. case "BasePipe":
  134. relation = this.factory.createBasePipe(data)
  135. break;
  136. }
  137. }
  138. if (relation) {
  139. this.relations.push(relation);
  140. }
  141. return relation
  142. }
  143. }