import * as mars3d from 'mars3d' import Vue from 'vue' /** * 四面体 * @param graphicLayer * @param position * @param attr */ export function Tetrahedron(graphicLayer, position, attr, style = {}) { const tetrahedronPrimitive = new mars3d.graphic.Tetrahedron({ position: position, style: { width: 8, height: 15, color: 'rgba(255,0,0,0.7)', moveHeight: 50 }, attr: attr }) graphicLayer.addGraphic(tetrahedronPrimitive) } /** * 点 * @param graphicLayer * @param position * @param attr */ export function Graphic_Point(graphicLayer, position, attr, popup) { const pointPrimitive = new mars3d.graphic.BillboardPrimitive({ id: attr.alarmId, position: position, style: { image: '../static/images/alarm.png', scale: 0.8, hasPixelOffset: true, pixelOffsetY: -20, scaleByDistance: true, scaleByDistance_far: 20000, scaleByDistance_farValue: 0.8, scaleByDistance_near: 0, scaleByDistance_nearValue: 1.6, visibleDepth: false, // clampToGround: true }, attr, }) let str = `<div style="font-size: 14px;color: #7ff5ff;font-weight: 500;font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;"> <div style="color: red;font-size: 18px;font-weight: bold;margin: 8px;border-bottom: 1px solid red;font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;">当前告警</div>` for (const j in popup) { if (j === 'FID') continue str += ` <div style="padding: 2px;padding-left: 8px"> <label style="padding-right: 5px;font-weight: 700">${j}: </label> ${popup[j]}</div>` } str += `</div>` pointPrimitive.bindPopup(str) graphicLayer.addGraphic(pointPrimitive) } export function randomPoint(minJD, maxJD, minWD, maxWD) { // 114.882505, 25.778006, 0] // const jd = random(114.84 * 1000, 114.89 * 1000) / 1000 // const wd = random(25.76 * 1000, 25.81 * 1000) / 1000 const jd = random(minJD * 1000, maxJD * 1000) / 1000 const wd = random(minWD * 1000, maxWD * 1000) / 1000 return new mars3d.LngLatPoint(jd, wd, 100) } export function random(min, max) { return Math.floor(Math.random() * (max - min + 1) + min) } /** * 垂直飞线 * @constructor */ export function FlyLine(graphicLayer, minJD, maxJD, minWD, maxWD) { const arrData = [] for (let j = 0; j < 100; ++j) { const startPt = randomPoint(minJD, maxJD, minWD, maxWD) const endPt = startPt.clone() endPt.alt = random(1000, 2000) arrData.push({ positions: [startPt, endPt], style: { width: 1, materialType: mars3d.MaterialType.LineFlowColor, materialOptions: { color: 'rgb(141,172,172)', speed: random(5, 10), startTime: random(1000, 3000), percent: 0.1, alpha: 0.01 } } }) } const upPoly = new mars3d.graphic.PolylineCombine({ instances: arrData }) graphicLayer.addGraphic(upPoly) }