Skip to content

Commit fc90a76

Browse files
author
zhaokai
committed
验证节点,验证element
1 parent 71c2df7 commit fc90a76

File tree

10 files changed

+33
-18
lines changed

10 files changed

+33
-18
lines changed

src/service/2DPlot/PlotLayer2D.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: zk
55
* @Date: 2022-05-13 10:34:57
66
* @LastEditors: zk
7-
* @LastEditTime: 2022-06-13 17:08:19
7+
* @LastEditTime: 2022-06-22 10:01:17
88
*/
99

1010
import { DrawPlotObjectFactory2D } from './Draw/DrawPlotObjectFactory2D';
@@ -278,14 +278,15 @@ class PlotLayer2D {
278278
const symbolManager = SymbolManager.instance;
279279

280280
const leaf = symbolManager.getLeafByID(id);
281+
if(!leaf) return null;
281282

282283
const element = await leaf.getElement();
284+
if(!element) return null
283285
const plotObj = PlotObjectFactory.createInstance(element.type, {
284286
element,
285287
positions: element.positions,
286288
canvas: this
287289
});
288-
289290
plotObj.fromGeoJSON(geoFeature);
290291
this.addPlot(plotObj);
291292
}

src/service/2DPlot/PlotLayer2DGroup.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: zk
55
* @Date: 2022-05-13 11:01:10
66
* @LastEditors: zk
7-
* @LastEditTime: 2022-06-15 19:53:34
7+
* @LastEditTime: 2022-06-22 10:01:40
88
*/
99

1010
import { fabric } from 'fabric';
@@ -246,7 +246,11 @@ export const PlotLayer2DGroup = fabric.util.createClass(fabric.Canvas, {
246246
drawUtilPlotObject(id, options) {
247247
const symbol = SymbolManager.instance;
248248
const leaf = symbol.getLeafByID(id);
249+
250+
if(!leaf) return null;
251+
249252
return leaf.getElement().then((element) => {
253+
if(!element)return null;
250254
const plotObj = PlotObjectFactory.createInstance(element.type, {
251255
element,
252256
positions: options.positions,

src/service/3DPlot/PlotLayer3D.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,10 @@ class PlotLayer3D extends Observable {
253253
const symbolManager = SymbolManager.instance;
254254

255255
const leaf = symbolManager.getLeafByID(id);
256+
if(!leaf) return null;
256257

257258
leaf.getElement().then(function (element) {
259+
if(!element) return null;
258260
const primitive = PrimitiveFactory.createInstance(element.type, {
259261
positions: element.positions,
260262
element,

src/service/3DPlot/PlotLayer3DGroup.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ class PlotLayer3DGroup {
216216
drawUtilPlotObject(id, options) {
217217
const symbol = SymbolManager.instance;
218218
const leaf = symbol.getLeafByID(id);
219+
if(!leaf)return null;
219220
return leaf.getElement().then((element) => {
221+
if(!element) return null;
220222
// 待修改问题:positions传参无效
221223
// const primitive = PrimitiveFactory.createInstance(element.type, {
222224
// positions:options.positions,
@@ -233,7 +235,9 @@ class PlotLayer3DGroup {
233235
});
234236
}
235237
removeDrawUtilPlotObject(primitive) {
236-
this._utilPlotCanvas.removePlot(primitive);
238+
if(primitive){
239+
this._utilPlotCanvas.removePlot(primitive);
240+
}
237241
}
238242
/**
239243
* @function: Module:3DPlot.PlotLayer3DGroup.getPlotObjectById

src/service/PlotBase/SvgLoader/element/extend/ReplaceRectElement.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: your name
33
* @Date: 2021-11-04 17:02:07
4-
* @LastEditTime: 2022-05-23 19:00:31
4+
* @LastEditTime: 2022-06-22 10:00:07
55
* @LastEditors: zk
66
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
77
* @FilePath: \MapGISPlotBase\src\base\SvgLoader\element\extend\ReplacedGroupElement.js
@@ -45,6 +45,8 @@ export default class ReplaceRectElement extends RectElement {
4545

4646
const symbol = symbolManager.getLeafByID(parseInt(id,10));
4747

48+
if(!symbol) return;
49+
4850
const that = this;
4951

5052
symbol.getSvg().then(function (res) {

src/service/PlotBase/SvgLoader/element/extend/ReplacedGroupElement.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* @Author: your name
33
* @Date: 2021-11-04 17:02:07
4-
* @LastEditTime: 2022-05-10 15:25:05
5-
* @LastEditors: Do not edit
4+
* @LastEditTime: 2022-06-22 09:59:46
5+
* @LastEditors: zk
66
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
77
* @FilePath: \MapGISPlotBase\src\base\SvgLoader\element\extend\ReplacedGroupElement.js
88
*/
@@ -35,6 +35,8 @@ export default class ReplacedGroupElement extends GElement {
3535

3636
const symbol = symbolManager.getLeafByID(parseInt(id,10));
3737

38+
if(!symbol) return;
39+
3840
var that = this;
3941

4042
symbol.getSvg().then(function (res) {

src/service/PlotBase/SymbolManager/ServerSymbolManager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default class ServerSymbolManager {
2828
return leaves[i];
2929
}
3030
}
31-
31+
LogTool.warn(`符号库id为${symbolId}的节点不存在`)
3232
return null;
3333

3434
}
@@ -56,7 +56,6 @@ export default class ServerSymbolManager {
5656
LogTool.error(symbolId, "对应的符号不存在");
5757
return undefined;
5858
}
59-
6059
return symbol.getImage();
6160
}
6261
}

src/service/PlotBase/SymbolManager/SymbolBase.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export default class SymbolBase {
4949
return false;
5050
}
5151

52-
if (!defined(json.id)) {
53-
LogTool.warn("json.id is not defined");
54-
}
55-
5652
this.id = json.id;
5753

5854
this.name = json.name;

src/service/PlotBase/SymbolManager/SymbolManager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* @Description:
33
* @Version: 2.0
44
* @Date: 2021-07-22 11:46:16
5-
* @LastEditTime: 2022-01-14 09:49:26
5+
* @LastEditTime: 2022-06-22 09:54:09
66
* @Author: xinxiao
7-
* @LastEditors: Do not edit
7+
* @LastEditors: zk
88
*/
99
import {defined} from "../../PlotUtilBase/Check";
1010
import LogTool from "../../PlotUtilBase/Log/LogTool";
@@ -59,7 +59,7 @@ export default class SymbolManager {
5959
return leaves[i];
6060
}
6161
}
62-
62+
LogTool.warn(`符号库id为${id}的节点不存在!`)
6363
return null;
6464
}
6565

src/service/PlotBase/SymbolManager/SymbolNode.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Description:
33
* @Version: 2.0
44
* @Date: 2021-07-22 11:46:54
5-
* @LastEditTime: 2022-06-15 14:47:07
5+
* @LastEditTime: 2022-06-22 09:39:55
66
* @Author: xinxiao
77
* @LastEditors: zk
88
*/
@@ -69,7 +69,12 @@ export default class SymbolNode extends SymbolBase {
6969
*/
7070
async getElement() {
7171
const elem = ElementFactory.createInstance(await this.getSvg(), this.type);
72-
elem.symbolManager(this);
72+
73+
if(elem){
74+
elem.symbolManager(this);
75+
}else{
76+
LogTool.warn(`符号类型${this.type}未注册!`)
77+
}
7378
return elem;
7479
}
7580

0 commit comments

Comments
 (0)