UNPKG

hf-cesium

Version:

css和js入口合并成一个

1 lines 89.3 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("cesium")):"function"==typeof define&&define.amd?define(["cesium"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).index_location=e(t.Cesium)}(this,(function(t){"use strict";var e=Object.defineProperty,i=(t,i,s)=>(((t,i,s)=>{i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s})(t,"symbol"!=typeof i?i+"":i,s),s);function s(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const i in t)if("default"!==i){const s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>t[i]})}return e.default=t,Object.freeze(e)}const n=s(t);var o={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-o.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*o.Bounce.In(2*t):.5*o.Bounce.Out(2*t-1)+.5}}},r="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},a=new(function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=r()),void 0===e&&(e=!1);var i=Object.keys(this._tweens);if(0===i.length)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var n=this._tweens[i[s]],o=!e;n&&!1===n.update(t,o)&&!e&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}());a.getAll.bind(a),a.removeAll.bind(a),a.add.bind(a),a.remove.bind(a),a.update.bind(a);const l={LINEAR_NONE:o.Linear.None,QUADRATIC_IN:o.Quadratic.In,QUADRATIC_OUT:o.Quadratic.Out,QUADRATIC_IN_OUT:o.Quadratic.InOut,CUBIC_IN:o.Cubic.In,CUBIC_OUT:o.Cubic.Out,CUBIC_IN_OUT:o.Cubic.InOut,QUARTIC_IN:o.Quartic.In,QUARTIC_OUT:o.Quartic.Out,QUARTIC_IN_OUT:o.Quartic.InOut,QUINTIC_IN:o.Quintic.In,QUINTIC_OUT:o.Quintic.Out,QUINTIC_IN_OUT:o.Quintic.InOut,SINUSOIDAL_IN:o.Sinusoidal.In,SINUSOIDAL_OUT:o.Sinusoidal.Out,SINUSOIDAL_IN_OUT:o.Sinusoidal.InOut,EXPONENTIAL_IN:o.Exponential.In,EXPONENTIAL_OUT:o.Exponential.Out,EXPONENTIAL_IN_OUT:o.Exponential.InOut,CIRCULAR_IN:o.Circular.In,CIRCULAR_OUT:o.Circular.Out,CIRCULAR_IN_OUT:o.Circular.InOut,ELASTIC_IN:o.Elastic.In,ELASTIC_OUT:o.Elastic.Out,ELASTIC_IN_OUT:o.Elastic.InOut,BACK_IN:o.Back.In,BACK_OUT:o.Back.Out,BACK_IN_OUT:o.Back.InOut,BOUNCE_IN:o.Bounce.In,BOUNCE_OUT:o.Bounce.Out,BOUNCE_IN_OUT:o.Bounce.InOut},h=Object.freeze(l);class c{constructor(e){i(this,"operator"),i(this,"eventHandler"),i(this,"viewer"),i(this,"duration",.85),i(this,"easingFunction",h.CUBIC_IN_OUT),i(this,"callFun"),i(this,"registEventHandlers",[]),i(this,"animationFrame",0),this.operator=e,this.viewer=e.viewer,this.eventHandler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.init()}init(){this.initLeftDownEventHandler(),this.animate()}animate(){var t,e;(null==(t=this.registEventHandlers)?void 0:t.length)&&(null==(e=this.registEventHandlers)||e.forEach((t=>{t()}))),this.animationFrame=requestAnimationFrame(this.animate.bind(this))}initLeftDownEventHandler(){this.eventHandler.setInputAction((e=>{let i=this.viewer.scene.pickPosition(e.position),s=t.Cartographic.fromCartesian(i),n=t.Math.toDegrees(s.latitude),o=t.Math.toDegrees(s.longitude),r=s.height;console.log(o,n,r,e.position),this.callFun&&this.callFun({lon:o,lat:n,alt:r,position:e.position}),this.flytoEvent(e)}),t.ScreenSpaceEventType.LEFT_CLICK)}flytoEvent(e){const i=this.viewer.scene.pick(e.position);if(console.log("pickedFeature",i),!i)return;let s,n;if(i.id instanceof t.Entity&&i.id.userData){if(n=i.id.userData,console.log("pickedFeature.id",n),n.viewConfig){const{position:e,hpr:i}=n.viewConfig;this.viewer.camera.flyTo({destination:t.Cartesian3.fromDegrees(e[0],e[1],e[2]),orientation:t.HeadingPitchRoll.fromDegrees(i[0],i[1],i[2]),duration:this.duration,easingFunction:this.easingFunction})}}else i.primitive&&i.primitive.userData&&(n=i.primitive.userData,s=i.primitive);if(s)if(s.userData&&(s.userData.flyto||s.userData.viewConfig)){console.log("primitive.userData---",s.userData);let{position:e,orientation:i,duration:n}=s.userData.flyto;this.viewer.camera.flyTo({destination:t.Cartesian3.fromDegrees(e[0],e[1],e[2]),orientation:t.HeadingPitchRoll.fromDegrees(i[0],i[1],i[2]),duration:n||this.duration,easingFunction:this.easingFunction})}else{const t=s.boundingSphere;t&&this.viewer.camera.flyToBoundingSphere(t,{duration:this.duration,easingFunction:this.easingFunction})}}setClickCallBack(t){t&&(this.callFun=t)}clearClickCallBack(){this.callFun&&(this.callFun=void 0)}registEventHandlerCallback(t){t&&this.registEventHandlers.push(t)}clearRegistEventHandler(){this.registEventHandlers&&this.registEventHandlers.length&&(this.registEventHandlers=[])}dispose(){this.eventHandler.removeInputAction(t.ScreenSpaceEventType.LEFT_CLICK),this.animationFrame&&cancelAnimationFrame(this.animationFrame)}}var p=6371008.8,u={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*p,kilometers:6371.0088,kilometres:6371.0088,meters:p,metres:p,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:p/1852,radians:1,yards:6967335.223679999};function d(t,e,i){void 0===i&&(i={});var s={type:"Feature"};return(0===i.id||i.id)&&(s.id=i.id),i.bbox&&(s.bbox=i.bbox),s.properties=e||{},s.geometry=t,s}function g(t,e,i){if(void 0===i&&(i={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(t[0])||!f(t[1]))throw new Error("coordinates must contain numbers");return d({type:"Point",coordinates:t},e,i)}function m(t,e,i){void 0===i&&(i={});for(var s=0,n=t;s<n.length;s++){var o=n[s];if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return d({type:"Polygon",coordinates:t},e,i)}function y(t,e,i){if(void 0===i&&(i={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return d({type:"LineString",coordinates:t},e,i)}function w(t){return 180*(t%(2*Math.PI))/Math.PI}function v(t){return t%360*Math.PI/180}function f(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function C(t,e,i){if(null!==t)for(var s,n,o,r,a,l,h,c,p=0,u=0,d=t.type,g="FeatureCollection"===d,m="Feature"===d,y=g?t.features.length:1,w=0;w<y;w++){a=(c=!!(h=g?t.features[w].geometry:m?t.geometry:t)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var v=0;v<a;v++){var f=0,E=0;if(null!==(r=c?h.geometries[v]:h)){l=r.coordinates;var M=r.type;switch(p=0,M){case null:break;case"Point":if(!1===e(l,u,w,f,E))return!1;u++,f++;break;case"LineString":case"MultiPoint":for(s=0;s<l.length;s++){if(!1===e(l[s],u,w,f,E))return!1;u++,"MultiPoint"===M&&f++}"LineString"===M&&f++;break;case"Polygon":case"MultiLineString":for(s=0;s<l.length;s++){for(n=0;n<l[s].length-p;n++){if(!1===e(l[s][n],u,w,f,E))return!1;u++}"MultiLineString"===M&&f++,"Polygon"===M&&E++}"Polygon"===M&&f++;break;case"MultiPolygon":for(s=0;s<l.length;s++){for(E=0,n=0;n<l[s].length;n++){for(o=0;o<l[s][n].length-p;o++){if(!1===e(l[s][n][o],u,w,f,E))return!1;u++}E++}f++}break;case"GeometryCollection":for(s=0;s<r.geometries.length;s++)if(!1===C(r.geometries[s],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function E(t,e,i){var s=i;return function(t,e){var i,s,n,o,r,a,l,h,c,p,u=0,d="FeatureCollection"===t.type,g="Feature"===t.type,m=d?t.features.length:1;for(i=0;i<m;i++){for(a=d?t.features[i].geometry:g?t.geometry:t,h=d?t.features[i].properties:g?t.properties:{},c=d?t.features[i].bbox:g?t.bbox:void 0,p=d?t.features[i].id:g?t.id:void 0,r=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,n=0;n<r;n++)if(null!==(o=l?a.geometries[n]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,u,h,c,p))return!1;break;case"GeometryCollection":for(s=0;s<o.geometries.length;s++)if(!1===e(o.geometries[s],u,h,c,p))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,u,h,c,p))return!1;u++}}(t,(function(t,n,o,r,a){s=0===n&&void 0===i?t:e(s,t,n,o,r,a)})),s}function M(t){var e=[1/0,1/0,-1/0,-1/0];return C(t,(function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1])})),e}function b(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function P(t,e,i){void 0===i&&(i={});var s=b(t),n=b(e),o=v(n[1]-s[1]),r=v(n[0]-s[0]),a=v(s[1]),l=v(n[1]),h=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(r/2),2)*Math.cos(a)*Math.cos(l);return function(t,e){void 0===e&&(e="kilometers");var i=u[e];if(!i)throw new Error(e+" units is invalid");return t*i}(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),i.units)}function D(t,e){void 0===e&&(e={});var i=Number(t[0]),s=Number(t[1]),n=Number(t[2]),o=Number(t[3]);if(6===t.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var r=[i,s];return m([[r,[n,s],[n,o],[i,o],r]],e.properties,{bbox:t,id:e.id})}function T(t,e,i,s){void 0===s&&(s={});var n=b(t),o=v(n[0]),r=v(n[1]),a=v(i),l=function(t,e){void 0===e&&(e="kilometers");var i=u[e];if(!i)throw new Error(e+" units is invalid");return t/i}(e,s.units),h=Math.asin(Math.sin(r)*Math.cos(l)+Math.cos(r)*Math.sin(l)*Math.cos(a));return g([w(o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(r),Math.cos(l)-Math.sin(r)*Math.sin(h))),w(h)],s.properties)}function I(t,e,i){if(void 0===i&&(i={}),!0===i.final)return function(t,e){var i=I(e,t);return i=(i+180)%360}(t,e);var s=b(t),n=b(e),o=v(s[0]),r=v(n[0]),a=v(s[1]),l=v(n[1]),h=Math.sin(r-o)*Math.cos(l),c=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(r-o);return w(Math.atan2(h,c))}function _(t,e){return T(t,P(t,e)/2,I(t,e))}function L(t,e){void 0===e&&(e={});var i=M(t);return g([(i[0]+i[2])/2,(i[1]+i[3])/2],e.properties,e)}M.default=M;var O=6378137;function x(t){return E(t,(function(t,e){return t+function(t){var e,i=0;switch(t.type){case"Polygon":return A(t.coordinates);case"MultiPolygon":for(e=0;e<t.coordinates.length;e++)i+=A(t.coordinates[e]);return i;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)}),0)}function A(t){var e=0;if(t&&t.length>0){e+=Math.abs(k(t[0]));for(var i=1;i<t.length;i++)e-=Math.abs(k(t[i]))}return e}function k(t){var e,i,s,n,o,r,a=0,l=t.length;if(l>2){for(r=0;r<l;r++)r===l-2?(s=l-2,n=l-1,o=0):r===l-1?(s=l-1,n=0,o=1):(s=r,n=r+1,o=r+2),e=t[s],i=t[n],a+=(S(t[o][0])-S(e[0]))*Math.sin(S(i[1]));a=a*O*O/2}return a}function S(t){return t*Math.PI/180}function F(t){const e=n.Cartographic.fromCartesian(t);return[n.Math.toDegrees(e.longitude),n.Math.toDegrees(e.latitude)]}function H(t,e){if(!t||!e)return 0;return function(t,e){let i=t[1]*Math.PI/180,s=e[1]*Math.PI/180,n=i-s,o=t[0]*Math.PI/180-e[0]*Math.PI/180,r=2*Math.asin(Math.sqrt(Math.pow(Math.sin(n/2),2)+Math.cos(i)*Math.cos(s)*Math.pow(Math.sin(o/2),2)));return r*=6378.137,r=Math.round(1e4*r)/10,r}(F(t),F(e))}function R(t){return n.Cartographic.fromCartesian(t).height}function N(t){if(t.length<3)return 0;let e=[];return t.forEach((t=>{e.push(F(t))})),e.push(e[0]),x(m([e])).toFixed(3)}class W{constructor(t){this.viewer=t,this.positions=[],this.vertexEntities=[],this.tempPositions=[],this.initEvents()}setBaseHeight(t){this.height=t}initEvents(){this.handler=new n.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.MeasureStartEvent=new n.Event,this.MeasureEndEvent=new n.Event}active(){this.registerEvents(),this.isMeasure=!0}deactive(){this.isMeasure&&this.unRegisterEvents()}unRegisterEvents(){this.handler.removeInputAction(n.ScreenSpaceEventType.LEFT_CLICK)}registerEvents(){this.leftClickEvent(),this.mouseMoveEvent(),this.rightClickEvent()}leftClickEvent(){this.handler.setInputAction((t=>{this.viewer._element.style.cursor="default";let e=this.viewer.scene.pickPosition(t.position);if(!e){let t=this.viewer.scene.globe.ellipsoid;e=this.viewer.scene.camera.pickEllipsoid(e,t)}n.defined(e)&&(this.positions.push(e),this.height=this.unifiedHeight(this.positions,this.height),1==this.positions.length&&this.createPolygonEntity(),this.createVertex(),console.log("position",e))}),n.ScreenSpaceEventType.LEFT_CLICK)}mouseMoveEvent(){this.handler.setInputAction((t=>{if(!this.isMeasure)return;this.viewer._element.style.cursor="default";let e=this.viewer.scene.pickPosition(t.endPosition);e||(e=this.viewer.scene.camera.pickEllipsoid(t.startPosition,this.viewer.scene.globe.ellipsoid)),e&&this.handleMoveEvent(e)}),n.ScreenSpaceEventType.MOUSE_MOVE)}handleMoveEvent(t){this.positions.length<1||(this.height=this.unifiedHeight(this.positions,this.height),this.tempPositions=this.positions.concat(t),this.tempPositions.length>3&&!this.mesureResultEntity&&this.createResultLabel())}createResultLabel(){this.mesureResultEntity=this.viewer.entities.add({position:new n.CallbackProperty((t=>this.getCenterPosition()),!1),type:"MeasureAreaResult",label:{text:new n.CallbackProperty((t=>"面积"+N(this.tempPositions)+"平方米"),!1),scale:.5,font:"normal 28px MicroSoft YaHei",distanceDisplayCondition:new n.DistanceDisplayCondition(0,5e4),scaleByDistance:new n.NearFarScalar(1e3,1,3e3,.4),verticalOrigin:n.VerticalOrigin.BOTTOM,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-30),outlineWidth:9,outlineColor:n.Color.YELLOW,eyeOffset:new n.Cartesian3(0,0,-10)}})}getCenterPosition(){let t=[];if(this.tempPositions.length<3)return this.tempPositions[0];this.tempPositions.forEach((e=>{const i=this.cartesian3ToPoint3D(e);t.push([i.x,i.y])}));let e=L(D(M(y(t)))).geometry.coordinates;return n.Cartesian3.fromDegrees(e[0],e[1],this.height+.3)}unifiedHeight(t,e){let i;e||(e=this.getPositionHeight(t[0]));for(let s=0;s<t.length;s++){let o=t[s];i=this.cartesian3ToPoint3D(o),t[s]=n.Cartesian3.fromDegrees(i.x,i.y,e)}return e}createPolygonEntity(){this.polygonEntity=this.viewer.entities.add({polygon:{hierarchy:new n.CallbackProperty((t=>new n.PolygonHierarchy(this.tempPositions)),!1),material:n.Color.RED.withAlpha(.4),classificationType:n.ClassificationType.CESIUM_3D_TILE},polyline:{perPositionHeight:!0,positions:new n.CallbackProperty((t=>this.tempPositions.concat(this.tempPositions[0])),!1),width:1,material:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW}),depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})}})}createVertex(){let t=this.viewer.entities.add({position:this.positions[this.positions.length-1],type:"MeasureAreaVertex",point:{depthTest:!1,color:n.Color.FUCHSIA,pixelSize:8,disableDepthTestDistance:500}});t.depthTest=!1,this.vertexEntities.push(t)}getPositionHeight(t){return n.Cartographic.fromCartesian(t).height}cartesian3ToPoint3D(t){const e=n.Cartographic.fromCartesian(t);return{x:n.Math.toDegrees(e.longitude),y:n.Math.toDegrees(e.latitude),z:e.height}}rightClickEvent(){this.handler.setInputAction((t=>{!this.isMeasure||this.positions.length<3?(this.deactive(),this.clear()):(this.tempPositions=[...this.positions],this.polygonEntity.polyline={positions:this.positions.concat(this.positions[0]),width:2,material:n.Color.YELLOW,depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})},this.polygonEntity.polygon.hierarchy=new n.PolygonHierarchy(this.tempPositions),this.mesureResultEntity.position=this.getCenterPosition(),this.mesureResultEntity.label.text="总面积"+N(this.positions)+"平方米",this.measureEnd())}),n.ScreenSpaceEventType.RIGHT_CLICK)}measureEnd(){this.deactivate(),this.MeasureEndEvent.raiseEvent(this.measureArea)}deactivate(){this.isMeasure&&(this.unRegisterEvents(),this.viewer._element.style.cursor="pointer",this.viewer.enableCursorStyle=!0,this.isMeasure=!1,this.tempPositions=[],this.positions=[],this.height=void 0)}clear(){this.viewer.entities.remove(this.polygonEntity),this.polygonEntity=void 0,this.vertexEntities.forEach((t=>{this.viewer.entities.remove(t)})),this.vertexEntities=[],this.viewer.entities.remove(this.vertexEntities),this.vertexEntities=[],this.height=void 0}}class z{constructor(t){this.viewer=t,this.positions=[],this.vertexEntities=[],this.tempPositions=[],this.initEvents()}setBaseHeight(t){this.height=t}initEvents(){this.handler=new n.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.MeasureStartEvent=new n.Event,this.MeasureEndEvent=new n.Event}active(){this.registerEvents(),this.isMeasure=!0}deactive(){this.isMeasure&&this.unRegisterEvents()}unRegisterEvents(){this.handler.removeInputAction(n.ScreenSpaceEventType.LEFT_CLICK)}registerEvents(){this.leftClickEvent(),this.mouseMoveEvent(),this.rightClickEvent()}leftClickEvent(){this.handler.setInputAction((t=>{if(this.viewer._element.style.cursor="default",2==this.positions.length)return void this.deactivate();let e=this.viewer.scene.pickPosition(t.position);if(!e){let t=this.viewer.scene.globe.ellipsoid;e=this.viewer.scene.camera.pickEllipsoid(e,t)}n.defined(e)&&(this.positions.push(e),this.height=this.unifiedHeight(this.positions,this.height),1==this.positions.length&&this.createPolygonEntity(),this.createVertex(),console.log("position",e))}),n.ScreenSpaceEventType.LEFT_CLICK)}createPolygonEntity(){this.polygonEntity=this.viewer.entities.add({polyline:{positions:new n.CallbackProperty((t=>this.tempPositions),!1),width:1,material:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW}),depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})}}),this.polygonEntity.depthTest=!1}mouseMoveEvent(){this.handler.setInputAction((t=>{if(!this.isMeasure)return;if(2==this.positions.length)return this.tempPositions=[...this.positions],this.polygonEntity.polyline={positions:this.positions,width:2,material:n.Color.YELLOW,depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})},this.mesureResultEntity.position=this.getCenterPosition(),this.mesureResultEntity.label.text="距离"+H(this.positions[0],this.positions[1])+"米",void this.measureEnd();this.viewer._element.style.cursor="default";let e=this.viewer.scene.pickPosition(t.endPosition);e||(e=this.viewer.scene.camera.pickEllipsoid(t.startPosition,this.viewer.scene.globe.ellipsoid)),e&&this.handleMoveEvent(e)}),n.ScreenSpaceEventType.MOUSE_MOVE)}handleMoveEvent(t){this.positions.length<1||(this.height=this.unifiedHeight(this.positions,this.height),this.tempPositions=this.positions.concat(t),this.tempPositions.length>=2&&!this.mesureResultEntity&&this.createResultLabel())}createResultLabel(){this.mesureResultEntity=this.viewer.entities.add({position:new n.CallbackProperty((t=>this.getCenterPosition()),!1),type:"MeasureAreaResult",label:{text:new n.CallbackProperty((t=>"距离"+H(this.tempPositions[0],this.tempPositions[1])+"米"),!1),scale:.5,font:"normal 28px MicroSoft YaHei",distanceDisplayCondition:new n.DistanceDisplayCondition(0,5e4),scaleByDistance:new n.NearFarScalar(1e3,1,3e3,.4),verticalOrigin:n.VerticalOrigin.BOTTOM,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-30),outlineWidth:9,outlineColor:n.Color.YELLOW,eyeOffset:new n.Cartesian3(0,0,-10)}})}getCenterPosition(){let t=[];if(this.tempPositions.length<2)return this.tempPositions[0];this.tempPositions.forEach((e=>{const i=this.cartesian3ToPoint3D(e);t.push([i.x,i.y])}));let e=_(g(t[0]),g(t[1]));return n.Cartesian3.fromDegrees(e.geometry.coordinates[0],e.geometry.coordinates[1],this.height+.3)}unifiedHeight(t,e){let i;e||(e=this.getPositionHeight(t[0]));for(let s=0;s<t.length;s++){let o=t[s];i=this.cartesian3ToPoint3D(o),t[s]=n.Cartesian3.fromDegrees(i.x,i.y,e)}return e}createVertex(){let t=this.viewer.entities.add({position:this.positions[this.positions.length-1],type:"MeasureAreaVertex",point:{color:n.Color.FUCHSIA,pixelSize:8,disableDepthTestDistance:500}});t.depthTest=!1,this.vertexEntities.push(t)}getPositionHeight(t){return n.Cartographic.fromCartesian(t).height}cartesian3ToPoint3D(t){const e=n.Cartographic.fromCartesian(t);return{x:n.Math.toDegrees(e.longitude),y:n.Math.toDegrees(e.latitude),z:e.height}}rightClickEvent(){this.handler.setInputAction((t=>{!this.isMeasure||this.positions.length<2?(this.deactive(),this.clear()):(this.tempPositions=[...this.positions],this.polygonEntity.polyline={positions:this.positions,width:2,material:n.Color.YELLOW,depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})},this.mesureResultEntity.position=this.getCenterPosition(),this.mesureResultEntity.label.text="距离"+H(this.positions[0],this.positions[1])+"米",this.measureEnd())}),n.ScreenSpaceEventType.RIGHT_CLICK)}measureEnd(){this.deactivate(),this.MeasureEndEvent.raiseEvent(this.measureArea)}deactivate(){this.isMeasure&&(this.unRegisterEvents(),this.viewer._element.style.cursor="pointer",this.viewer.enableCursorStyle=!0,this.isMeasure=!1,this.tempPositions=[],this.positions=[],this.height=void 0)}clear(){this.viewer.entities.remove(this.mesureResultEntity),this.mesureResultEntity=void 0,this.viewer.entities.remove(this.polygonEntity),this.polygonEntity=void 0,this.vertexEntities.forEach((t=>{this.viewer.entities.remove(t)})),this.vertexEntities=[],this.height=void 0}}class U{constructor(t){this.viewer=t,this.positions=[],this.vertexEntities=[],this.tempPositions=[],this.initEvents()}initEvents(){this.handler=new n.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.MeasureStartEvent=new n.Event,this.MeasureEndEvent=new n.Event}active(){this.registerEvents(),this.isMeasure=!0}deactive(){this.isMeasure&&this.unRegisterEvents()}unRegisterEvents(){this.handler.removeInputAction(n.ScreenSpaceEventType.LEFT_CLICK)}registerEvents(){this.leftClickEvent(),this.mouseMoveEvent(),this.rightClickEvent()}leftClickEvent(){this.handler.setInputAction((t=>{if(this.viewer._element.style.cursor="default",2==this.positions.length)return void this.deactivate();let e=this.viewer.scene.pickPosition(t.position);if(!e){let t=this.viewer.scene.globe.ellipsoid;e=this.viewer.scene.camera.pickEllipsoid(e,t)}n.defined(e)&&(this.positions.push(e),1==this.positions.length&&this.createPolygonEntity(),this.createVertex())}),n.ScreenSpaceEventType.LEFT_CLICK)}createPolygonEntity(){this.polygonEntity=this.viewer.entities.add({polyline:{perPositionHeight:!0,depthTest:!1,positions:new n.CallbackProperty((t=>this.tempPositions),!1),width:1,material:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW}),depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})}}),this.polygonEntity.depthTest=!1}mouseMoveEvent(){this.handler.setInputAction((t=>{if(!this.isMeasure)return;if(2==this.positions.length)return this.tempPositions=[...this.positions],this.polygonEntity.polyline={perPositionHeight:!0,depthTest:!1,positions:this.positions,width:2,material:n.Color.YELLOW,depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})},this.mesureResultEntity.position=this.getCenterPosition(),this.mesureResultEntity.label.text="高度"+this.getHeightByPoints(this.positions)+"米",void this.measureEnd();this.viewer._element.style.cursor="default";let e=this.viewer.scene.pickPosition(t.endPosition);e||(e=this.viewer.scene.camera.pickEllipsoid(t.startPosition,this.viewer.scene.globe.ellipsoid)),e&&this.handleMoveEvent(e)}),n.ScreenSpaceEventType.MOUSE_MOVE)}handleMoveEvent(t){this.positions.length<1||(this.tempPositions=this.positions.concat(t),this.tempPositions.length>=2&&!this.mesureResultEntity&&this.createResultLabel())}createResultLabel(){this.mesureResultEntity=this.viewer.entities.add({position:new n.CallbackProperty((t=>this.getCenterPosition()),!1),type:"MeasureAreaResult",label:{text:new n.CallbackProperty((t=>"高度"+this.getHeightByPoints(this.tempPositions)+"米"),!1),scale:1,font:"normal 28px MicroSoft YaHei",distanceDisplayCondition:new n.DistanceDisplayCondition(0,5e4),scaleByDistance:new n.NearFarScalar(1e3,1,3e3,.4),verticalOrigin:n.VerticalOrigin.BOTTOM,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-30),outlineWidth:9,outlineColor:n.Color.YELLOW,eyeOffset:new n.Cartesian3(0,0,-10)}})}getCenterPosition(){let t=[];if(this.tempPositions.length<2)return this.tempPositions[0];this.tempPositions.forEach((e=>{const i=this.cartesian3ToPoint3D(e);t.push([i.x,i.y])}));let e=_(g(t[0]),g(t[1]));return n.Cartesian3.fromDegrees(e.geometry.coordinates[0],e.geometry.coordinates[1],R(this.tempPositions[0])+this.getHeightByPoints(this.tempPositions)/2)}createVertex(){let t=this.viewer.entities.add({position:this.positions[this.positions.length-1],type:"MeasureAreaVertex",point:{color:n.Color.FUCHSIA,pixelSize:8,disableDepthTestDistance:500}});t.depthTest=!1,this.vertexEntities.push(t)}cartesian3ToPoint3D(t){const e=n.Cartographic.fromCartesian(t);return{x:n.Math.toDegrees(e.longitude),y:n.Math.toDegrees(e.latitude),z:e.height}}rightClickEvent(){this.handler.setInputAction((t=>{!this.isMeasure||this.positions.length<2?(this.deactive(),this.clear()):(this.tempPositions=[...this.positions],this.polygonEntity.polyline={positions:this.positions,depthTest:!1,perPositionHeight:!0,width:2,material:n.Color.YELLOW,depthFailMaterial:new n.PolylineDashMaterialProperty({color:n.Color.YELLOW})},this.mesureResultEntity.position=this.getCenterPosition(),this.mesureResultEntity.label.text="高度"+this.getHeightByPoints(this.positions)+"米",this.measureEnd())}),n.ScreenSpaceEventType.RIGHT_CLICK)}getHeightByPoints(t){return t.length<2?0:(R(t[1])-R(t[0])).toFixed(2)}measureEnd(){this.deactivate(),this.MeasureEndEvent.raiseEvent(this.measureArea)}deactivate(){this.isMeasure&&(this.unRegisterEvents(),this.viewer._element.style.cursor="pointer",this.viewer.enableCursorStyle=!0,this.isMeasure=!1,this.tempPositions=[],this.positions=[])}clear(){this.viewer.entities.remove(this.mesureResultEntity),this.mesureResultEntity=void 0,this.viewer.entities.remove(this.polygonEntity),this.polygonEntity=void 0,this.vertexEntities.forEach((t=>{this.viewer.entities.remove(t)})),this.vertexEntities=[]}}class V{constructor(t={}){this._definitionChanged=new n.Event,this._color=n.defaultValue(t.color,new n.Color(1,1,0,1)),this._time=(new Date).getTime(),this.duration=t.duration,this._isPaused=!1}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(t){return n.Material.WallDiffuseMaterialType}getValue(t,e){return(e=n.defaultValue(e,{})).u_color=this._color,!this._isPaused&&this.duration?e.time=((new Date).getTime()-this._time)%this.duration/this.duration:e.time=0,e}equals(t){return this===t||t instanceof V&&n.Property.equals(this._color,t._color)}togglePause(t){this._isPaused=t,this._isPaused||(this._time=(new Date).getTime())}}Object.defineProperties(V.prototype,{color:n.createPropertyDescriptor("color")}),n.Material.WallDiffuseMaterialType||(n.Material.WallDiffuseMaterialType="WallDiffuseMaterialProperty"),n.Material._materialCache.getMaterial(n.Material.WallDiffuseMaterialType)||n.Material._materialCache.addMaterial(n.Material.WallDiffuseMaterialType,{fabric:{type:n.Material.WallDiffuseMaterialType,uniforms:{u_color:n.Color.MEDIUMORCHID,time:0},source:"\n\t\t\tuniform vec4 u_color;\n\t\t\tczm_material czm_getMaterial(czm_materialInput materialInput){\n\t\t\t\tczm_material material = czm_getDefaultMaterial(materialInput);\n\t\t\t\tvec2 st = materialInput.st;\n\t\t\t\tmaterial.diffuse = u_color.rgb * 2.0;\n\t\t\t\t// material.alpha = color.a * (1.0 - fract(st.t)) * 0.8;\n\t\t\t\tmaterial.alpha = u_color.a * (1.0-fract(st.t - time))*0.5;\n\t\t\t\treturn material;\n\t\t\t}"},translucent:function(t){return!0}});class B{constructor(t={}){this._definitionChanged=new n.Event,this._color=n.defaultValue(t.color,new n.Color(1,1,0,1)),this._time=(new Date).getTime(),this.duration=t.duration,this._isPaused=!1}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(t){return n.Material.PolygonLineDiffuseMaterialType}getValue(t,e){return(e=n.defaultValue(e,{})).u_color=this._color,!this._isPaused&&this.duration?e.time=((new Date).getTime()-this._time)%this.duration/this.duration:e.time=0,e}equals(t){return this===t||t instanceof B&&n.Property.equals(this._color,t._color)}togglePause(t){this._isPaused=t,this._isPaused||(this._time=(new Date).getTime())}}Object.defineProperties(B.prototype,{color:n.createPropertyDescriptor("color")}),n.Material.PolygonLineDiffuseMaterialType||(n.Material.PolygonLineDiffuseMaterialType="PolygonLineDiffuseMaterialProperty"),n.Material._materialCache.getMaterial(n.Material.PolygonLineDiffuseMaterialType)||n.Material._materialCache.addMaterial(n.Material.PolygonLineDiffuseMaterialType,{fabric:{type:n.Material.PolygonLineDiffuseMaterialType,uniforms:{u_color:n.Color.MEDIUMORCHID,time:0},source:"\n\t\t\tuniform vec4 u_color;\n\t\t\tczm_material czm_getMaterial(czm_materialInput materialInput){\n\t\t\t\tczm_material material = czm_getDefaultMaterial(materialInput);\n\t\t\t\tvec2 st = materialInput.st;\n\t\t\t\tmaterial.diffuse = u_color.rgb * 2.0;\n\t\t\t\tmaterial.alpha = u_color.a * (1.0-fract(st.s - time))*0.5;\n\t\t\t\treturn material;\n\t\t\t}"},translucent:function(t){return!0}});class G{constructor(e,s){i(this,"DF",{name:"",url:"",pixelOffset:new t.Cartesian2(0,0),eyeOffset:new t.Cartesian3(0,0,0),width:64,height:64,scale:.5}),i(this,"viewer"),i(this,"options"),i(this,"entity"),this.viewer=e,this.options=Object.assign({},this.DF,s)}add(){return"外部重载实现"}update(t){return this.options=Object.assign({},this.options,t),this.options}getData(){let t={id:this.options.id,name:this.options.name,type:this.options.type,positions:this.positions2Array(this.options.positions),lonlats:this.lonlats2Array(this.options.lonlats)};return void 0!==this.options.color&&(t.color=this.options.color.toCssColorString()),void 0!==this.options.outlineColor&&(t.outlineColor=this.options.outlineColor.toCssColorString()),void 0!==this.options.url&&(t.url=this.options.url),void 0!==this.options.center&&(t.center=this.options.center),void 0!==this.options.height&&(t.height=this.options.height),void 0!==this.options.area&&(t.blockArea=this.options.area),void 0!==this.options.viewConfig&&(t.viewConfig=this.options.viewConfig),void 0!==this.options.showStartIcon&&(t.showStartIcon=this.options.showStartIcon),void 0!==this.options.showEndIcon&&(t.showEndIcon=this.options.showEndIcon),void 0!==this.options.showTrackIcon&&(t.showTrackIcon=this.options.showTrackIcon),void 0!==this.options.currentLonlat&&(t.currentLonlat=this.options.currentLonlat),t}updateCenter(e){if(e.length<2)return;let i;return i="object"==typeof e?this.getCenterFromLonLat(e):this.getCenter(this.options.positions),i instanceof t.Cartesian3?this.update({center:[i.x,i.y,i.z]}):this.update({center:i}),i}getCenter(e){let i=0,s=0,n=0;e.length&&e.forEach((t=>{i+=t.x,s+=t.y,n+=t.z}));let o=i/e.length,r=s/e.length,a=n/e.length;return new t.Cartesian3(o,r,a)}getCenterFromLonLat(t){let e=0,i=0,s=0;for(let n=0;n<t.length;n+=3)e+=t[n],i+=t[n+1],s+=t[n+2];return[e/(t.length/3),i/(t.length/3),s/(t.length/3)]}setDate(){}positions2Array(t){if(!t)return[];let e=[];return t.length&&t.forEach((t=>{t&&e.push([t.x,t.y,t.z])})),e&&e}lonlats2Array(t){let e=[];if(t.length<=3)e.push([...t]);else for(let i=0;i<t.length;i+=3)e.push([t[i],t[i+1],t[i+2]]);return e&&e}dispose(){this.entity&&this.viewer.entities.remove(this.entity)}convertFormat(e){let i={};for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const n=e[s];if(i[s]=n,n instanceof t.Cartesian2&&(i[s]=[n.x,n.y]),n instanceof t.Cartesian3&&(i[s]=[n.x,n.y,n.z]),n instanceof t.Color&&(i[s]=n.toCssColorString()),"positions"===s&&Array.isArray(n)){let e=[];n.forEach((i=>{i instanceof t.Cartesian3&&e.push([i.x,i.y,i.z])})),e.length&&(i[s]=e)}}return i}}class j extends G{constructor(e,s){return super(e,s),i(this,"DF",{name:"自定义材质立体墙效果",color:new t.Color(6/255,180/255,178/255,1),clampToGround:!0,duration:1e3,maximumHeights:100,minimumHeights:0,showCenter:!1,showAnimationLine:!0,outlineWidth:2,height:100}),this.options=Object.assign({},this.DF,s),this.add()}add(){var e;try{this.entity=this.viewer.entities.add({name:new t.CallbackProperty((()=>this.options.name),!1),id:this.options.id&&this.options.id,wall:{positions:new t.CallbackProperty((()=>{var e;return(null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegreesArrayHeights(this.options.lonlats):this.options.positions}),!1),maximumHeights:new t.CallbackProperty((()=>{var t;return(null==(t=this.options)?void 0:t.lonlats)?new Array(this.options.lonlats.length/3).fill(this.options.height):new Array(this.options.positions.length).fill(this.options.height)}),!1),minimumHeights:(null==(e=this.options)?void 0:e.lonlats)?new Array(this.options.lonlats.length/3).fill(this.options.minimumHeights):new Array(this.options.positions.length).fill(this.options.minimumHeights),material:new V({color:this.options.color,duration:this.options.duration})}});let i=this.updateCenter(this.options.lonlats?this.options.lonlats:this.options.positions);return console.log("center:",i),this.options.showCenter&&i&&(Array.isArray(i)?this.entity.position=t.Cartesian3.fromDegrees(i[0],i[1],i[1]):this.entity.position=i,this.entity.label={text:new t.CallbackProperty((t=>"中心位置"+i.toString()),!1),scale:.5,font:"normal 28px MicroSoft YaHei",distanceDisplayCondition:new t.DistanceDisplayCondition(0,5e3),verticalOrigin:t.VerticalOrigin.BOTTOM,horizontalOrigin:t.HorizontalOrigin.CENTER,style:t.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new t.Cartesian2(0,-10),outlineWidth:9,outlineColor:t.Color.YELLOW}),this.options.showAnimationLine&&(this.entity.polyline={positions:new t.CallbackProperty((()=>{var e;return(null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegreesArrayHeights(this.options.lonlats):this.options.positions}),!1),width:this.options.outlineWidth,clampToGround:this.options.clampToGround,material:new B({color:this.options.color,duration:3*this.options.duration})}),this.options.id||this.update({id:this.entity.id}),this}catch(i){console.error(this.options.type+"绘制错误",i)}}toggleAnimation(t){var e,i,s,n,o;(null==(e=this.entity)?void 0:e.wall.material)&&(null==(i=this.entity)||i.wall.material.togglePause(t)),(null==(s=this.entity)?void 0:s.polyline)&&(null==(n=this.entity)?void 0:n.polyline.material)&&(null==(o=this.entity)||o.polyline.material.togglePause(t))}}class Y extends G{constructor(e,s){return super(e,s),i(this,"DF",{name:"立体多边形",color:new t.Color(1,1,0,.5),extrudedHeight:30,clampToGround:!0,perPositionHeight:!0,closeTop:!1,ClassificationType:t.ClassificationType.CESIUM_3D_TILE,outline:!0,outlineColor:new t.Color(1,1,0,.8),outlineWidth:2,clampToGround:!0,duration:3e3,showAnimationLine:!0}),this.options=Object.assign({},this.DF,s),this.add()}add(){try{if(this.entity=this.viewer.entities.add({name:new t.CallbackProperty((()=>this.options.name),!1),id:this.options.id,polygon:{hierarchy:new t.CallbackProperty((()=>{var e;return new t.PolygonHierarchy((null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegreesArrayHeights(this.options.lonlats):this.options.positions)}),!1),material:this.options.color,extrudedHeight:this.options.extrudedHeight,perPositionHeight:this.options.perPositionHeight,classificationType:this.options.ClassificationType,closeTop:this.options.closeTop}}),this.options.showAnimationLine){let e=[...this.options.lonlats];for(let t=0;t<this.options.lonlats.length;t+=3)e.push(this.options.lonlats[t],this.options.lonlats[t+1],this.options.lonlats[t+2]+this.options.extrudedHeight);this.entity.polyline={positions:new t.CallbackProperty((()=>{var i;return(null==(i=this.options)?void 0:i.lonlats)?t.Cartesian3.fromDegreesArrayHeights(e):this.options.positions}),!1),width:this.options.outlineWidth,material:new B({color:this.options.outlineColor,duration:this.options.duration})}}return this.options.id||this.update({id:this.entity.id}),this}catch(e){console.error(this.options.type+"绘制错误",e)}}toggleAnimation(t){var e,i,s;(null==(e=this.entity)?void 0:e.polyline)&&(null==(i=this.entity)?void 0:i.polyline.material)&&(null==(s=this.entity)||s.polyline.material.togglePause(t))}}class q extends G{constructor(e,s){return super(e,s),i(this,"DF",{name:"自定义材质贴地线",color:new t.Color(6/255,180/255,178/255,1),width:3,clampToGround:!0,duration:3e3}),this.options=Object.assign({},this.DF,s),this.add()}add(){try{return this.entity=this.viewer.entities.add({name:new t.CallbackProperty((()=>this.options.name),!1),id:this.options.id,polyline:{positions:new t.CallbackProperty((()=>{var e;return(null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegreesArrayHeights(this.options.lonlats):this.options.positions}),!1),width:this.options.width,clampToGround:this.options.clampToGround,material:new B({color:this.options.color,duration:this.options.duration})}}),this.options.id||this.update({id:this.entity.id}),this}catch(e){console.error(this.options.type+"绘制错误",e)}}toggleAnimation(t){var e,i,s;(null==(e=this.entity)?void 0:e.polyline)&&(null==(i=this.entity)?void 0:i.polyline.material)&&(null==(s=this.entity)||s.polyline.material.togglePause(t))}}class Q extends G{constructor(e,s){return super(e,s),i(this,"DF",{name:"常规组合点线",color:new t.Color(101/255,245/255,170/255,1),outlineColor:new t.Color(55/255,148/255,98/255,1),width:3,pixelOffset:new t.Cartesian2(0,-10),depthOffset:new t.Cartesian2(0,1),outlineWidth:20,clampToGround:!0,showPoint:!0}),i(this,"pointEntities",[]),this.options=Object.assign({},this.DF,s),this.add()}add(){try{if(this.entity=this.viewer.entities.add({name:new t.CallbackProperty((()=>this.options.name),!1),id:this.options.id,polyline:{positions:new t.CallbackProperty((()=>{var e;return(null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegreesArrayHeights(this.options.lonlats):this.options.positions}),!1),width:this.options.width,clampToGround:this.options.clampToGround,material:new t.PolylineOutlineMaterialProperty({color:this.options.color,outlineWidth:this.options.outlineWidth/2,outlineColor:this.options.outlineColor})}}),this.options.id||this.update({id:this.entity.id}),this.options.showPoint&&this.options.lonlats.length)for(let t=0;t<this.options.lonlats.length;t+=3){const e=this.options.lonlats[t],i=this.options.lonlats[t+1],s=this.options.lonlats[t+2];this.createPoint([e,i,s])}return this}catch(e){console.error(this.options.type+"绘制错误",e)}}createPoint(e){console.log("createPoint",e);let i=this.viewer.entities.add({position:new t.CallbackProperty((()=>t.Cartesian3.fromDegrees(e[0],e[1],e[2]||.01)),!1),point:{color:this.options.outlineColor,pixelSize:10,outlineColor:this.options.color,outlineWidth:8,depthOffset:this.options.depthOffset,pixelOffset:this.options.pixelOffset,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(i)}dispose(){if(super.dispose(),this.pointEntities.length)for(let t=0;t<this.pointEntities.length;t++){const e=this.pointEntities[t];this.viewer.entities.remove(e)}}}class K{constructor(t={}){this._definitionChanged=new n.Event,this._color=n.defaultValue(t.color,new n.Color(1,1,0,1)),this._repeat=n.defaultValue(t.repeat,new n.Cartesian2(1,1)),this._time=(new Date).getTime(),this._image=t.image||"",this.duration=t.duration,this._isPaused=!1}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}get color(){return n.createPropertyDescriptor("color")}getType(t){return n.Material.PolygonFlowLineDiffuseMaterialType}getValue(t,e){return(e=n.defaultValue(e,{})).u_color=this._color,e.image=this._image,e.repeat=this._repeat,!this._isPaused&&this.duration?e.time=((new Date).getTime()-this._time)%this.duration/this.duration:e.time=0,e}equals(t){return this===t||t instanceof K&&n.Property.equals(this._color,t._color)}togglePause(t){this._isPaused=t,this._isPaused||(this._time=(new Date).getTime())}}n.Material.PolygonFlowLineDiffuseMaterialType||(n.Material.PolygonFlowLineDiffuseMaterialType="PolygonFlowLineDiffuseMaterial"),n.Material.FlowLineDiffuseSource||(n.Material.FlowLineDiffuseSource="\n\tuniform vec4 u_color;\n\tuniform vec2 u_repeat; // 添加重复属性\n\tczm_material czm_getMaterial(czm_materialInput materialInput){\n\tczm_material material = czm_getDefaultMaterial(materialInput);\n\t\tvec2 st = materialInput.st;\n\t\t// 应用重复属性\n\t\tst = fract(st * repeat); // 使用fract函数确保纹理坐标在[0, 1]区间内\n\n\t\tvec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));\n\t\tmaterial.alpha = colorImage.a * u_color.a;\n\t\tmaterial.diffuse = u_color.rgb ;\n\t\treturn material;\n\t}"),n.Material._materialCache.getMaterial(n.Material.PolygonFlowLineDiffuseMaterialType)||n.Material._materialCache.addMaterial(n.Material.PolygonFlowLineDiffuseMaterialType,{fabric:{type:n.Material.PolygonFlowLineDiffuseMaterialType,uniforms:{u_color:n.Color.MEDIUMORCHID,time:0,image:"",transparent:!0,repeat:new n.Cartesian2(1,1)},source:n.Material.FlowLineDiffuseSource},translucent:function(t){return!0}});class J extends G{constructor(e,s){return super(e,s),i(this,"DF",{name:"行进线",color:new t.Color(6/255,180/255,178/255,1),width:10,clampToGround:!0,duration:3e3,image:"",repeat:new t.Cartesian2(40,1)}),this.options=Object.assign({},this.DF,s),this.add()}add(){try{return this.entity=this.viewer.entities.add({name:new t.CallbackProperty((()=>this.options.name),!1),id:this.options.id,polyline:{positions:new t.CallbackProperty((()=>{var e;return(null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegreesArrayHeights(this.options.lonlats):this.options.positions}),!1),width:this.options.width,clampToGround:this.options.clampToGround,material:new K({color:this.options.color,duration:this.options.duration,image:this.options.url,repeat:this.options.repeat})}}),this.options.id||this.update({id:this.entity.id}),this}catch(e){console.error(this.options.type+"绘制错误",e)}}toggleAnimation(t){var e,i,s;(null==(e=this.entity)?void 0:e.polyline)&&(null==(i=this.entity)?void 0:i.polyline.material)&&(null==(s=this.entity)||s.polyline.material.togglePause(t))}}class Z{constructor(t={}){this._definitionChanged=new n.Event,this._color=n.defaultValue(t.color,new n.Color(1,1,0,1)),this._time=(new Date).getTime(),this.duration=t.duration,this._isPaused=!1}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(t){return n.Material.PolyVerticalLineDiffuseMaterialType}getValue(t,e){return(e=n.defaultValue(e,{})).u_color=this._color,!this._isPaused&&this.duration?e.time=((new Date).getTime()-this._time)%this.duration/this.duration:e.time=0,e}equals(t){return this===t||t instanceof Z&&n.Property.equals(this._color,t._color)}togglePause(t){this._isPaused=t,this._isPaused||(this._time=(new Date).getTime())}}Object.defineProperties(Z.prototype,{color:n.createPropertyDescriptor("color")}),n.Material.PolyVerticalLineDiffuseMaterialType||(n.Material.PolyVerticalLineDiffuseMaterialType="PolyVerticalLineDiffuseMaterialProperty"),n.Material._materialCache.getMaterial(n.Material.PolyVerticalLineDiffuseMaterialType)||n.Material._materialCache.addMaterial(n.Material.PolyVerticalLineDiffuseMaterialType,{fabric:{type:n.Material.PolyVerticalLineDiffuseMaterialType,uniforms:{u_color:n.Color.MEDIUMORCHID,time:0},source:"\n\t\t\tuniform vec4 u_color;\n\t\t\tczm_material czm_getMaterial(czm_materialInput materialInput){\n\t\t\t\tczm_material material = czm_getDefaultMaterial(materialInput);\n\t\t\t\tvec2 st = materialInput.st;\n\t\t\t\tmaterial.diffuse = u_color.rgb * 2.0;\n\t\t\t\tmaterial.alpha = u_color.a * (1.0-fract(st.s + time))*0.5;\n\t\t\t\treturn material;\n\t\t\t}"},translucent:function(t){return!0}});class X{constructor(t={}){this._definitionChanged=new n.Event,this._color=n.defaultValue(t.color,new n.Color(1,1,0,1)),this._time=(new Date).getTime(),this._colorSubscription=void 0,this.duration=n.defaultValue(t.duration,1e3),this.count=n.defaultValue(t.count,2),this._isPaused=!1,this.gradient=n.defaultValue(t.gradient,.1),0===this.gradient&&(this.gradient=0),this.gradient>1&&(this.gradient=1)}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(t){return n.Material.CircleWaveMaterialType}getValue(t,e){return(e=n.defaultValue(e,{})).u_color=this._color,!this._isPaused&&this.duration?e.time=((new Date).getTime()-this._time)%this.duration/this.duration:e.time=0,e.count=this.count,e.gradient=1+10*(1-this.gradient),e}equals(t){return this===t||t instanceof X&&n.Property.equals(this._color,t._color)}togglePause(t){this._isPaused=t,this._isPaused||(this._time=(new Date).getTime())}}Object.defineProperties(X.prototype,{color:n.createPropertyDescriptor("color"),duration:n.createPropertyDescriptor("duration"),count:n.createPropertyDescriptor("count"),isConstant:{get:function(){return!1}},definitionChanged:{get:function(){return this._definitionChanged}}}),n.Material.CircleWaveMaterialType||(n.Material.CircleWaveMaterialType="CircleWaveMaterial"),n.Material._materialCache.getMaterial(n.Material.CircleWaveMaterialType)||n.Material._materialCache.addMaterial(n.Material.CircleWaveMaterialType,{fabric:{type:n.Material.CircleWaveMaterialType,uniforms:{u_color:n.Color.MEDIUMORCHID,time:1,count:1,gradient:.1},source:"\n\t\t\t\tczm_material czm_getMaterial(czm_materialInput materialInput) {\n\t\t\t\tczm_material material = czm_getDefaultMaterial(materialInput);\n\t\t\t\tmaterial.diffuse = 1.5 * u_color.rgb;\n\t\t\t\tvec2 st = materialInput.st;\n\t\t\t\tvec3 str = materialInput.str;\n\t\t\t\tfloat dis = distance(st, vec2(0.5, 0.5));\n\t\t\t\tfloat per = fract(time);\n\t\t\t\tif (abs(str.z) > 0.001) {\n\t\t\t\tdiscard;\n\t\t\t\t}\n\t\t\t\tif (dis > 0.5) {\n\t\t\t\tdiscard;\n\t\t\t\t} else {\n\t\t\t\tfloat perDis = 0.5 / count;\n\t\t\t\tfloat disNum;\n\t\t\t\tfloat bl = .0;\n\t\t\t\tfor (int i = 0; i <= 9; i++) {\n\t\t\t\tif (float(i) <= count) {\n\t\t\t\tdisNum = perDis *float(i) - dis + per / count;\n\t\t\t\tif (disNum > 0.0) {\n\t\t\t\t\tif (disNum < perDis) {\n\t\t\t\t\tbl = 1.0 - disNum / perDis;\n\t\t\t\t\t} else if(disNum - perDis < perDis) {\n\t\t\t\t\tbl = 1.0 - abs(1.0 - disNum / perDis);\n\t\t\t\t\t}\n\t\t\t\t\tmaterial.alpha = pow(bl, gradient);\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn material;\n\t\t\t}"},translucent:function(t){return!0}});class $ extends G{constructor(e,s){return super(e,s),i(this,"DF",{name:"自定义材质贴竖直线",color:new t.Color(6/255,180/255,178/255,1),width:3,duration:1e3,height:500,waterwave:{show:!0,color:new t.Color(6/255,180/255,178/255,1),maxRadius:50,duration:3e3,count:3,gradient:.5}}),this.options=Object.assign({},this.DF,s),this.add()}add(){try{return this.entity=this.viewer.entities.add({name:new t.CallbackProperty((()=>this.options.name),!1),id:this.options.id,position:new t.CallbackProperty((()=>{var e;return(null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegrees(this.options.lonlats[0],this.options.lonlats[1],this.options.lonlats[2]):this.options.positions[0]}),!1),polyline:{positions:new t.CallbackProperty((()=>{var e;let i=[...this.options.lonlats,this.options.lonlats[0],this.options.lonlats[1],this.options.height];return(null==(e=this.options)?void 0:e.lonlats)?t.Cartesian3.fromDegreesArrayHeights(i):this.options.positions}),!1),width:this.options.width,material:new Z({color:this.options.color,duration:this.options.duration})}}),this.options.waterwave&&this.options.waterwave.show&&(this.entity.ellipse={semiMinorAxis:this.options.waterwave.maxRadius,semiMajorAxis:this.options.waterwave.maxRadius,material:new X({color:this.options.waterwave.color,duration:this.options.waterwave.