123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- import { SParser } from '@persagy-web/big/lib';
- import { Legend, Marker, Relation, ElementData } from "@persagy-web/big"
- import { topuFactory } from "./topuFactory"
- export class PTopoParser extends SParser {
-
- nodes: any = [];
-
- markers: any = [];
-
- relations: any = [];
- constructor() {
- super(new topuFactory());
- }
-
- parseData(data: ElementData): void {
-
- if (data.markers && data.markers.length) {
- data.markers.forEach((item) => {
- this.addMarker(item);
- })
- }
-
- if (data.nodes && data.nodes.length) {
- data.nodes.forEach((item: any) => {
- this.addNode(item)
- })
- }
-
- if (data.relations && data.relations.length) {
- data.relations.forEach((item: any) => {
- this.addRelation(item)
- })
- }
- }
-
- addMarker(data: Marker) {
- if (data.properties && data.properties.type) {
- switch (data.properties.type) {
- case "BaseLine":
- this.markers.push(this.factory.createBaseLineEdit(data));
- break;
- case "BaseText":
- this.markers.push(this.factory.createBaseTextEdit(data));
- break;
- case "BaseImage":
- this.markers.push(this.factory.createBaseImageEdit(data));
- break;
- case "BaseExplain":
- this.markers.push(this.factory.createBaseExpainEdit(data));
- break;
- case "BaseCircle":
- this.markers.push(this.factory.createBaseCircleEdit(data));
- break;
- case "BaseArrow":
- this.markers.push(this.factory.createBaseArrow(data));
- break;
- case "BaseRect":
- this.markers.push(this.factory.createBaseRectEdit(data));
- break;
- case "BasePolygon":
- this.markers.push(this.factory.createBasePolygonEdit(data));
- break;
- case "BaseArrowPolygon":
- this.markers.push(this.factory.createBasePolygonArrowEdit(data));
- }
- }
- }
-
- addNode(data: Legend) {
- let node = null;
- if (data.properties && data.properties.type) {
- switch (data.properties.type) {
- case "BaseEquipment":
- node = this.factory.createBaseSEquipment(data)
- break;
- }
- }
- if (node) {
- this.nodes.push(node);
- }
- return node
- }
-
- addRelation(data: Relation) {
- let relation = null;
- if (data.properties && data.properties.type) {
- switch (data.properties.type) {
- case "BasePipe":
- relation = this.factory.createBasePipe(data)
- break;
- }
- }
- if (relation) {
- this.relations.push(relation);
- }
- return relation
- }
- }
|