import { map, object3Dlayer } from './index_old';
|
import calculate from './calculate';
|
|
var _defaultDeg = 30,
|
_sector = undefined,
|
_sectorViews = {};
|
|
function clearSector() {
|
var list = [];
|
for (const key in _sectorViews) {
|
list.push(_sectorViews[key]);
|
}
|
if (list.length > 0) {
|
map.remove(list);
|
_sectorViews = {};
|
}
|
if (_sector) {
|
object3Dlayer.remove(_sector);
|
}
|
}
|
|
export default {
|
drawSector(fDatas, i) {
|
const lnglat = fDatas.lnglats_GD[i];
|
let windDir = fDatas.factor[17].datas[i].factorData;
|
let windSpeed = fDatas.factor[16].datas[i].factorData;
|
if (!windDir) windDir = 0;
|
if (!windSpeed) windSpeed = 0;
|
|
if (windSpeed > 10) {
|
return;
|
}
|
if (_sector != undefined) {
|
clearSector();
|
}
|
|
// eslint-disable-next-line no-undef
|
var sector = new AMap.Object3D.Mesh();
|
sector.transparent = true;
|
sector.backOrFront = 'both';
|
|
var unit = 5;
|
|
var sDeg = windDir - _defaultDeg; //扇形起始角度(以上方作为0度)
|
// sDeg = sDeg < 0 ? sDeg + 360 : sDeg
|
var eDeg = windDir + _defaultDeg; //扇形结束角度
|
// eDeg = eDeg < 0 ? eDeg + 360 : eDeg
|
|
var distance = windSpeed * 10 * 60; //半径(风速*时间)
|
var lnglat2 = calculate.getLatLon(lnglat, distance, sDeg);
|
var lnglat3 = calculate.getLatLon(lnglat, distance, windDir);
|
var lnglat4 = calculate.getLatLon(lnglat, distance, eDeg);
|
var list = calculate.parse2LngLat([lnglat, lnglat2, lnglat3, lnglat4]);
|
|
var distance2 = windSpeed * 5 * 60; //半径(风速*时间)
|
var lnglat2_2 = calculate.getLatLon(lnglat, distance2, sDeg);
|
var lnglat2_3 = calculate.getLatLon(lnglat, distance2, windDir);
|
var lnglat2_4 = calculate.getLatLon(lnglat, distance2, eDeg);
|
var list2 = calculate.parse2LngLat([lnglat2_2, lnglat2_3, lnglat2_4]);
|
|
var p0 = calculate.lngLatToGeodeticCoord([lnglat])[0];
|
var geometry = sector.geometry;
|
|
var count = distance / unit;
|
var unitDeg = (eDeg - sDeg) / count;
|
for (let i = 0; i < count; i++) {
|
var angle1 = sDeg + unitDeg * i;
|
var angle2 = sDeg + unitDeg * (i + 1);
|
|
var l1 = calculate.getLatLon(lnglat, distance, angle1);
|
var l2 = calculate.getLatLon(lnglat, distance, angle2);
|
var l3 = calculate.getLatLon(lnglat, distance2, angle1);
|
var l4 = calculate.getLatLon(lnglat, distance2, angle2);
|
|
var coors = calculate.lngLatToGeodeticCoord([l1, l2, l3, l4]);
|
l1 = coors[0];
|
l2 = coors[1];
|
l3 = coors[2];
|
l4 = coors[3];
|
|
// 内测扇形
|
geometry.vertices.push(p0.x, p0.y, 0);
|
geometry.vertices.push(l3.x, l3.y, 0);
|
geometry.vertices.push(l4.x, l4.y, 0);
|
// 外侧扇形
|
geometry.vertices.push(l3.x, l3.y, 0);
|
geometry.vertices.push(l4.x, l4.y, 0);
|
geometry.vertices.push(l1.x, l1.y, 0);
|
geometry.vertices.push(l2.x, l2.y, 0);
|
// console.log(l3.x + ',' + l3.y + ' | ' + l1.x + ',' + l1.y);
|
|
// 内测扇形颜色
|
geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
|
geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
|
geometry.vertexColors.push(1, 0.11, 0.25, 0.6);
|
//外侧扇形颜色
|
geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
|
geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
|
geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
|
geometry.vertexColors.push(1, 0.37, 0.07, 0.5);
|
|
var index = i * 7;
|
geometry.faces.push(index, index + 1, index + 2);
|
geometry.faces.push(index + 3, index + 4, index + 5);
|
geometry.faces.push(index + 4, index + 5, index + 6);
|
}
|
object3Dlayer.add(sector);
|
_sector = sector;
|
|
distance = distance.toFixed(0);
|
distance2 = distance2.toFixed(0);
|
const zoomStyleMapping = {
|
14: 0,
|
15: 0,
|
16: 0,
|
17: 0,
|
18: 0,
|
19: 0,
|
20: 0
|
};
|
//10分钟扇形
|
// eslint-disable-next-line no-undef
|
var text15 = new AMap.ElasticMarker({
|
zoom: [14, 20],
|
position: list[2],
|
styles: [
|
{
|
icon: {
|
img: './asset/mipmap/location.png',
|
size: [16, 16], //可见区域的大小
|
ancher: [8, 16], //锚点
|
fitZoom: 18, //最合适的级别
|
scaleFactor: 1, //地图放大一级的缩放比例系数
|
maxScale: 2, //最大放大比例
|
minScale: 1 //最小放大比例
|
},
|
label: {
|
content: '<div>10分钟</div>',
|
offset: [-35, 0],
|
position: 'BM',
|
minZoom: 15
|
}
|
}
|
],
|
zoomStyleMapping: zoomStyleMapping
|
});
|
_sectorViews['text10'] = text15;
|
// eslint-disable-next-line no-undef
|
var textM = new AMap.ElasticMarker({
|
zoom: [14, 20],
|
position: list[1],
|
styles: [
|
{
|
icon: {
|
img: './asset/mipmap/location.png',
|
size: [16, 16], //可见区域的大小
|
ancher: [8, 16], //锚点
|
fitZoom: 18, //最合适的级别
|
scaleFactor: 1, //地图放大一级的缩放比例系数
|
maxScale: 2, //最大放大比例
|
minScale: 1 //最小放大比例
|
},
|
label: {
|
content: `<div>${distance}m</div>`,
|
offset: [-35, 0],
|
position: 'BM',
|
minZoom: 15
|
}
|
}
|
],
|
zoomStyleMapping: zoomStyleMapping
|
});
|
_sectorViews['textM'] = textM;
|
map.add(_sectorViews['text10']);
|
map.add(_sectorViews['textM']);
|
|
//5分钟扇形
|
let pList = list2;
|
// eslint-disable-next-line no-undef
|
var text5 = new AMap.ElasticMarker({
|
position: pList[1],
|
styles: [
|
{
|
icon: {
|
img: './asset/mipmap/location.png',
|
size: [16, 16], //可见区域的大小
|
ancher: [8, 16], //锚点
|
fitZoom: 18, //最合适的级别
|
scaleFactor: 1, //地图放大一级的缩放比例系数
|
maxScale: 2, //最大放大比例
|
minScale: 1 //最小放大比例
|
},
|
label: {
|
content: `<div>5分钟</div>`,
|
offset: [-35, 0],
|
position: 'BM',
|
minZoom: 15
|
}
|
}
|
],
|
zoomStyleMapping: zoomStyleMapping
|
});
|
_sectorViews['text5'] = text5;
|
// eslint-disable-next-line no-undef
|
var textM5 = new AMap.ElasticMarker({
|
position: pList[0],
|
styles: [
|
{
|
icon: {
|
img: './asset/mipmap/location.png',
|
size: [16, 16], //可见区域的大小
|
ancher: [8, 16], //锚点
|
fitZoom: 18, //最合适的级别
|
scaleFactor: 1, //地图放大一级的缩放比例系数
|
maxScale: 2, //最大放大比例
|
minScale: 1 //最小放大比例
|
},
|
label: {
|
content: `<div>${distance2}m</div>`,
|
offset: [-35, 0],
|
position: 'BM',
|
minZoom: 15
|
}
|
}
|
],
|
zoomStyleMapping: zoomStyleMapping
|
});
|
_sectorViews['textM5'] = textM5;
|
map.add(_sectorViews['textM5']);
|
map.add(_sectorViews['text5']);
|
}
|
};
|