Skip to content

Commit e3d70f6

Browse files
author
zhaokai
committed
Merge branch 'webclient_plot' into dev
2 parents 91f7e26 + fc90a76 commit e3d70f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+713
-665
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"proj4": "2.3.15",
9999
"promise-polyfill": "^8.2.3",
100100
"qs": "^6.9.4",
101-
"webfont-matcher": "^1.1.0"
101+
"webfont-matcher": "^1.1.0",
102+
"svg-pathdata": "^6.0.0"
102103
}
103104
}

src/cesiumjs/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,13 @@ export {
454454
OGCWMTSInfo,
455455
OGCWMSInfo
456456
};
457+
458+
import {
459+
SymbolManager3D,
460+
PlotCanvas3D
461+
} from "./Plot/index"
462+
463+
export {
464+
SymbolManager3D,
465+
PlotCanvas3D
466+
}

src/mapboxgl/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { MapExtend } from './MapExtend';
22
export { MapExtend };
33

4-
import { Common, BaseServer, Extend, MRFS, MRGS, MRFWS, MRMS, MRCS, Info, PostGIS, CloudDisk } from '@mapgis/webclient-es6-service';
5-
export { Common, BaseServer, Extend, MRFS, MRGS, MRFWS, MRMS, MRCS, Info, PostGIS, CloudDisk };
4+
import { Common, BaseServer, Extend, MRFS, MRGS, MRFWS , MRMS, MRCS, Info, PostGIS, CloudDisk } from '@mapgis/webclient-es6-service';
5+
export { Common, BaseServer, Extend, MRFS, MRGS, MRFWS , MRMS, MRCS, Info, PostGIS, CloudDisk };
66

77
import { mapboxgl, MapDocLayer, MapTileLayer, MapWmsLayer, MapWMTSLayer, MapVectorLayer, ArcGISLayer, TDTLayer } from './layer';
88
export { mapboxgl, MapDocLayer, MapTileLayer, MapWmsLayer, MapWMTSLayer, MapVectorLayer, ArcGISLayer, TDTLayer };

src/mapboxgl/overlay/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
* @Description:
3+
* @Author: zk
4+
* @Date: 2022-04-25 11:32:23
5+
* @LastEditors: Do not edit
6+
* @LastEditTime: 2022-04-25 20:11:41
7+
*/
18
/**
29
* @module 客户端可视化
310
*/

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:16:16
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/2DPlot/Shapes/IrregularShapes/PlotIrregularShape.js

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2021-11-18 15:08:54
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-06-13 19:14:58
6+
* @LastEditTime: 2022-06-22 10:16:55
77
*/
88
import { fabric } from 'fabric';
99
import PlotPolylineObject from '../PlotPolylineObject';
@@ -17,11 +17,20 @@ const PlotIrregularShape = fabric.util.createClass(PlotPolylineObject, {
1717
});
1818
return boundingBox;
1919
},
20+
_calcStrokeOrFillGeometry(coords) {
21+
// 非规则符号使用外部设置函数进行控制点填充
22+
const strokeCoords = this._elem.applyFuncToStorkeGeometry(coords);
23+
// 非规则符号使用完整几何进行填充
24+
const fillCoords= this._elem.applyFuncToFillGeometry(coords);
25+
return { strokeCoords, fillCoords };
26+
},
2027
_pathElementRender: function _pathElementRender(ctx, coords) {
2128
const style = this._elem.getContextStyle();
2229
const lineWidth = this.calcMapScaleLineWidth(style.lineWidth);
2330
style.lineWidth = lineWidth;
24-
this._pointsToPath(ctx, style, coords);
31+
32+
const { strokeCoords, fillCoords } = this._calcStrokeOrFillGeometry(coords);
33+
this._pointsToPath(ctx, style, strokeCoords, fillCoords);
2534
},
2635
_comparePathElementRender: function _comparePathElementRender(ctx, coords) {
2736
const style = this._elem.getContextStyle();
@@ -39,8 +48,41 @@ const PlotIrregularShape = fabric.util.createClass(PlotPolylineObject, {
3948
})
4049
);
4150
if (_compareStyle) {
42-
this._pointsToPath(ctx, _compareStyle, coords);
51+
const { strokeCoords, fillCoords } = this._calcStrokeOrFillGeometry(coords);
52+
this._pointsToPath(ctx, style, strokeCoords, fillCoords);
53+
}
54+
},
55+
56+
_pointsToPath: function _pointsToPath(ctx, style, strokeCoords, fillCoords) {
57+
// stroke
58+
ctx.save();
59+
const strokeCoordsPnts = strokeCoords.filter((s) => s.length !== 0);
60+
for (let j = 0; j < strokeCoordsPnts.length; j += 1) {
61+
const tempPnts = strokeCoordsPnts[j];
62+
const tempPntsLen = tempPnts.length;
63+
ctx.beginPath();
64+
ctx.moveTo(tempPnts[0].x + this.m_offsetX, tempPnts[0].y + this.m_offsetY);
65+
for (let m = 1; m < tempPntsLen; m += 1) {
66+
ctx.lineTo(tempPnts[m].x + this.m_offsetX, tempPnts[m].y + this.m_offsetY);
67+
}
68+
this._drawPath(ctx, Object.assign({},style, { fillStyle: 'none' }));
69+
}
70+
ctx.restore();
71+
72+
// fill
73+
ctx.save();
74+
const fillPnts = fillCoords.filter((s) => s.length !== 0);
75+
for (let j = 0; j < fillPnts.length; j += 1) {
76+
const tempPnts = fillPnts[j];
77+
const tempPntsLen = tempPnts.length;
78+
ctx.beginPath();
79+
ctx.moveTo(tempPnts[0].x + this.m_offsetX, tempPnts[0].y + this.m_offsetY);
80+
for (let m = 1; m < tempPntsLen; m += 1) {
81+
ctx.lineTo(tempPnts[m].x + this.m_offsetX, tempPnts[m].y + this.m_offsetY);
82+
}
83+
this._drawPath(ctx, Object.assign({},style, { strokeStyle: 'none' }));
4384
}
85+
ctx.restore();
4486
},
4587
_render(ctx) {
4688
const coords = this._elem.cacheCoords || this._elem.getCoords();

src/service/2DPlot/Shapes/PlotPolylineObject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const PlotPolylineObject = fabric.util.createClass(PlotObject, {
158158
for (let m = 1; m < tempPntsLen; m += 1) {
159159
ctx.lineTo(tempPnts[m].x + this.m_offsetX, tempPnts[m].y + this.m_offsetY);
160160
}
161-
if (GeomUtil.PointEqualFuzzy(startPnt.x, startPnt.y, endPnt.x, endPnt.y)) {
161+
if (GeomUtil.PointEqualFuzzy(startPnt.x, startPnt.y, endPnt.x, endPnt.y,1e-18)) {
162162
ctx.closePath();
163163
}
164164

src/service/3DPlot/PlotLayer3D.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class PlotLayer3D extends Observable {
132132
if (!plotLayer) {
133133
return undefined;
134134
}
135-
135+
136136
let index = this._getPlotIndexById(id, plotLayer);
137137
const {_primitives} = plotLayer;
138138
if (index !== undefined) {
@@ -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

0 commit comments

Comments
 (0)