"use strict"; function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var turf = _interopRequireWildcard(require("@turf/turf")); function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } var mapRoam = { coord: [[123.13255714786649, 23.067683098974722], [122.93636587570226, 23.188425587402776], [122.73982043428656, 23.308924483009175], [122.54291884301844, 23.429177925979], [122.34565912727214, 23.549184049216148], [122.14803931858805, 23.668940978328354], [121.95005745486677, 23.78844683161317], [121.7517115805666, 23.90769972004486], [121.61410438678931, 23.99015603989342]], entityModel: null, url: 'http://localhost/Model/model/Cesium_Air.glb', // 两点插值去重 getTurfLineChunk: function getTurfLineChunk() { var line = turf.lineString([[123.13255714786649, 23.067683098974722], [121.61410438678931, 23.99015603989342]]); var chunk = turf.lineChunk(line, 15, { units: 'miles' }); var val = turf.cleanCoords(line).geometry.coordinates; var std = []; chunk.features.filter(function (item) { for (var i in item.geometry.coordinates) { std.push(item.geometry.coordinates[i]); } }); var line = turf.lineString(std); }, startRoam: function startRoam() { this.trackView(); }, closeRoam: function closeRoam() { if (this.entityModel == null) return; Viewer.clock.shouldAnimate = false; Viewer.entities.removeAll(); this.entityModel = null; }, trackView: function trackView() { var myPositions = this.coord; Viewer.clock.shouldAnimate = true; var start = Cesium.JulianDate.fromDate(new Date(2015, 2, 25, 16)); var stop = Cesium.JulianDate.addSeconds(start, this.coord.length - 1, new Cesium.JulianDate()); Viewer.clock.startTime = start.clone(); Viewer.clock.stopTime = stop.clone(); Viewer.clock.currentTime = start.clone(); Viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP; Viewer.clock.multiplier = 1; var position = computeCirclularFlight(); this.entityModel = Viewer.entities.add({ availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({ start: start, stop: stop })]), position: position, orientation: new Cesium.VelocityOrientationProperty(position), model: { uri: this.url, minimumPixelSize: 64, scale: 0.5 }, path: { resolution: 1, material: new Cesium.PolylineGlowMaterialProperty({ glowPower: 0.1, color: Cesium.Color.RED }), width: 16 } }); this.entityModel.model.show = true; function computeCirclularFlight() { var property = new Cesium.SampledPositionProperty(); property.setInterpolationOptions({ interpolationDegree: 2, interpolationAlgorithm: Cesium.HermitePolynomialApproximation }); for (var i = 0; i < myPositions.length; i++) { var time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate()); var position = Cesium.Cartesian3.fromDegrees(myPositions[i][0], myPositions[i][1], 5); property.addSample(time, position); } return property; } } }; var _default = mapRoam; exports["default"] = _default;