angular-cesium
Version:
Angular library for working with Cesium.
16 lines (14 loc) • 290 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("geodesy"),require("util"),require("rxjs/operators"),require("rxjs"),require("primitive-primitives"),require("json-string-mapper"),require("angular2parse"),require("lodash.get")):"function"==typeof define&&define.amd?define("angular-cesium",["exports","@angular/core","@angular/common","geodesy","util","rxjs/operators","rxjs","primitive-primitives","json-string-mapper","angular2parse","lodash.get"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["angular-cesium"]={},t.ng.core,t.ng.common,t.geodesy,t.util,t.rxjs.operators,t.rxjs,t.primitivePrimitives,t.jsonStringMapper,t.angular2parse,t._get)}(this,(function(t,e,i,n,o,r,s,a,c,p,l){"use strict";function d(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var u=d(n),h=d(l),g=function(){function t(){this.cesium=Cesium}return t.prototype.createViewer=function(t,e){return e?new this.cesium.Viewer(t,Object.assign({contextOptions:{webgl:{preserveDrawingBuffer:!0}}},e)):new this.cesium.Viewer(t,{contextOptions:{webgl:{preserveDrawingBuffer:!0}}})},t}();g.decorators=[{type:e.Injectable}],g.ctorParameters=function(){return[]};var y=function(){function t(){this.nextViewerOptionsIndex=0,this.nextViewerModifierIndex=0}return Object.defineProperty(t.prototype,"viewerOptions",{get:function(){return this._viewerOptions},set:function(t){this._viewerOptions=t},enumerable:!1,configurable:!0}),t.prototype.getNextViewerOptions=function(){return this._viewerOptions instanceof Array?this._viewerOptions[this.nextViewerOptionsIndex++]:this._viewerOptions},Object.defineProperty(t.prototype,"viewerModifier",{get:function(){return this._viewerModifier},set:function(t){this._viewerModifier=t},enumerable:!1,configurable:!0}),t.prototype.getNextViewerModifier=function(){return this._viewerModifier instanceof Array?this._viewerModifier[this.nextViewerModifierIndex++]:this._viewerModifier},t}();y.decorators=[{type:e.Injectable}];var f=function(){function t(t,e,i){this.ngZone=t,this.viewerFactory=e,this.viewerConfiguration=i}return t.prototype.init=function(t,e){var i=this;this.map=e,this.ngZone.runOutsideAngular((function(){var e=i.viewerConfiguration?i.viewerConfiguration.getNextViewerOptions():void 0;i.cesiumViewer=i.viewerFactory.createViewer(t,e);var n=i.viewerConfiguration&&i.viewerConfiguration.getNextViewerModifier();"function"==typeof n&&n(i.cesiumViewer)}))},t.prototype.getViewer=function(){return this.cesiumViewer},t.prototype.getScene=function(){return this.cesiumViewer.scene},t.prototype.getCanvas=function(){return this.cesiumViewer.canvas},t.prototype.getMap=function(){return this.map},t}();f.decorators=[{type:e.Injectable}],f.ctorParameters=function(){return[{type:e.NgZone},{type:g},{type:y,decorators:[{type:e.Optional}]}]};var m=Cesium.AssociativeArray,v=Cesium.Color,E=Cesium.ColorGeometryInstanceAttribute,P=Cesium.defined,b=Cesium.DistanceDisplayCondition,C=Cesium.DistanceDisplayConditionGeometryInstanceAttribute,_=Cesium.ShowGeometryInstanceAttribute,M=Cesium.Primitive,S=Cesium.ShadowMode,T=Cesium.BoundingSphereState,A=Cesium.ColorMaterialProperty,O=Cesium.MaterialProperty,I=Cesium.Property,D=new v,L=new b,w=new b;function R(t,e,i,n,o,r,s){var a;this.translucent=e,this.appearanceType=i,this.depthFailAppearanceType=n,this.depthFailMaterialProperty=o,this.depthFailMaterial=void 0,this.closed=r,this.shadows=s,this.primitives=t,this.createPrimitive=!1,this.waitingOnCreate=!1,this.primitive=void 0,this.oldPrimitive=void 0,this.geometry=new m,this.updaters=new m,this.updatersWithAttributes=new m,this.attributes=new m,this.subscriptions=new m,this.showsUpdated=new m,this.itemsToRemove=[],this.invalidated=!1,P(o)&&(a=o.definitionChanged.addEventListener(R.prototype.onMaterialChanged,this)),this.removeMaterialSubscription=a}R.prototype.onMaterialChanged=function(){this.invalidated=!0},R.prototype.isMaterial=function(t){var e=this.depthFailMaterialProperty,i=t.depthFailMaterialProperty;return i===e||!!P(e)&&e.equals(i)},R.prototype.add=function(t,e){var i=t.id;if(this.createPrimitive=!0,this.geometry.set(i,e),this.updaters.set(i,t),t.hasConstantFill&&t.fillMaterialProperty.isConstant&&I.isConstant(t.distanceDisplayConditionProperty)){var n=this;this.subscriptions.set(i,t.entity.definitionChanged.addEventListener((function(e,i,o,r){"isShowing"===i&&n.showsUpdated.set(t.id,t)})))}else this.updatersWithAttributes.set(i,t)},R.prototype.remove=function(t){var e=t.id;if(this.createPrimitive=this.geometry.remove(e)||this.createPrimitive,this.updaters.remove(e)){this.updatersWithAttributes.remove(e);var i=this.subscriptions.get(e);P(i)&&(i(),this.subscriptions.remove(e))}},R.prototype.update=function(t){var e,i,n=!0,o=0,r=this.primitive,s=this.primitives;if(this.createPrimitive){var a=this.geometry.values,c=a.length;if(c>0){for(P(r)&&(P(this.oldPrimitive)?s.remove(r):this.oldPrimitive=r),i=0;i<c;i++){var p=a[i],l=p.attributes;e=this.attributes.get(p.id.id),P(e)&&(P(l.show)&&(l.show.value=e.show),P(l.color)&&(l.color.value=e.color),P(l.depthFailColor)&&(l.depthFailColor.value=e.depthFailColor))}var d;P(this.depthFailAppearanceType)&&(P(this.depthFailMaterialProperty)&&(this.depthFailMaterial=O.getValue(t,this.depthFailMaterialProperty,this.depthFailMaterial)),d=new this.depthFailAppearanceType({material:this.depthFailMaterial,translucent:this.translucent,closed:this.closed})),r=new M({show:!1,asynchronous:!0,geometryInstances:a,appearance:new this.appearanceType({flat:this.shadows===S.DISABLED||this.shadows===S.CAST_ONLY,translucent:this.translucent,closed:this.closed}),depthFailAppearance:d,shadows:this.shadows}),s.add(r),n=!1}else{P(r)&&(s.remove(r),r=void 0);var u=this.oldPrimitive;P(u)&&(s.remove(u),this.oldPrimitive=void 0)}this.attributes.removeAll(),this.primitive=r,this.createPrimitive=!1,this.waitingOnCreate=!0}else if(P(r)&&r.ready){r.show=!0,P(this.oldPrimitive)&&(s.remove(this.oldPrimitive),this.oldPrimitive=void 0),!P(this.depthFailAppearanceType)||this.depthFailMaterialProperty instanceof A||(this.depthFailMaterial=O.getValue(t,this.depthFailMaterialProperty,this.depthFailMaterial),this.primitive.depthFailAppearance.material=this.depthFailMaterial);var h=this.updatersWithAttributes.values,g=h.length,y=this.waitingOnCreate;for(i=0;i<g;i++){var f=h[i],m=this.geometry.get(f.id);if(e=this.attributes.get(m.id.id),P(e)||(e=r.getGeometryInstanceAttributes(m.id),this.attributes.set(m.id.id,e)),!f.fillMaterialProperty.isConstant||y){var T=f.fillMaterialProperty.color,R=I.getValueOrDefault(T,t,v.WHITE,D);v.equals(e._lastColor,R)||(e._lastColor=v.clone(R,e._lastColor),e.color=E.toValue(R,e.color),(this.translucent&&255===e.color[3]||!this.translucent&&255!==e.color[3])&&(this.itemsToRemove[o++]=f))}if(P(this.depthFailAppearanceType)&&f.depthFailMaterialProperty instanceof A&&(!f.depthFailMaterialProperty.isConstant||y)){var x=f.depthFailMaterialProperty.color,j=I.getValueOrDefault(x,t,v.WHITE,D);v.equals(e._lastDepthFailColor,j)||(e._lastDepthFailColor=v.clone(j,e._lastDepthFailColor),e.depthFailColor=E.toValue(j,e.depthFailColor))}var k=f.entity.isShowing&&(f.hasConstantFill||f.isFilled(t));k!==(1===e.show[0])&&(e.show=_.toValue(k,e.show));var N=f.distanceDisplayConditionProperty;if(!I.isConstant(N)){var F=I.getValueOrDefault(N,t,w,L);b.equals(F,e._lastDistanceDisplayCondition)||(e._lastDistanceDisplayCondition=b.clone(F,e._lastDistanceDisplayCondition),e.distanceDisplayCondition=C.toValue(F,e.distanceDisplayCondition))}}this.updateShows(r),this.waitingOnCreate=!1}else P(r)&&!r.ready&&(n=!1);return this.itemsToRemove.length=o,n},R.prototype.updateShows=function(t){for(var e=this.showsUpdated.values,i=e.length,n=0;n<i;n++){var o=e[n],r=this.geometry.get(o.id),s=this.attributes.get(r.id.id);P(s)||(s=t.getGeometryInstanceAttributes(r.id),this.attributes.set(r.id.id,s));var a=o.entity.isShowing;a!==(1===s.show[0])&&(s.show=_.toValue(a,s.show))}this.showsUpdated.removeAll()},R.prototype.contains=function(t){return this.updaters.contains(t.id)},R.prototype.getBoundingSphere=function(t,e){var i=this.primitive;if(!i.ready)return T.PENDING;var n=i.getGeometryInstanceAttributes(t.entity);return!P(n)||!P(n.boundingSphere)||P(n.show)&&0===n.show[0]?T.FAILED:(n.boundingSphere.clone(e),T.DONE)},R.prototype.removeAllPrimitives=function(){var t=this.primitives,e=this.primitive;P(e)&&(t.remove(e),this.primitive=void 0,this.geometry.removeAll(),this.updaters.removeAll());var i=this.oldPrimitive;P(i)&&(t.remove(i),this.oldPrimitive=void 0)},R.prototype.destroy=function(){var t=this.primitive,e=this.primitives;P(t)&&e.remove(t);var i=this.oldPrimitive;P(i)&&e.remove(i),P(this.removeMaterialSubscription)&&this.removeMaterialSubscription()};var x=!1;var j,k=new e.InjectionToken("ANGULAR_CESIUM_CONFIG"),N=function(t){this.config=t,!1!==(!t||t.fixEntitiesShadows)&&(x||(Cesium.StaticGeometryColorBatch.prototype.add=function(t,e){var i,n,o=e.createFillGeometryInstance(t);255===o.attributes.color.value[3]?(i=this._solidItems,n=!1):(i=this._translucentItems,n=!0);for(var r=i.length,s=0;s<r;s++){var a=i[s];if(a.isMaterial(e))return void a.add(e,o)}var c=new R(this._primitives,n,this._appearanceType,this._depthFailAppearanceType,e.depthFailMaterialProperty,this._closed,this._shadows);c.add(e,o),i.push(c)},x=!0))};N.decorators=[{type:e.Injectable}],N.ctorParameters=function(){return[{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[k]}]}]},t.SceneMode=void 0,(j=t.SceneMode||(t.SceneMode={}))[j.SCENE3D=0]="SCENE3D",j[j.COLUMBUS_VIEW=1]="COLUMBUS_VIEW",j[j.SCENE2D=2]="SCENE2D",j[j.PERFORMANCE_SCENE2D=3]="PERFORMANCE_SCENE2D";var F,H,V=function(){function e(){this.isSceneModePerformance2D=!1}return e.prototype.init=function(t){this.viewer=t.getViewer(),this.scene=t.getScene(),this.screenSpaceCameraController=this.scene.screenSpaceCameraController,this.camera=this.scene.camera,this.lastRotate=this.screenSpaceCameraController.enableRotate,this.lastTilt=this.screenSpaceCameraController.enableTilt,this.lastLook=this.screenSpaceCameraController.enableLook},e.prototype._listenToSceneModeMorph=function(t){this.morphListenerCancelFn=this.scene.morphStart.addEventListener(t)},e.prototype._revertCameraProperties=function(){this.isSceneModePerformance2D=!1,this.enableTilt(this.lastTilt),this.enableRotate(this.lastRotate),this.enableLook(this.lastLook)},e.prototype.getCamera=function(){return this.camera},e.prototype.getScreenSpaceCameraController=function(){return this.screenSpaceCameraController},e.prototype.getMinimumZoom=function(){return this.screenSpaceCameraController.minimumZoomDistance},e.prototype.setMinimumZoom=function(t){this.screenSpaceCameraController.minimumZoomDistance=t},e.prototype.getMaximumZoom=function(){return this.screenSpaceCameraController.maximumZoomDistance},e.prototype.setMaximumZoom=function(t){this.screenSpaceCameraController.maximumZoomDistance=t},e.prototype.enableTilt=function(t){this.screenSpaceCameraController.enableTilt=t},e.prototype.enableRotate=function(t){this.screenSpaceCameraController.enableRotate=t},e.prototype.enableLook=function(t){this.screenSpaceCameraController.enableLook=t},e.prototype.enableTranslate=function(t){this.screenSpaceCameraController.enableTranslate=t},e.prototype.enableZoom=function(t){this.screenSpaceCameraController.enableZoom=t},e.prototype.enableInputs=function(t){this.screenSpaceCameraController.enableInputs=t},e.prototype.setSceneMode=function(i,n){var o=this;switch(i){case t.SceneMode.SCENE3D:this.isSceneModePerformance2D&&this._revertCameraProperties(),this.scene.morphTo3D(n);break;case t.SceneMode.COLUMBUS_VIEW:this.isSceneModePerformance2D&&this._revertCameraProperties(),this.scene.morphToColumbusView(n);break;case t.SceneMode.SCENE2D:this.isSceneModePerformance2D&&this._revertCameraProperties(),this.scene.morphTo2D(n);break;case t.SceneMode.PERFORMANCE_SCENE2D:this.isSceneModePerformance2D=!0,this.lastLook=this.screenSpaceCameraController.enableLook,this.lastTilt=this.screenSpaceCameraController.enableTilt,this.lastRotate=this.screenSpaceCameraController.enableRotate,this.screenSpaceCameraController.enableTilt=!1,this.screenSpaceCameraController.enableRotate=!1,this.screenSpaceCameraController.enableLook=!1,this.morphListenerCancelFn&&this.morphListenerCancelFn(),this.scene.morphToColumbusView(n);var r=this.scene.morphComplete.addEventListener((function(){o.camera.setView({destination:Cesium.Cartesian3.fromDegrees(0,0,Math.min(e.PERFORMANCE_2D_ALTITUDE,o.getMaximumZoom())),orientation:{pitch:Cesium.Math.toRadians(-90)}}),r(),o._listenToSceneModeMorph(o._revertCameraProperties.bind(o))}))}},e.prototype.cameraFlyTo=function(t){return this.camera.flyTo(t)},e.prototype.flyTo=function(t,e){return this.viewer.flyTo(t,e)},e.prototype.zoomIn=function(t){return this.camera.zoomIn(t||this.camera.defaultZoomAmount)},e.prototype.zoomOut=function(t){return this.camera.zoomOut(t||this.camera.defaultZoomAmount)},e.prototype.zoomTo=function(t,e){return this.viewer.zoomTo(t,e)},e.prototype.setView=function(t){this.camera.setView(t)},e.prototype.setRotation=function(t){this.setView({orientation:{heading:t}})},e.prototype.lockRotation=function(t){this.scene.screenSpaceCameraController.enableRotate=!t},e.prototype.trackEntity=function(t,e){var i=this,n=e&&e.flyTo||!1;return this.viewer.trackedEntity=void 0,new Promise((function(o){if(n){var r=e&&e.flyToDuration||1,s=e&&e.altitude||1e4,a=t.position.getValue(Cesium.JulianDate.now()),c=Cesium.Cartographic.fromCartesian(a),p=s-c.height;c.height=s;var l=Cesium.Cartesian3.fromRadians(c.longitude,c.latitude,c.height);i.cameraFlyTo({duration:r,destination:l,complete:function(){i.viewer.trackedEntity=t,setTimeout((function(){p>0?i.camera.zoomOut(p):i.camera.zoomIn(p)}),0),o()}})}else i.viewer.trackedEntity=t,o()}))},e.prototype.untrackEntity=function(){this.trackEntity()},e}();V.PERFORMANCE_2D_ALTITUDE=25e6,V.decorators=[{type:e.Injectable}],V.ctorParameters=function(){return[]},t.CesiumEvent=void 0,(F=t.CesiumEvent||(t.CesiumEvent={}))[F.MOUSE_MOVE=Cesium.ScreenSpaceEventType.MOUSE_MOVE]="MOUSE_MOVE",F[F.LEFT_CLICK=Cesium.ScreenSpaceEventType.LEFT_CLICK]="LEFT_CLICK",F[F.LEFT_DOUBLE_CLICK=Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK]="LEFT_DOUBLE_CLICK",F[F.LEFT_DOWN=Cesium.ScreenSpaceEventType.LEFT_DOWN]="LEFT_DOWN",F[F.LEFT_UP=Cesium.ScreenSpaceEventType.LEFT_UP]="LEFT_UP",F[F.MIDDLE_CLICK=Cesium.ScreenSpaceEventType.MIDDLE_CLICK]="MIDDLE_CLICK",F[F.MIDDLE_DOUBLE_CLICK=Cesium.ScreenSpaceEventType.MIDDLE_DOUBLE_CLICK]="MIDDLE_DOUBLE_CLICK",F[F.MIDDLE_DOWN=Cesium.ScreenSpaceEventType.MIDDLE_DOWN]="MIDDLE_DOWN",F[F.MIDDLE_UP=Cesium.ScreenSpaceEventType.MIDDLE_UP]="MIDDLE_UP",F[F.PINCH_START=Cesium.ScreenSpaceEventType.PINCH_START]="PINCH_START",F[F.PINCH_END=Cesium.ScreenSpaceEventType.PINCH_END]="PINCH_END",F[F.PINCH_MOVE=Cesium.ScreenSpaceEventType.PINCH_MOVE]="PINCH_MOVE",F[F.RIGHT_CLICK=Cesium.ScreenSpaceEventType.RIGHT_CLICK]="RIGHT_CLICK",F[F.RIGHT_DOUBLE_CLICK=Cesium.ScreenSpaceEventType.RIGHT_DOUBLE_CLICK]="RIGHT_DOUBLE_CLICK",F[F.RIGHT_DOWN=Cesium.ScreenSpaceEventType.RIGHT_DOWN]="RIGHT_DOWN",F[F.RIGHT_UP=Cesium.ScreenSpaceEventType.RIGHT_UP]="RIGHT_UP",F[F.WHEEL=Cesium.ScreenSpaceEventType.WHEEL]="WHEEL",F[F.LONG_LEFT_PRESS=110]="LONG_LEFT_PRESS",F[F.LONG_RIGHT_PRESS=111]="LONG_RIGHT_PRESS",F[F.LONG_MIDDLE_PRESS=112]="LONG_MIDDLE_PRESS",F[F.LEFT_CLICK_DRAG=113]="LEFT_CLICK_DRAG",F[F.RIGHT_CLICK_DRAG=114]="RIGHT_CLICK_DRAG",F[F.MIDDLE_CLICK_DRAG=115]="MIDDLE_CLICK_DRAG",t.PickOptions=void 0,(H=t.PickOptions||(t.PickOptions={}))[H.NO_PICK=0]="NO_PICK",H[H.PICK_FIRST=1]="PICK_FIRST",H[H.PICK_ONE=2]="PICK_ONE",H[H.PICK_ALL=3]="PICK_ALL";var B=function(){function i(){this._showContextMenu=!1,this._contextMenuChangeNotifier=new e.EventEmitter,this._onOpen=new e.EventEmitter,this._onClose=new e.EventEmitter,this._defaultContextMenuOptions={closeOnLeftCLick:!0,closeOnLeftClickPriority:10}}return Object.defineProperty(i.prototype,"contextMenuChangeNotifier",{get:function(){return this._contextMenuChangeNotifier},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"showContextMenu",{get:function(){return this._showContextMenu},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"content",{get:function(){return this._content},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onOpen",{get:function(){return this._onOpen},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onClose",{get:function(){return this._onClose},enumerable:!1,configurable:!0}),i.prototype.init=function(t){this.mapEventsManager=t},i.prototype.open=function(e,i,n){var o=this;void 0===n&&(n={}),this.close(),this._content=e,this._position=i,this._options=Object.assign({},this._defaultContextMenuOptions,n),this._showContextMenu=!0,this.mapEventsManager&&this._options.closeOnLeftCLick&&(this.leftClickRegistration=this.mapEventsManager.register({event:t.CesiumEvent.LEFT_CLICK,pick:t.PickOptions.NO_PICK,priority:this._options.closeOnLeftClickPriority}),this.leftClickSubscription=this.leftClickRegistration.subscribe((function(){o.leftClickSubscription.unsubscribe(),o.close()}))),this._contextMenuChangeNotifier.emit(),this._onOpen.emit()},i.prototype.close=function(){this._content=void 0,this._position=void 0,this._options=void 0,this._showContextMenu=!1,this.leftClickRegistration&&(this.leftClickRegistration.dispose(),this.leftClickRegistration=void 0),this.leftClickSubscription&&(this.leftClickSubscription.unsubscribe(),this.leftClickSubscription=void 0),this._contextMenuChangeNotifier.emit(),this._onClose.emit()},i}();B.decorators=[{type:e.Injectable}];var U=u.LatLonVectors;window.geodesy=u;var G=function(){function t(t){this.cesiumService=t}return t.cartesian3ToLatLon=function(t,e){var i=Cesium.Cartographic.fromCartesian(t,e);return{lon:Cesium.Math.toDegrees(i.longitude),lat:Cesium.Math.toDegrees(i.latitude),height:i.height}},t.prototype.screenToCartesian3=function(t,e){if(this.cesiumService){var i=Object.assign({},t);if(e){var n=this.cesiumService.getViewer().canvas.getBoundingClientRect();i.x+=n.left,i.y+=n.top}return this.cesiumService.getViewer().camera.pickEllipsoid(i)}throw new Error("ANGULAR2-CESIUM - Cesium service should be provided in order to do screen position calculations")},t.prototype.screenToCartographic=function(t,e){return this.cartesian3ToCartographic(this.screenToCartesian3(t),e)},t.prototype.cartesian3ToCartographic=function(t,e){return Cesium.Cartographic.fromCartesian(t,e)},t.prototype.degreesToCartographic=function(t,e,i){return Cesium.Cartographic.fromDegrees(t,e,i)},t.prototype.radiansToCartographic=function(t,e,i){return Cesium.Cartographic.fromRadians(t,e,i)},t.prototype.degreesToUTM=function(t,e){return new n.LatLonEllipsoidal(e,t).toUtm()},t.prototype.UTMToDegrees=function(t,e,i,o){return this.geodesyToCesiumObject(new n.Utm(t,e,i,o).toLatLonE())},t.prototype.geodesyToCesiumObject=function(t){return{longitude:t.lon,latitude:t.lat,height:t.height?t.height:0}},t.prototype.midPointToCartesian3=function(t,e){var i=function(t){return Cesium.Math.toDegrees(t)},n=new U(i(t.latitude),i(t.longitude)),o=new U(i(e.latitude),i(e.longitude)),r=n.midpointTo(o);return Cesium.Cartesian3.fromDegrees(r.lon,r.lat)},t.prototype.middlePointByScreen=function(t,e){var i=this.cesiumService.getScene(),n=Cesium.SceneTransforms.wgs84ToWindowCoordinates(i,t),o=Cesium.SceneTransforms.wgs84ToWindowCoordinates(i,e),r=new Cesium.Cartesian2((o.x+n.x)/2,(o.y+n.y)/2);return i.pickPosition(r)},t.prototype.bearingTo=function(t,e){var i=function(t){return Cesium.Math.toDegrees(t)},n=new U(i(t.latitude),i(t.longitude)),o=new U(i(e.latitude),i(e.longitude));return n.bearingTo(o)},t.prototype.bearingToCartesian=function(t,e){var i=Cesium.Cartographic.fromCartesian(t),n=Cesium.Cartographic.fromCartesian(e);return this.bearingTo(i,n)},t}();G.decorators=[{type:e.Injectable}],G.ctorParameters=function(){return[{type:f,decorators:[{type:e.Optional}]}]};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var K=function(t,e){return(K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function z(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}K(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}Object.create;function W(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,o,r=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return s}function $(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(W(arguments[e]));return t}Object.create;var Y=function(){function t(){}return t.prototype.setPropsAssigner=function(t){this._propsAssigner=t},t}(),Z=function(t){function e(e,i){var n=t.call(this)||this;return n.drawerType=e,n.cesiumService=i,n._show=!0,n}return z(e,t),e.prototype.init=function(){var t=this.cesiumService.getScene();this._cesiumCollection=new this.drawerType({scene:t}),this._primitiveCollectionWrap=new Cesium.PrimitiveCollection,this._primitiveCollectionWrap.add(this._cesiumCollection),t.primitives.add(this._primitiveCollectionWrap)},e.prototype.add=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return this._cesiumCollection.add(t)},e.prototype.update=function(t,e){for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];this._propsAssigner?this._propsAssigner(t,e):Object.assign(t,e)},e.prototype.remove=function(t){this._cesiumCollection.remove(t)},e.prototype.removeAll=function(){this._cesiumCollection.removeAll()},e.prototype.setShow=function(t){this._show=t,this._primitiveCollectionWrap.show=t},e.prototype.getShow=function(){return this._show},e}(Y),q=function(){function t(t){this.cesiumService=t}return t.pointByLocationDistanceAndAzimuth=function(e,i,n,o){for(var r,s,a=i/Cesium.Ellipsoid.WGS84.maximumRadius,c=e instanceof Cesium.Cartesian3?Cesium.Cartographic.fromCartesian(e):e,p=e instanceof Cesium.Cartesian3?e:Cesium.Cartesian3.fromRadians(e.longitude,e.latitude,e.height),l=0,d=.1,u=-.1;0===l||l<16&&Math.max(s,i)/Math.min(s,i)>1.000001;){var h=u+(d-u)/2;r=t._pointByLocationDistanceAndAzimuth(c,a*(1+h),n),(s=this.distance(p,r))>i?d=u+(d-u)/2:u+=(d-u)/2,l++}return r},t._pointByLocationDistanceAndAzimuth=function(t,e,i){var n=t.latitude,o=t.longitude,r=Math.asin(Math.sin(n)*Math.cos(e)+Math.cos(n)*Math.sin(e)*Math.cos(i)),s=o+Math.atan2(Math.sin(i)*Math.sin(e)*Math.cos(n),Math.cos(e)-Math.sin(n)*Math.sin(r));return s=(s+3*Math.PI)%(2*Math.PI)-Math.PI,Cesium.Cartesian3.fromRadians(s,r)},t.distance=function(t,e){return Cesium.Cartesian3.distance(t,e)},t.getPositionsDelta=function(t,e){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}},t.addDeltaToPosition=function(t,e,i){if(void 0===i&&(i=!1),i){t.x+=e.x,t.y+=e.y,t.z+=e.z,(o=Cesium.Cartographic.fromCartesian(t)).height=0;var n=Cesium.Cartesian3.fromRadians(o.longitude,o.latitude,o.height);return t.x=n.x,t.y=n.y,t.z=n.z,t}var o;n=new Cesium.Cartesian3(t.x+e.x,t.y+e.y,t.z+e.z);return(o=Cesium.Cartographic.fromCartesian(n)).height=0,Cesium.Cartesian3.fromRadians(o.longitude,o.latitude,o.height)},t.middleCartesian3Point=function(t,e){return new Cesium.Cartesian3(e.x-t.x/2,e.y-t.y/2,e.z-t.z/2)},t.prototype.screenPositionToCartesian3=function(t){return this.cesiumService.getViewer().camera.pickEllipsoid(t)},t}();q.decorators=[{type:e.Injectable}],q.ctorParameters=function(){return[{type:f}]};var X,J=function(t){function e(e){return t.call(this,Cesium.PolylineCollection,e)||this}return z(e,t),e.prototype._calculateArcPositions=function(t){for(var e=t.quality||18,i=t.delta/e,n=[],o=0;o<e+1;++o){var r=q.pointByLocationDistanceAndAzimuth(t.center,t.radius,t.angle+i*o,!0);n.push(r)}return n},e.prototype._calculateTriangle=function(t){return[t.center,q.pointByLocationDistanceAndAzimuth(t.center,t.radius,t.angle,!0)]},e.prototype._calculateArc=function(t){var e=this._calculateArcPositions(t);return t.drawEdges?e.concat(this._calculateTriangle(t)):e},e.prototype.add=function(t){if(t.positions=this._calculateArc(t),t.color){var e=Cesium.Material.fromType("Color");e.uniforms.color=t.color,t.material=e}return this._cesiumCollection.add(t)},e.prototype.update=function(t,e){return e.constantColor||!e.color||t.material.uniforms.color.equals(e.color)||(t.material.uniforms.color=e.color),t.width=void 0!==e.width?e.width:t.width,t.show=void 0!==e.show?e.show:t.show,t.distanceDisplayCondition=void 0!==e.distanceDisplayCondition?e.distanceDisplayCondition:t.distanceDisplayCondition,t.positions=this._calculateArc(e),t},e}(Z);J.decorators=[{type:e.Injectable}],J.ctorParameters=function(){return[{type:f}]},t.ɵf=void 0,(X=t.ɵf||(t.ɵf={}))[X.ellipse=Cesium.EllipseGraphics]="ellipse",X[X.ellipsoid=Cesium.EllipsoidGraphics]="ellipsoid",X[X.polygon=Cesium.PolygonGraphics]="polygon",X[X.polyline=Cesium.PolylineGraphics]="polyline",X[X.polylineVolume=Cesium.PolylineVolumeGraphics]="polylineVolume",X[X.box=Cesium.BoxGraphics]="box",X[X.corridor=Cesium.CorridorGraphics]="corridor",X[X.cylinder=Cesium.CylinderGraphics]="cylinder",X[X.label=Cesium.LabelGraphics]="label",X[X.billboard=Cesium.BillboardGraphics]="billboard",X[X.model=Cesium.ModelGraphics]="model",X[X.path=Cesium.PathGraphics]="path",X[X.point=Cesium.PointGraphics]="point",X[X.rectangle=Cesium.RectangleGraphics]="rectangle",X[X.wall=Cesium.WallGraphics]="wall";var Q=function(){function t(t,e,i){void 0===e&&(e=-1),void 0===i&&(i=-1),this.entityCollection=t,this._isSuspended=!1,this._isHardSuspend=!1,this._updateRate=i,this._collectionSize=e}return t.prototype.setShow=function(t){this.entityCollection.show=t},Object.defineProperty(t.prototype,"isSuspended",{get:function(){return this._isSuspended},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateRate",{get:function(){return this._updateRate},set:function(t){this._updateRate=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collectionSize",{get:function(){return this._collectionSize},set:function(t){this._collectionSize=t},enumerable:!1,configurable:!0}),t.prototype.collection=function(){return this.entityCollection},t.prototype.isFree=function(){return this._collectionSize<1||this.entityCollection.values.length<this._collectionSize},t.prototype.add=function(t){return this.suspend(),this.entityCollection.add(t)},t.prototype.remove=function(t){return this.suspend(),this.entityCollection.remove(t)},t.prototype.removeNoSuspend=function(t){this.entityCollection.remove(t)},t.prototype.removeAll=function(){this.suspend(),this.entityCollection.removeAll()},t.prototype.onEventSuspension=function(t,e){var i=this;return void 0===e&&(e=!1),this._onEventSuspensionCallback={callback:t,once:e},function(){i._onEventSuspensionCallback=void 0}},t.prototype.onEventResume=function(t,e){var i=this;return void 0===e&&(e=!1),this._onEventResumeCallback={callback:t,once:e},this._isSuspended||this.triggerEventResume(),function(){i._onEventResumeCallback=void 0}},t.prototype.triggerEventSuspension=function(){if(void 0!==this._onEventSuspensionCallback){var t=this._onEventSuspensionCallback.callback;this._onEventSuspensionCallback.once&&(this._onEventSuspensionCallback=void 0),t()}},t.prototype.triggerEventResume=function(){if(void 0!==this._onEventResumeCallback){var t=this._onEventResumeCallback.callback;this._onEventResumeCallback.once&&(this._onEventResumeCallback=void 0),t()}},t.prototype.suspend=function(){var t=this;this._updateRate<0||this._isHardSuspend||this._isSuspended||(this._isSuspended=!0,this.entityCollection.suspendEvents(),this.triggerEventSuspension(),this._suspensionTimeout=setTimeout((function(){t.entityCollection.resumeEvents(),t.triggerEventResume(),t._isSuspended=!1,t._suspensionTimeout=void 0}),this._updateRate))},t.prototype.hardSuspend=function(){this.entityCollection.suspendEvents(),this._isHardSuspend=!0},t.prototype.hardResume=function(){this.entityCollection.resumeEvents(),this._isHardSuspend=!1},t}(),tt=function(e){function i(i,n,o){void 0===o&&(o={collectionMaxSize:-1,collectionSuspensionTime:-1,collectionsNumber:1});var r=e.call(this)||this;for(var s in r.cesiumService=i,r.graphicsType=n,r.defaultOptions=o,r.entityCollections=new Map,r.graphicsTypeName=t.ɵf[r.graphicsType],t.ɵf)t.ɵf[s]===r.graphicsType&&(r.graphicsTypeName=s);return r}return z(i,e),i.prototype.getFreeEntitiesCollection=function(){var t=null;return this.entityCollections.forEach((function(e){e.isFree()&&(t=e)})),t},i.prototype.init=function(t){for(var e=t||this.defaultOptions,i=[],n=0;n<e.collectionsNumber;n++){var o=new Cesium.CustomDataSource(this.graphicsTypeName);i.push(o),this.cesiumService.getViewer().dataSources.add(o),this.entityCollections.set(o.entities,new Q(o.entities,e.collectionMaxSize,e.collectionSuspensionTime))}return i},i.prototype.add=function(t){var e,i=this.getFreeEntitiesCollection();if(null===i)throw new Error("No more free entity collections");var n=((e={position:void 0!==t.position?t.position:void 0,description:void 0!==t.description?t.description:void 0,orientation:void 0!==t.orientation?t.orientation:void 0,viewFrom:void 0!==t.viewFrom?t.viewFrom:void 0})[this.graphicsTypeName]=t,e);return void 0!==t.name&&(n.name=t.name),void 0!==t.availability&&(n.availability=t.availability),i.add(n)},i.prototype.update=function(t,e){this.suspendEntityCollection(t),t.position instanceof Cesium.CallbackProperty&&t.position._isConstant&&(t.position=e.position),t.position=void 0!==e.position?e.position:void 0,t.name=void 0!==e.name?e.name:t.name,t.description=void 0!==e.description?e.description:t.description,t.orientation=void 0!==e.orientation?e.orientation:t.orientation,t.viewFrom=void 0!==e.viewFrom?e.viewFrom:t.viewFrom,t.availability=(e.availability,e.availability),this._propsAssigner?this._propsAssigner(t[this.graphicsTypeName],e):Object.assign(t[this.graphicsTypeName],e)},i.prototype.remove=function(t){this.entityCollections.get(t.entityCollection).remove(t)},i.prototype.removeAll=function(){this.entityCollections.forEach((function(t){t.removeAll()}))},i.prototype.setShow=function(t){this.entityCollections.forEach((function(e){e.setShow(t)}))},i.prototype.suspendEntityCollection=function(t){var e=t.entityCollection;if(!this.entityCollections.has(e))throw new Error("No EntityCollection for entity.entityCollection");this.entityCollections.get(e).suspend()},i}(Y),et=function(e){function i(i){return e.call(this,i,t.ɵf.billboard)||this}return z(i,e),i}(tt);et.decorators=[{type:e.Injectable}],et.ctorParameters=function(){return[{type:f}]};var it=function(t){function e(e){var i=t.call(this)||this;return i.cesiumService=e,i}return z(e,t),e.prototype.init=function(t){var e=[];return this.czmlStream=new Cesium.CzmlDataSource("czml"),e.push(this.czmlStream),this.cesiumService.getViewer().dataSources.add(this.czmlStream),e},e.prototype.add=function(t){return this.czmlStream.process(t.czmlPacket),t},e.prototype.update=function(t,e){this.czmlStream.process(e.czmlPacket)},e.prototype.remove=function(t){this.czmlStream.entities.removeById(t.acEntity.id)},e.prototype.removeAll=function(){this.czmlStream.entities.removeAll()},e.prototype.setShow=function(t){this.czmlStream.entities.show=t},e}(Y);it.decorators=[{type:e.Injectable}],it.ctorParameters=function(){return[{type:f}]};var nt=function(e){function i(i){return e.call(this,i,t.ɵf.ellipse)||this}return z(i,e),i}(tt);nt.decorators=[{type:e.Injectable}],nt.ctorParameters=function(){return[{type:f}]};var ot=function(e){function i(i){return e.call(this,i,t.ɵf.label)||this}return z(i,e),i}(tt);ot.decorators=[{type:e.Injectable}],ot.ctorParameters=function(){return[{type:f}]};var rt=function(e){function i(i){return e.call(this,i,t.ɵf.point)||this}return z(i,e),i}(tt);rt.decorators=[{type:e.Injectable}],rt.ctorParameters=function(){return[{type:f}]};var st=function(e){function i(i){return e.call(this,i,t.ɵf.polygon)||this}return z(i,e),i}(tt);st.decorators=[{type:e.Injectable}],st.ctorParameters=function(){return[{type:f}]};var at=function(e){function i(i){return e.call(this,i,t.ɵf.polyline)||this}return z(i,e),i}(tt);at.decorators=[{type:e.Injectable}],at.ctorParameters=function(){return[{type:f}]};var ct,pt,lt=function(t){function e(e){return t.call(this,Cesium.PolylineCollection,e)||this}return z(e,t),e.prototype.add=function(t){return this._cesiumCollection.add(this.withColorMaterial(t))},e.prototype.update=function(e,i){i.material instanceof Cesium.Color&&(e.material&&e.material.uniforms&&e.material.uniforms.color instanceof Cesium.Color?this.withColorMaterial(i):e.material.uniforms.color.equals(i.material)||(e.material.uniforms.color=i.material)),t.prototype.update.call(this,e,i)},e.prototype.withColorMaterial=function(t){if(t.material instanceof Cesium.Color){var e=Cesium.Material.fromType("Color");e.uniforms.color=t.material,t.material=e}return t},e}(Z);lt.decorators=[{type:e.Injectable}],lt.ctorParameters=function(){return[{type:f}]},t.KeyboardAction=void 0,(ct=t.KeyboardAction||(t.KeyboardAction={}))[ct.CAMERA_FORWARD=0]="CAMERA_FORWARD",ct[ct.CAMERA_BACKWARD=1]="CAMERA_BACKWARD",ct[ct.CAMERA_RIGHT=2]="CAMERA_RIGHT",ct[ct.CAMERA_LEFT=3]="CAMERA_LEFT",ct[ct.CAMERA_UP=4]="CAMERA_UP",ct[ct.CAMERA_DOWN=5]="CAMERA_DOWN",ct[ct.CAMERA_LOOK_RIGHT=6]="CAMERA_LOOK_RIGHT",ct[ct.CAMERA_LOOK_LEFT=7]="CAMERA_LOOK_LEFT",ct[ct.CAMERA_LOOK_UP=8]="CAMERA_LOOK_UP",ct[ct.CAMERA_LOOK_DOWN=9]="CAMERA_LOOK_DOWN",ct[ct.CAMERA_TWIST_RIGHT=10]="CAMERA_TWIST_RIGHT",ct[ct.CAMERA_TWIST_LEFT=11]="CAMERA_TWIST_LEFT",ct[ct.CAMERA_ROTATE_RIGHT=12]="CAMERA_ROTATE_RIGHT",ct[ct.CAMERA_ROTATE_LEFT=13]="CAMERA_ROTATE_LEFT",ct[ct.CAMERA_ROTATE_UP=14]="CAMERA_ROTATE_UP",ct[ct.CAMERA_ROTATE_DOWN=15]="CAMERA_ROTATE_DOWN",ct[ct.CAMERA_ZOOM_IN=16]="CAMERA_ZOOM_IN",ct[ct.CAMERA_ZOOM_OUT=17]="CAMERA_ZOOM_OUT";var dt,ut=100,ht=.01,gt=.01,yt=((pt={})[t.KeyboardAction.CAMERA_FORWARD]=function(t,e){var i=t.getViewer().camera,n=t.getScene().globe.ellipsoid.cartesianToCartographic(i.position).height/(e.moveRate||ut);i.moveForward(n)},pt[t.KeyboardAction.CAMERA_BACKWARD]=function(t,e){var i=t.getViewer().camera,n=t.getScene().globe.ellipsoid.cartesianToCartographic(i.position).height/(e.moveRate||ut);i.moveBackward(n)},pt[t.KeyboardAction.CAMERA_UP]=function(t,e){var i=t.getViewer().camera,n=t.getScene().globe.ellipsoid.cartesianToCartographic(i.position).height/(e.moveRate||ut);i.moveUp(n)},pt[t.KeyboardAction.CAMERA_DOWN]=function(t,e){var i=t.getViewer().camera,n=t.getScene().globe.ellipsoid.cartesianToCartographic(i.position).height/(e.moveRate||ut);i.moveDown(n)},pt[t.KeyboardAction.CAMERA_RIGHT]=function(t,e){var i=t.getViewer().camera,n=t.getScene().globe.ellipsoid.cartesianToCartographic(i.position).height/(e.moveRate||ut);i.moveRight(n)},pt[t.KeyboardAction.CAMERA_LEFT]=function(t,e){var i=t.getViewer().camera,n=t.getScene().globe.ellipsoid.cartesianToCartographic(i.position).height/(e.moveRate||ut);i.moveLeft(n)},pt[t.KeyboardAction.CAMERA_LOOK_RIGHT]=function(t,e){var i=t.getViewer().camera,n=i.positionCartographic,o=e.lookFactor||ht;i.lookRight(n.latitude*o)},pt[t.KeyboardAction.CAMERA_LOOK_LEFT]=function(t,e){var i=t.getViewer().camera,n=i.positionCartographic,o=e.lookFactor||ht;i.lookLeft(n.latitude*o)},pt[t.KeyboardAction.CAMERA_LOOK_UP]=function(t,e){var i=t.getViewer().camera,n=i.positionCartographic,o=e.lookFactor||ht;i.lookUp(n.longitude*(-1*o))},pt[t.KeyboardAction.CAMERA_LOOK_DOWN]=function(t,e){var i=t.getViewer().camera,n=i.positionCartographic,o=e.lookFactor||ht;i.lookDown(n.longitude*(-1*o))},pt[t.KeyboardAction.CAMERA_TWIST_RIGHT]=function(t,e){var i=t.getViewer().camera,n=e.amount||.01;i.twistRight(n)},pt[t.KeyboardAction.CAMERA_TWIST_LEFT]=function(t,e){var i=t.getViewer().camera,n=e.amount||.01;i.twistLeft(n)},pt[t.KeyboardAction.CAMERA_ROTATE_RIGHT]=function(t,e){var i=t.getViewer().camera,n=e.angle||gt;i.rotateRight(n)},pt[t.KeyboardAction.CAMERA_ROTATE_LEFT]=function(t,e){var i=t.getViewer().camera,n=e.angle||gt;i.rotateLeft(n)},pt[t.KeyboardAction.CAMERA_ROTATE_UP]=function(t,e){var i=t.getViewer().camera,n=e.angle||gt;i.rotateUp(n)},pt[t.KeyboardAction.CAMERA_ROTATE_DOWN]=function(t,e){var i=t.getViewer().camera,n=e.angle||gt;i.rotateDown(n)},pt[t.KeyboardAction.CAMERA_ZOOM_IN]=function(t,e){var i=t.getViewer().camera,n=e.amount;i.zoomIn(n)},pt[t.KeyboardAction.CAMERA_ZOOM_OUT]=function(t,e){var i=t.getViewer().camera,n=e.amount;i.zoomOut(n)},pt);!function(t){t[t.IGNORED=0]="IGNORED",t[t.NOT_PRESSED=1]="NOT_PRESSED",t[t.PRESSED=2]="PRESSED"}(dt||(dt={}));var ft=function(){function t(t,e,i){this.ngZone=t,this.cesiumService=e,this.document=i,this._currentDefinitions=null,this._activeDefinitions={},this._keyMappingFn=this.defaultKeyMappingFn}return t.prototype.init=function(){var t=this.cesiumService.getCanvas();t.addEventListener("click",(function(){t.focus()})),this.handleKeydown=this.handleKeydown.bind(this),this.handleKeyup=this.handleKeyup.bind(this),this.handleTick=this.handleTick.bind(this)},t.prototype.setKeyboardControls=function(t,e,i){var n=this;if(void 0===i&&(i=!1),!t)return this.removeKeyboardControls();this._currentDefinitions||this.registerEvents(i),this._currentDefinitions=t,this._keyMappingFn=e||this.defaultKeyMappingFn,Object.keys(this._currentDefinitions).forEach((function(t){n._activeDefinitions[t]={state:dt.NOT_PRESSED,action:null,keyboardEvent:null}}))},t.prototype.removeKeyboardControls=function(){this.unregisterEvents(),this._currentDefinitions=null},t.prototype.getAction=function(t){return this._currentDefinitions[t]||null},t.prototype.defaultKeyMappingFn=function(t){return String.fromCharCode(t.keyCode)},t.prototype.handleKeydown=function(t){var e=this._keyMappingFn(t),i=this.getAction(e);if(i&&this._activeDefinitions[e].state!==dt.IGNORED){var n=!0,o=this.getParams(i.params,t);i.validation&&(n=i.validation(this.cesiumService,o,t)),!0===n&&(this._activeDefinitions[e]={state:dt.PRESSED,action:i,keyboardEvent:t})}},t.prototype.handleKeyup=function(t){var e=this._keyMappingFn(t),i=this.getAction(e);i&&(this._activeDefinitions[e]={state:dt.NOT_PRESSED,action:null,keyboardEvent:t},i.done&&"function"==typeof i.done&&i.done(this.cesiumService,t))},t.prototype.handleTick=function(){var t=this;Object.keys(this._activeDefinitions).forEach((function(e){var i=t._activeDefinitions[e];null!==i&&null!==i.action&&i.state===dt.PRESSED&&t.executeAction(i.action,e,i.keyboardEvent)}))},t.prototype.getParams=function(t,e){return t?"function"==typeof t?t(this.cesiumService,e):t:{}},t.prototype.executeAction=function(t,e,i){if(this._currentDefinitions){var n=this.getParams(t.params,i);if(o.isNumber(t.action)){var r=yt[t.action];r&&r(this.cesiumService,n,i)}else if("function"==typeof t.action){!1===t.action(this.cesiumService,n,i)&&(this._activeDefinitions[e]={state:dt.IGNORED,action:null,keyboardEvent:null})}}},t.prototype.registerEvents=function(t){var e=this,i=function(){e.document.addEventListener("keydown",e.handleKeydown),e.document.addEventListener("keyup",e.handleKeyup),e.cesiumService.getViewer().clock.onTick.addEventListener(e.handleTick)};t?this.ngZone.runOutsideAngular(i):i()},t.prototype.unregisterEvents=function(){this.document.removeEventListener("keydown",this.handleKeydown),this.document.removeEventListener("keyup",this.handleKeyup),this.cesiumService.getViewer().clock.onTick.removeEventListener(this.handleTick)},t}();ft.decorators=[{type:e.Injectable}],ft.ctorParameters=function(){return[{type:e.NgZone},{type:f},{type:void 0,decorators:[{type:e.Inject,args:[i.DOCUMENT]}]}]};var mt=function(){function t(t,e){this.event=t,this.modifier=e}return t.prototype.init=function(t){var e=this;return this.observer=s.Observable.create((function(i){t.setInputAction((function(t){t.position&&(t.startPosition=t.position,t.endPosition=t.position),i.next(t)}),e.event,e.modifier)})),this.observer},t}(),vt=function(e){function i(t,i,n){var o=e.call(this,t,i)||this;return o.event=t,o.modifier=i,o.eventFactory=n,o}return z(i,e),i.prototype.init=function(){var e,n;this.event===t.CesiumEvent.LONG_LEFT_PRESS?(e=t.CesiumEvent.LEFT_DOWN,n=t.CesiumEvent.LEFT_UP):this.event===t.CesiumEvent.LONG_RIGHT_PRESS?(e=t.CesiumEvent.RIGHT_DOWN,n=t.CesiumEvent.RIGHT_UP):this.event===t.CesiumEvent.LONG_MIDDLE_PRESS&&(e=t.CesiumEvent.MIDDLE_DOWN,n=t.CesiumEvent.MIDDLE_UP);var o=null,a=this.eventFactory.get(e,this.modifier).pipe(r.tap((function(t){return o=t.endPosition}))),c=this.eventFactory.get(t.CesiumEvent.MOUSE_MOVE).pipe(r.filter((function(t){return Math.abs(t.endPosition.x-o.x)>i.LONG_PRESS_EVENTS_MIN_DISTANCE_PX||Math.abs(t.endPosition.y-o.y)>i.LONG_PRESS_EVENTS_MIN_DISTANCE_PX}))),p=s.merge(this.eventFactory.get(n,this.modifier),c);return r.publish()(a.pipe(r.mergeMap((function(t){return s.of(t).pipe(r.delay(i.LONG_PRESS_EVENTS_DURATION),r.takeUntil(p))}))))},i}(mt);vt.LONG_PRESS_EVENTS_DURATION=250,vt.LONG_PRESS_EVENTS_MIN_DISTANCE_PX=10;var Et=function(){function t(t){this.cesiumService=t,this.cesiumEventsObservables=new Map}return t.getEventFullName=function(t,e){return e?t+"_"+e:t.toString()},t.prototype.init=function(){this.eventsHandler=this.cesiumService.getViewer().screenSpaceEventHandler},t.prototype.get=function(e,i){var n=t.getEventFullName(e,i);if(this.cesiumEventsObservables.has(n))return this.cesiumEventsObservables.get(n);var o=this.createCesiumEventObservable(e,i);return this.cesiumEventsObservables.set(n,o),o},t.prototype.createCesiumEventObservable=function(e,i){var n;return(n=t.longPressEvents.has(e)?this.createSpecialCesiumEventObservable(e,i):r.publish()(new mt(e,i).init(this.eventsHandler))).connect(),n},t.prototype.createSpecialCesiumEventObservable=function(t,e){return new vt(t,e,this).init()},t}();Et.longPressEvents=new Set([t.CesiumEvent.LONG_LEFT_PRESS,t.CesiumEvent.LONG_RIGHT_PRESS,t.CesiumEvent.LONG_MIDDLE_PRESS]),Et.decorators=[{type:e.Injectable}],Et.ctorParameters=function(){return[{type:f}]};var Pt=function(){function t(){this._entitesToPlonter=[],this._plonterChangeNotifier=new e.EventEmitter,this._plonterObserver=new s.Subject}return Object.defineProperty(t.prototype,"plonterChangeNotifier",{get:function(){return this._plonterChangeNotifier},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"plonterShown",{get:function(){return this._plonterShown},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"entitesToPlonter",{get:function(){return this._entitesToPlonter},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"plonterClickPosition",{get:function(){return this._eventResult.movement},enumerable:!1,configurable:!0}),t.prototype.plonterIt=function(t){return this._eventResult=t,this._entitesToPlonter=t.entities,this._plonterShown=!0,this._plonterChangeNotifier.emit(),this._plonterObserver},t.prototype.resolvePlonter=function(t){this._plonterShown=!1,this._eventResult.entities=[t],this._plonterChangeNotifier.emit(),this._plonterObserver.next(this._eventResult)},t}();Pt.decorators=[{type:e.Injectable}],Pt.ctorParameters=function(){return[]};var bt=function(t){return t.reduce((function(t,e){return t.indexOf(e)<0&&t.push(e),t}),[])},Ct=function(){function e(){}return e.getDragEventTypes=function(e){var i,n;return e===t.CesiumEvent.LEFT_CLICK_DRAG?(i=t.CesiumEvent.LEFT_DOWN,n=t.CesiumEvent.LEFT_UP):e===t.CesiumEvent.RIGHT_CLICK_DRAG?(i=t.CesiumEvent.RIGHT_DOWN,n=t.CesiumEvent.RIGHT_UP):e===t.CesiumEvent.MIDDLE_CLICK_DRAG&&(i=t.CesiumEvent.MIDDLE_DOWN,n=t.CesiumEvent.MIDDLE_UP),{mouseDownEvent:i,mouseUpEvent:n}},e}();Ct.dragEvents=new Set([t.CesiumEvent.LEFT_CLICK_DRAG,t.CesiumEvent.RIGHT_CLICK_DRAG,t.CesiumEvent.MIDDLE_CLICK_DRAG]);var _t=function(t,e,i,n){this.observable=t,this.stopper=e,this.priority=i,this.isPaused=n},Mt=function(){function e(t,e,i){this.cesiumService=t,this.eventBuilder=e,this.plonterService=i,this.eventRegistrations=new Map}return e.prototype.init=function(){this.eventBuilder.init(),this.scene=this.cesiumService.getScene()},e.prototype.register=function(e){var i=this;if(void 0===this.scene)throw new Error("CesiumService has not been initialized yet - MapEventsManagerService must be injected under ac-map");if(e.pick=e.pick||t.PickOptions.NO_PICK,e.priority=e.priority||0,e.pickConfig=e.pickConfig||{},e.entityType&&e.pick===t.PickOptions.NO_PICK)throw new Error("MapEventsManagerService: can't register an event with entityType and PickOptions.NO_PICK - It doesn't make sense ");var n=Et.getEventFullName(e.event,e.modifier);this.eventRegistrations.has(n)||this.eventRegistrations.set(n,[]);var o=this.createEventRegistration(e),r=o.observable;return r.dispose=function(){return i.disposeObservable(o,n)},this.eventRegistrations.get(n).push(o),this.sortRegistrationsByPriority(n),r},e.prototype.disposeObservable=function(t,e){t.stopper.next(1);var i=this.eventRegistrations.get(e),n=i.indexOf(t);-1!==n&&i.splice(n,1),this.sortRegistrationsByPriority(e)},e.prototype.sortRegistrationsByPriority=function(t){var e=this.eventRegistrations.get(t);if(e.sort((function(t,e){return e.priority-t.priority})),0!==e.length){var i=e[0].priority;e.forEach((function(t){t.isPaused=t.priority<i}))}},e.prototype.createEventRegistration=function(t){var e,i=this,n=t.event,o=t.modifier,a=t.entityType,c=t.pick,p=t.priority,l=t.pickFilter,d=t.pickConfig,u=this.eventBuilder.get(n,o),h=new s.Subject,g=new _t(void 0,h,p,!1);return e=Ct.dragEvents.has(n)?this.createDragEvent({event:n,modifier:o,entityType:a,pick:c,priority:p,pickFilter:l,pickConfig:d}).pipe(r.takeUntil(h)):u.pipe(r.filter((function(){return!g.isPaused})),r.map((function(t){return i.triggerPick(t,c,d)})),r.filter((function(t){return null!==t.cesiumEntities||void 0===a})),r.map((function(t){return i.addEntities(t,a,c,l)})),r.filter((function(t){return null!==t.entities||void 0===a&&!l})),r.switchMap((function(t){return i.plonter(t,c)})),r.takeUntil(h)),g.observable=e,g},e.prototype.createDragEvent=function(e){var i=e.event,n=e.modifier,o=e.entityType,a=e.pick,c=e.priority,p=e.pickFilter,l=e.pickConfig,d=Ct.getDragEventTypes(i),u=d.mouseDownEvent,h=d.mouseUpEvent,g=this.eventBuilder.get(h),y=this.eventBuilder.get(t.CesiumEvent.MOUSE_MOVE),f=this.createEventRegistration({event:u,modifier:n,entityType:o,pick:a,priority:c,pickFilter:p,pickConfig:l}),m=new s.Subject,v=f.observable.pipe(r.mergeMap((function(t){var e=null,i=t.movement.startPosition.x,n=t.movement.startPosition.y;return y.pipe(r.map((function(o){return e={movement:{drop:!1,startPosition:{x:i,y:n},endPosition:o.endPosition},entities:t.entities,cesiumEntities:t.cesiumEntities}})),r.takeUntil(g),r.tap({complete:function(){if(e){var t=Object.assign({},e);t.movement.drop=!0,m.next(t)}}}))})));return s.merge(v,m)},e.prototype.triggerPick=function(e,i,n){var o=[];switch(i){case t.PickOptions.PICK_ONE:case t.PickOptions.PICK_ALL:o=0===(o=this.scene.drillPick(e.endPosition,n.drillPickLimit,n.pickWidth,n.pickHeight)).length?null:o;break;case t.PickOptions.PICK_FIRST:var r=this.scene.pick(e.endPosition,n.pickWidth,n.pickHeight);o=void 0===r?null:[r];break;case t.PickOptions.NO_PICK:}return o&&(o=o.map((function(t){return t.id&&t.id instanceof Cesium.Entity?t.id:t.primitive}))),{movement:e,cesiumEntities:o}},e.prototype.addEntities=function(e,i,n,o){if(null===e.cesiumEntities)return e.entities=null,e;var r=[];return n!==t.PickOptions.NO_PICK&&(r=i?e.cesiumEntities.map((function(t){return t.acEntity})).filter((function(t){return t&&t instanceof i})):e.cesiumEntities.map((function(t){return t.acEntity})),r=bt(r),0===(r=o&&r?r.filter(o):r).length&&(r=null)),e.entities=r,e},e.prototype.plonter=function(e,i){return i===t.PickOptions.PICK_ONE&&null!==e.entities&&e.entities.length>1?this.plonterService.plonterIt(e):s.of(e)},e}();Mt.decorators=[{type:e.Injectable}],Mt.ctorParameters=function(){return[{type:f},{type:Et},{type:Pt}]};var St=function(){function t(t){this.cesiumService=t,this.layersDataSources=[]}return t.prototype.registerLayerDataSources=function(t,e){var i=this;t.forEach((function(t){t.zIndex=e,i.layersDataSources.push(t)}))},t.prototype.drawAllLayers=function(){var t=this;this.layersDataSources.sort((function(t,e){return t.zIndex-e.zIndex})),this.layersDataSources.forEach((function(e){t.cesiumService.getViewer().dataSources.add(e)}))},t.prototype.updateAndRefresh=function(t,e){var i=this;t&&t.length&&(t.forEach((function(t){var n=i.layersDataSources.indexOf(t);-1!==n&&(i.layersDataSources[n].zIndex=e)})),this.cesiumService.getViewer().dataSources.removeAll(),this.drawAllLayers())},t.prototype.removeDataSources=function(t){var e=this;t.forEach((function(t){var i=e.layersDataSources.indexOf(t);-1!==i