Skip to content

Commit aa4291b

Browse files
committed
【杨琨】【贴地代码】
1 parent 4c634d1 commit aa4291b

File tree

16 files changed

+838
-745
lines changed

16 files changed

+838
-745
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export default class DrawPoint extends DrawObject {
3535
if (!worldPos) return;
3636

3737
symbol.getElement().then(function (res) {
38+
const {classificationType} = that._symbol;
39+
res.classificationType = classificationType;
3840
that._primitive = PrimitiveFactory.createInstance(symbol.type, {
3941
positions: that.m_coords,
4042
element: res

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ 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;
6264
that._primitive = PrimitiveFactory.createInstance(symbol.type, {
6365
positions: that.m_coords,
6466
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class RegularLineElementInstance extends SvgElementInstance {
3535
let instances = [], wallIndex = 0, wallOffsetHeightArray;
3636
for (let i = 0; i < paths.length; i += 1) {
3737
const {type} = paths[i];
38-
if(type === 'extendline' || type === 'mainline'){
38+
if(wallOffsetHeights instanceof Array && wallOffsetHeights.length > 0 && (type === 'extendline' || type === 'mainline')){
3939
wallOffsetHeightArray = wallOffsetHeights[wallIndex];
4040
wallIndex++;
4141
}

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

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -11,80 +11,80 @@ import {CesiumUtil} from "../../Utils/CesiumUtil";
1111
import SvgElementInstance from "./SvgElementInstance";
1212

1313
export default class RegularSurfaceElementInstance extends SvgElementInstance {
14-
svgToGeomInstances(elem,options) {
15-
const { surfaceBorderWidth }=options
16-
this.polylineOutInstance = null;
17-
this.polygonRect = new Bounds();
18-
this._borderColor = Cesium.Color.RED;
19-
this._surfaceBorderWidth = surfaceBorderWidth;
20-
21-
const pathElements = [];
22-
const instances = [];
23-
24-
elem.getPathElem(pathElements);
25-
26-
const styleObject = pathElements[0].getContextStyle();
27-
if (styleObject) {
28-
if (styleObject.strokeStyle !== "none") {
29-
this._borderColor = Cesium.Color.fromCssColorString(
30-
styleObject.strokeStyle
31-
);
32-
}
33-
34-
// 边线线宽为像素值,界面显示效果太差,因此边线宽度取固定值
35-
// if(pathElements[0].getStyle('stroke-width').hasValue()){
36-
// const v=Math.round(pathElements[0].getStyle('stroke-width').getNumber())/2
37-
// this._surfaceBorderWidth=v
38-
// }
39-
14+
svgToGeomInstances(elem, options, callback) {
15+
const {surfaceBorderWidth} = options
16+
this.polylineOutInstance = null;
17+
this.polygonRect = new Bounds();
18+
this._borderColor = Cesium.Color.RED;
19+
this._surfaceBorderWidth = surfaceBorderWidth;
20+
21+
const pathElements = [];
22+
const instances = [];
23+
24+
elem.getPathElem(pathElements);
25+
26+
const styleObject = pathElements[0].getContextStyle();
27+
if (styleObject) {
28+
if (styleObject.strokeStyle !== "none") {
29+
this._borderColor = Cesium.Color.fromCssColorString(
30+
styleObject.strokeStyle
31+
);
32+
}
33+
34+
// 边线线宽为像素值,界面显示效果太差,因此边线宽度取固定值
35+
// if(pathElements[0].getStyle('stroke-width').hasValue()){
36+
// const v=Math.round(pathElements[0].getStyle('stroke-width').getNumber())/2
37+
// this._surfaceBorderWidth=v
38+
// }
39+
40+
}
41+
42+
pathElements.forEach((s) => {
43+
instances.push(this.pathElemToGeomInstance(s));
44+
});
45+
46+
const exportInstance = instances.flat();
47+
callback({
48+
instances: exportInstance,
49+
polylineOutInstance: this.polylineOutInstance,
50+
polygonRect: this.polygonRect,
51+
borderColor: this._borderColor
52+
});
4053
}
4154

42-
pathElements.forEach((s) => {
43-
instances.push(this.pathElemToGeomInstance(s));
44-
});
45-
46-
const exportInstance = instances.flat();
47-
return {
48-
instances: exportInstance,
49-
polylineOutInstance: this.polylineOutInstance,
50-
polygonRect:this.polygonRect,
51-
borderColor:this._borderColor
52-
};
53-
}
54-
55-
pathElemToGeomInstance(elem) {
56-
const _parts = elem.cacheCoords || elem.getCoords();
57-
58-
const polygonparts = _parts
59-
.flatMap((s) =>
60-
s.map((t) => {
61-
this.polygonRect.addPnt(t.x, t.y);
62-
const latlng = CesiumUtil.WebMercatorUnProject(t.x, t.y);
63-
return [latlng.x, latlng.y];
64-
})
65-
)
66-
.flat();
67-
68-
const polygon = new Cesium.PolygonGeometry({
69-
polygonHierarchy: new Cesium.PolygonHierarchy(
70-
Cesium.Cartesian3.fromDegreesArray(polygonparts)
71-
),
72-
});
73-
74-
const groundPolyline = new Cesium.GroundPolylineGeometry({
75-
positions: Cesium.Cartesian3.fromDegreesArray(polygonparts),
76-
width: this._surfaceBorderWidth,
77-
});
78-
79-
const instance = new Cesium.GeometryInstance({
80-
geometry: polygon,
81-
});
82-
83-
this.polylineOutInstance = new Cesium.GeometryInstance({
84-
geometry: groundPolyline,
85-
});
86-
87-
return instance;
88-
}
55+
pathElemToGeomInstance(elem) {
56+
const _parts = elem.cacheCoords || elem.getCoords();
57+
58+
const polygonparts = _parts
59+
.flatMap((s) =>
60+
s.map((t) => {
61+
this.polygonRect.addPnt(t.x, t.y);
62+
const latlng = CesiumUtil.WebMercatorUnProject(t.x, t.y);
63+
return [latlng.x, latlng.y];
64+
})
65+
)
66+
.flat();
67+
68+
const polygon = new Cesium.PolygonGeometry({
69+
polygonHierarchy: new Cesium.PolygonHierarchy(
70+
Cesium.Cartesian3.fromDegreesArray(polygonparts)
71+
),
72+
});
73+
74+
const groundPolyline = new Cesium.GroundPolylineGeometry({
75+
positions: Cesium.Cartesian3.fromDegreesArray(polygonparts),
76+
width: this._surfaceBorderWidth,
77+
});
78+
79+
const instance = new Cesium.GeometryInstance({
80+
geometry: polygon,
81+
});
82+
83+
this.polylineOutInstance = new Cesium.GeometryInstance({
84+
geometry: groundPolyline,
85+
});
86+
87+
return instance;
88+
}
8989

9090
}

0 commit comments

Comments
 (0)