| | |
| | | const fDatas = _factorDatas; |
| | | const factor = _factor; |
| | | drawMesh(fDatas, factor); |
| | | |
| | | if (_polFactorDatasList.length > 0) { |
| | | _polCylinderList.forEach((p) => { |
| | | object3Dlayer.remove(p); |
| | | }); |
| | | _polCylinderList = []; |
| | | _polFactorDatasList.forEach((e, i) => { |
| | | drawHighLight3DLayer(e, _polFactorList[i]); |
| | | }); |
| | | } |
| | | // console.log(map.getZoom()); |
| | | } |
| | | |
| | |
| | | _cylinder = cylinder; |
| | | } |
| | | |
| | | /** |
| | | * 绘制高亮的污染区域3D立面 |
| | | */ |
| | | var _polCylinderList = []; |
| | | var _polFactorDatasList = [], |
| | | //当前选中的监测因子数据 |
| | | _polFactorList = []; |
| | | function drawHighLight3DLayer(fDatas, factor) { |
| | | const offsetH = 100; |
| | | |
| | | const lnglats_GD = fDatas.lnglats_GD; |
| | | const coors = fDatas.coors_GD; |
| | | const heights = factor.heights; |
| | | const colors = factor.colors; |
| | | const bColors = factor.bottomColors; |
| | | |
| | | // eslint-disable-next-line no-undef |
| | | var cylinder = new AMap.Object3D.Mesh(); |
| | | cylinder.backOrFront = 'both'; |
| | | cylinder.transparent = true; |
| | | |
| | | var geometry = cylinder.geometry; |
| | | |
| | | const scale = _getScale(_minH, _maxH); |
| | | for (let i = 0; i < coors.length; i++) { |
| | | var r = lnglats_GD[i]; |
| | | var lastP = lnglats_GD[i - 1]; |
| | | var p = coors[i]; |
| | | var h = (heights[i] - _minH) * scale + _minHeight; |
| | | if (heights[i] == -1) { |
| | | h = -1; |
| | | } |
| | | |
| | | geometry.vertices.push(p.x, p.y, 0 - h); //底部顶点 |
| | | geometry.vertices.push(p.x, p.y, 0 - h - offsetH); //顶部顶点 |
| | | |
| | | if (i > 0) { |
| | | // eslint-disable-next-line no-undef |
| | | var distance = AMap.GeometryUtil.distance(r, lastP); |
| | | //两个数据点最小间隔时间为4s,假设车速按照120km/h计算,4s行驶最大距离作为132米, |
| | | //设定超过1分钟的数据绘制特殊的连线 |
| | | if (distance <= 500 && h != -1) { |
| | | var bottomIndex = i * 2; |
| | | var topIndex = bottomIndex + 1; |
| | | var lastBottomIndex = bottomIndex - 2; |
| | | var lastTopIndex = bottomIndex - 1; |
| | | geometry.faces.push(bottomIndex, topIndex, lastTopIndex); |
| | | geometry.faces.push(bottomIndex, lastBottomIndex, lastTopIndex); |
| | | } |
| | | } |
| | | |
| | | const color = [1, 1, 1, 1]; |
| | | // const color = [1, 0, 0, 0.75]; |
| | | geometry.vertexColors.push.apply(geometry.vertexColors, color); //底部顶点颜色 |
| | | geometry.vertexColors.push.apply(geometry.vertexColors, color); //顶部顶点颜色 |
| | | } |
| | | |
| | | // 7.根据合并选项重置或新增当前缓存数据 |
| | | _polFactorDatasList.push(fDatas); |
| | | _polFactorList.push(factor); |
| | | // if (_polCylinderList.length > 0) { |
| | | // _polCylinderList.forEach((p) => { |
| | | // object3Dlayer.remove(p); |
| | | // }); |
| | | // } |
| | | object3Dlayer.add(cylinder); |
| | | |
| | | _polCylinderList.push(cylinder); |
| | | } |
| | | |
| | | export default { |
| | | clear() { |
| | | map.off('zoomend', onMapZoom); |
| | | if (_cylinder != undefined) { |
| | | object3Dlayer.remove(_cylinder); |
| | | } |
| | | if (_polCylinderList.length > 0) { |
| | | _polCylinderList.forEach((p) => { |
| | | object3Dlayer.remove(p); |
| | | }); |
| | | _polCylinderList = []; |
| | | } |
| | | _polFactorDatasList = []; |
| | | _polFactorList = []; |
| | | }, |
| | | |
| | | drawMesh: drawMesh, |
| | |
| | | if (lnglats_GD.length > 0) { |
| | | map.on('zoomend', onMapZoom); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | drawHighLight3DLayer |
| | | }; |