Skip to content

Commit 22e60f9

Browse files
author
zhaokai
committed
合并版本
2 parents 62aabed + b6ad412 commit 22e60f9

34 files changed

+1616
-1256
lines changed

src/mapboxgl/overlay/FabricLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: zk
55
* @Date: 2022-05-13 11:22:56
66
* @LastEditors: zk
7-
* @LastEditTime: 2022-05-13 11:34:20
7+
* @LastEditTime: 2022-05-24 11:23:51
88
*/
99
import mapboxgl from '@mapgis/mapbox-gl';
1010
import { PlotMapCoordSys } from './fabric/PlotMapCoordSys';

src/mapboxgl/overlay/fabric/PlotMapCoordSys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-04-26 09:05:34
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-05-13 14:42:35
6+
* @LastEditTime: 2022-05-24 09:49:28
77
*/
88

99
/**

src/service/2DPlot/PlotCanvasGroup.js

Lines changed: 1 addition & 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-05-24 11:15:30
7+
* @LastEditTime: 2022-05-24 11:49:53
88
*/
99

1010
import { fabric } from 'fabric';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: your name
33
* @Date: 2021-07-05 11:32:52
4-
* @LastEditTime: 2022-05-24 11:10:01
4+
* @LastEditTime: 2022-05-24 11:49:33
55
* @LastEditors: zk
66
* @Description: In User Settings Edit
77
* @FilePath: \MapGISPlot\src\js\Shapes\PlotObject.js

src/service/2DPlot/Shapes/RegularShapes/PlotRegularObject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2021-11-17 16:12:55
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-05-24 11:19:36
6+
* @LastEditTime: 2022-05-25 16:56:30
77
*/
88

99
import { fabric } from 'fabric';
@@ -17,7 +17,7 @@ const _ = require('lodash');
1717
const PlotRegularObject = fabric.util.createClass(PlotPolylineObject, {
1818
type: 'plotregular',
1919
extendstyleAttributes: ['text'],
20-
hasBorders: false,
20+
hasBorders: true,
2121
isCalcCompareLine: false,
2222
_calcBounds: function _calcBounds(ctx) {
2323
const boundingBox = this._elem.getBounds();

src/service/3DPlot/Draw/DrawPoint.js

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,65 @@
88
*/
99

1010
import DrawObject from "../../../service/PlotBase/Draw/DrawObject";
11-
import { PrimitiveFactory } from "../Primitive/PrimitiveFactory";
11+
import {PrimitiveFactory} from "../Primitive/PrimitiveFactory";
1212
import {CesiumUtil} from "../Utils/CesiumUtil";
1313

1414
export default class DrawPoint extends DrawObject {
15-
constructor(viewer, symbol, plotLayer) {
16-
super();
17-
this._viewer = viewer;
18-
this._symbol = symbol;
19-
this.m_coords = [];
20-
this._primitive = null;
21-
this._plotLayer = plotLayer;
22-
}
15+
constructor(viewer, symbol, plotLayer) {
16+
super();
17+
this._viewer = viewer;
18+
this._symbol = symbol;
19+
this.m_coords = [];
20+
this._primitive = null;
21+
this._plotLayer = plotLayer;
22+
}
2323

24-
addHooks() {
25-
const viewer = this._viewer;
26-
const symbol = this._symbol;
27-
const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
28-
let that = this;
29-
handler.setInputAction((event) => {
30-
const worldPos = viewer.scene.globe.pick(
31-
viewer.camera.getPickRay(event.position),
32-
viewer.scene
33-
);
24+
addHooks() {
25+
const viewer = this._viewer;
26+
const symbol = this._symbol;
27+
const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
28+
let that = this;
29+
handler.setInputAction((event) => {
30+
const worldPos = viewer.scene.globe.pick(
31+
viewer.camera.getPickRay(event.position),
32+
viewer.scene
33+
);
3434

35-
if (!worldPos) return;
35+
if (!worldPos) return;
3636

37-
symbol.getElement().then(function (res) {
38-
that._primitive = PrimitiveFactory.createInstance(symbol.type, {
39-
positions: that.m_coords,
40-
element: res
41-
});
37+
symbol.getElement().then(function (res) {
38+
const {classificationType} = that._symbol;
39+
res.classificationType = classificationType;
40+
const {style} = that._symbol;
41+
if(style){
42+
res.initNodeStyles(style);
43+
}
4244

43-
const lnglat = CesiumUtil.cartesian3ToDegrees(
44-
viewer.scene.globe.ellipsoid,
45-
worldPos
46-
);
47-
that.m_coords.push(lnglat);
48-
that._plotLayer._primitiveCollection.add(that._primitive);
45+
that._primitive = PrimitiveFactory.createInstance(symbol.type, {
46+
positions: that.m_coords,
47+
element: res
48+
});
4949

50-
that._primitive.positions = that.m_coords;
51-
that.disable();
52-
that.fireFinishEvent({ plotObj3D: that._primitive });
53-
});
54-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
50+
const lnglat = CesiumUtil.cartesian3ToDegrees(
51+
viewer.scene.globe.ellipsoid,
52+
worldPos
53+
);
54+
that.m_coords.push(lnglat);
55+
that._plotLayer._primitiveCollection.add(that._primitive);
5556

56-
this._handler = handler;
57-
}
57+
that._primitive.positions = that.m_coords;
58+
that.disable();
59+
that.fireFinishEvent({plotObj3D: that._primitive});
60+
});
61+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
5862

59-
removeHooks() {
60-
const handler = this._handler;
61-
// handler.removeInputAction();
62-
handler.destroy();
63-
this._handler = null;
64-
}
63+
this._handler = handler;
64+
}
65+
66+
removeHooks() {
67+
const handler = this._handler;
68+
// handler.removeInputAction();
69+
handler.destroy();
70+
this._handler = null;
71+
}
6572
}

src/service/3DPlot/Draw/DrawPolyline.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ export default class DrawPolyline extends DrawObject {
5959

6060
symbol.getElement().then(function (res) {
6161
if (!that._isAdded) {
62+
const {classificationType} = that._symbol;
63+
res.classificationType = classificationType;
64+
const {style} = that._symbol;
65+
if(style){
66+
res.initNodeStyles(style);
67+
}
6268
that._primitive = PrimitiveFactory.createInstance(symbol.type, {
6369
positions: that.m_coords,
6470
element: res,

src/service/3DPlot/Primitive/ElementInstance/IrregularElementInstance.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import RegularLineElementInstance from "./RegularLineElementInstance";
1010
import GeomUtil from "../../../../service/PlotUtilBase/Geometry/GeomUtil";
1111

1212
export default class IrregularElementInstance extends RegularLineElementInstance {
13-
svgToGeomInstances(elem, options) {
13+
svgToGeomInstances(elem, options, callback) {
1414
const instances = this.pathElemToGeomInstance(elem, options);
1515
let wallGeomInstances;
1616
if (!options.isOpenWall) {
1717
wallGeomInstances = undefined;
1818
} else {
1919
wallGeomInstances = this.pathElemToWallGeomInstance(elem, options);
2020
}
21-
return { instances, wallGeomInstances };
21+
callback({ instances, wallGeomInstances });
2222
}
2323

2424
pathElemToGeomInstance(elem, options) {

src/service/3DPlot/Primitive/ElementInstance/RegularLineElementInstance.js

Lines changed: 75 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import MainElement from "../../../../service/PlotBase/SvgLoader/element/extend/M
1212
import { defined } from "../../../PlotUtilBase/Check";
1313

1414
export default class RegularLineElementInstance extends SvgElementInstance {
15-
svgToGeomInstances(elem, options) {
16-
const instances = super.svgToGeomInstances(elem, options);
17-
const wallGeomInstances = this.generateWallGeometryInstances(elem, options);
18-
return { instances, wallGeomInstances };
15+
svgToGeomInstances(elem, options, callback) {
16+
let that = this;
17+
super.svgToGeomInstances(elem, options, function (instances, wallOffsetHeights) {
18+
const wallGeomInstances = that.generateWallGeometryInstances(elem, options, wallOffsetHeights);
19+
callback({ instances, wallGeomInstances });
20+
});
1921
}
2022

2123
/**
@@ -24,17 +26,24 @@ export default class RegularLineElementInstance extends SvgElementInstance {
2426
* @param {*} options
2527
* @returns
2628
*/
27-
generateWallGeometryInstances(elem, options) {
29+
generateWallGeometryInstances(elem, options, wallOffsetHeights) {
2830
if (!options.isOpenWall) return undefined;
2931

3032
const paths = [];
3133
elem.getPathElem(paths);
3234

33-
let instances = [];
35+
let instances = [], wallIndex = 0, wallOffsetHeightArray;
3436
for (let i = 0; i < paths.length; i += 1) {
37+
const {type} = paths[i];
38+
if(wallOffsetHeights instanceof Array && wallOffsetHeights.length > 0 && (type === 'extendline' || type === 'mainline')){
39+
wallOffsetHeightArray = wallOffsetHeights[wallIndex];
40+
wallIndex++;
41+
}
42+
3543
const wallGeomInstance = this.pathElemToWallGeomInstance(
3644
paths[i],
37-
options
45+
options,
46+
wallOffsetHeightArray
3847
);
3948
if (!defined(wallGeomInstance)) continue;
4049
if (Array.isArray(wallGeomInstance)) {
@@ -46,7 +55,7 @@ export default class RegularLineElementInstance extends SvgElementInstance {
4655
return instances;
4756
}
4857

49-
pathElemToWallGeomInstance(pathElem, options) {
58+
pathElemToWallGeomInstance(pathElem, options, wallOffsetHeights) {
5059
const wallHeight = options.dimModHeight;
5160
const wallColor = options.wallColor;
5261
const cesiumWallColor = Cesium.ColorGeometryInstanceAttribute.fromColor(
@@ -55,31 +64,60 @@ export default class RegularLineElementInstance extends SvgElementInstance {
5564

5665
const parts = pathElem.cacheCoords || pathElem.getCoords();
5766
const instances = [];
58-
for (let i = 0; i < parts.length; i += 1) {
59-
const coords = parts[i];
60-
61-
const degreeArrayHeights = [];
62-
for (let j = 0; j < coords.length; j += 1) {
63-
const coord = coords[j];
64-
const res = CesiumUtil.WebMercatorUnProject(coord.x, coord.y);
65-
degreeArrayHeights.push(res.x, res.y, wallHeight);
67+
if(wallOffsetHeights instanceof Array && wallOffsetHeights.length > 0){
68+
for (let i = 0; i < parts.length; i += 1) {
69+
const coords = parts[i];
70+
71+
const degreeArrayHeights = [];
72+
for (let j = 0; j < coords.length; j += 1) {
73+
const coord = coords[j];
74+
const res = CesiumUtil.WebMercatorUnProject(coord.x, coord.y);
75+
degreeArrayHeights.push(res.x, res.y, wallHeight + wallOffsetHeights[i][j]);
76+
}
77+
78+
const wallGeometry = Cesium.WallGeometry.createGeometry(
79+
new Cesium.WallGeometry({
80+
positions:
81+
Cesium.Cartesian3.fromDegreesArrayHeights(degreeArrayHeights),
82+
})
83+
);
84+
85+
instances.push(
86+
new Cesium.GeometryInstance({
87+
geometry: wallGeometry,
88+
attributes: {
89+
color: cesiumWallColor,
90+
},
91+
})
92+
);
6693
}
94+
}else {
95+
for (let i = 0; i < parts.length; i += 1) {
96+
const coords = parts[i];
6797

68-
const wallGeometry = Cesium.WallGeometry.createGeometry(
69-
new Cesium.WallGeometry({
70-
positions:
71-
Cesium.Cartesian3.fromDegreesArrayHeights(degreeArrayHeights),
72-
})
73-
);
98+
const degreeArrayHeights = [];
99+
for (let j = 0; j < coords.length; j += 1) {
100+
const coord = coords[j];
101+
const res = CesiumUtil.WebMercatorUnProject(coord.x, coord.y);
102+
degreeArrayHeights.push(res.x, res.y, wallHeight);
103+
}
104+
105+
const wallGeometry = Cesium.WallGeometry.createGeometry(
106+
new Cesium.WallGeometry({
107+
positions:
108+
Cesium.Cartesian3.fromDegreesArrayHeights(degreeArrayHeights),
109+
})
110+
);
74111

75-
instances.push(
76-
new Cesium.GeometryInstance({
77-
geometry: wallGeometry,
78-
attributes: {
79-
color: cesiumWallColor,
80-
},
81-
})
82-
);
112+
instances.push(
113+
new Cesium.GeometryInstance({
114+
geometry: wallGeometry,
115+
attributes: {
116+
color: cesiumWallColor,
117+
},
118+
})
119+
);
120+
}
83121
}
84122

85123
return instances;
@@ -94,6 +132,7 @@ export default class RegularLineElementInstance extends SvgElementInstance {
94132
const lineWidth=style.lineWidth
95133
const strokeWidthSize = lineWidth*this.globelScale/2;
96134
const _fillWidthSize = this.fillDefaultWidth*this.globelScale/2
135+
const {offsetHeights} = options;
97136

98137
const parts = pathElem.cacheCoords || pathElem.getCoords();
99138

@@ -102,13 +141,17 @@ export default class RegularLineElementInstance extends SvgElementInstance {
102141
if (stroke && stroke !== "none") {
103142

104143
for (let i = 0; i < parts.length; i += 1) {
144+
let offsetHeight;
145+
if(offsetHeights){
146+
offsetHeight = offsetHeights[i];
147+
}
105148
const coords = parts[i];
106149
const geometry = this._generateStrokeGeometry(
107150
coords,
108-
isMainElement ? strokeWidthSize - 5 : strokeWidthSize
151+
isMainElement ? strokeWidthSize - 5 : strokeWidthSize,
152+
offsetHeight
109153
);
110154
geometry.modDetail=pathElem.getGeometryDetail(i)
111-
112155
const instance = this._generateCesiumGeometryInstance(
113156
pathElem,
114157
geometry,

0 commit comments

Comments
 (0)