cesium-pocket 0.1.16-alpha → 0.1.27-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";const t=require("cesium"),a={STOPED:Symbol("STOPED"),DRAWABLE:Symbol("DRAWABLE"),EDITING:Symbol("EDITING"),DRAGABLE:Symbol("DRAGABLE"),DRAGING:Symbol("DRAGING"),DONE:Symbol("DONE")};class f{constructor(e){this.status=a.STOPED,this.cesiumDom=e}startStatus(){this.status=a.DRAWABLE,this.cesiumDom.style.cursor="crosshair"}editStatus(){this.status=a.EDITING,this.cesiumDom.style.cursor="default"}dragStatus(){this.status=a.DRAGABLE,this.cesiumDom.style.cursor="default"}dragingStatus(){this.status=a.DRAGING,this.cesiumDom.style.cursor="grabbing"}doneStatus(){this.status=a.DONE,this.cesiumDom.style.cursor="default"}stopStatus(){this.status=a.STOPED,this.cesiumDom.style.cursor="default"}getStatus(){return this.status}}const m="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAQAElEQVR4AexdfYwkR3V/r3dnb884wUd03O1HTrZj4p09/CFMSBwpkqX8Ayjkj6ALQY6ixHIc8REJRUoiJUK+80eI7QQH28IOR+xIxOGwyCVRIHEE2JgD6cAfCPt2d9b4ZMt3O7uAfUYceG9ndrp4r6d1N7eeme7prq7q6np7VdvdVa/e+73f699M983OTADyIwwIAwMZEIEMpEYmhAEAEYicBcLAEAZEIEPIkSlhQAQi54AwMISBAgUyJKpMCQOOMCACcaRQAtMOAyIQO7xLVEcYEIE4UiiBaYcBEYgd3iWqIwy4KRBHyBWY7jMgAnG/hpJBgQyIQAokV1y7z4AIxP0aSgYFMiACKZBcce0+AyKQLTWUQ2GglwERSC8bsi8MbGFABLKFEDkUBnoZEIH0siH7wsAWBkQgWwiRQ2GglwERSC8bxe6LdwcZEIE4WDSBbI4BEYgBrmfV7PbZjcuvnNqY+73pdv2vplv1g1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.pointsCollection=new t.EntityCollection,this.currentDragPoint=null,this.mainData=[],this.textDom=null,this.point_L_ClickEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(n=>{let o=this.viewer.camera.getPickRay(n.position),r=this.viewer.scene.globe.pick(o,this.viewer.scene);t.defined(r)&&a.DRAWABLE==super.getStatus()&&this.createBillboard(r)},t.ScreenSpaceEventType.LEFT_CLICK)},this.point_L_MIDDLE_ClickEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(()=>{a.DRAGABLE==super.getStatus()&&this.currentDragPoint&&(this.viewer.scene.screenSpaceCameraController.enableRotate=!1,confirm("确定要删除吗?")?(this.viewer.entities.remove(this.currentDragPoint),this.pointsCollection.remove(this.currentDragPoint),this.pointsBackEdit(),this.setMainData(),this.viewer.scene.screenSpaceCameraController.enableRotate=!0):(this.pointsBackEdit(),this.viewer.scene.screenSpaceCameraController.enableRotate=!0))},t.ScreenSpaceEventType.MIDDLE_CLICK)},this.point_R_ClickEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(()=>{a.DRAWABLE==super.getStatus()?(super.editStatus(),this.setMainData()):a.EDITING==super.getStatus()?super.doneStatus():a.DRAGABLE==super.getStatus()?super.doneStatus():a.DONE==super.getStatus()&&(super.stopStatus(),this.pointsReset())},t.ScreenSpaceEventType.RIGHT_CLICK)},this.point_L_DownEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(()=>{a.DRAGABLE==super.getStatus()&&(super.dragingStatus(),this.viewer.scene.screenSpaceCameraController.enableRotate=!1)},t.ScreenSpaceEventType.LEFT_DOWN)},this.point_L_UpEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(()=>{a.DRAGING==super.getStatus()&&(this.pointsBackEdit(),this.viewer.scene.screenSpaceCameraController.enableRotate=!0)},t.ScreenSpaceEventType.LEFT_UP)},this.point_moveEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(n=>{const o=this.viewer.camera.getPickRay(n.endPosition);if(o){const r=this.viewer.scene.globe.pick(o,this.viewer.scene);t.defined(r)&&(a.DRAWABLE==super.getStatus()?this.showPosition(n.endPosition):a.EDITING==super.getStatus()?(this.textDom&&this.viewer.container.removeChild(this.textDom),this.pickPoint(n.endPosition)):a.DRAGABLE==super.getStatus()?this.pointsBackEdit():a.DRAGING==super.getStatus()&&this.currentDragPoint&&(this.currentDragPoint.position=new t.CallbackPositionProperty(()=>r,!1)))}},t.ScreenSpaceEventType.MOUSE_MOVE)},this.pickPoint=i=>{let n=this.viewer.scene.pick(i);n&&n.id&&n.id.properties.getValue().entityType=="POINT"&&(n.id.point.color=t.Color.YELLOW,super.dragStatus(),this.currentDragPoint=n.id)},this.viewer=e,this.viewer.entities.add(this.pointsCollection),this.textDom=document.createElement("div"),this.textDom.style.position="absolute",this.textDom.style.zIndex=" 10",this.textDom.style.color="white",this.textDom.style.backgroundColor="black",this.textDom.style.padding="2px 6px",this.viewer.container.appendChild(this.textDom)}start(){super.startStatus(),this.handler||(this.handler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.point_L_ClickEvent(),this.point_L_MIDDLE_ClickEvent(),this.point_R_ClickEvent(),this.point_L_DownEvent(),this.point_L_UpEvent(),this.point_moveEvent()}getEntityCollection(){return this.pointsCollection}getAllPositionsData(){return this.mainData}pointsBackEdit(){this.currentDragPoint&&(this.currentDragPoint.point.color=t.Color.TRANSPARENT,this.currentDragPoint=null,super.editStatus())}pointsReset(){for(let e=0,s=this.pointsCollection.values.length;e<s;e++){const i=this.pointsCollection.values[e];this.viewer.entities.removeById(i.id)}this.pointsCollection.removeAll(),this.viewer.entities.removeById(this.pointsCollection.id)}showPosition(e){const s=this.viewer.camera.getPickRay(e);if(this.textDom&&s){const i=this.viewer.scene.globe.pick(s,this.viewer.scene),n=t.Cartographic.fromCartesian(i),o=t.Math.toDegrees(n.longitude),r=t.Math.toDegrees(n.latitude);this.textDom.style.left=e.x+4+"px",this.textDom.style.top=e.y-30+"px",this.textDom.innerText=`${o.toFixed(4)}, ${r.toFixed(4)}`}}createBillboard(e){const s=t.Cartographic.fromCartesian(e),i=t.Math.toDegrees(s.longitude),n=t.Math.toDegrees(s.latitude),o=this.viewer.entities.add({position:e,label:{text:`${i.toFixed(4)}, ${n.toFixed(4)}`,font:"500 14px Helvetica",style:t.LabelStyle.FILL,fillColor:t.Color.WHITE,pixelOffset:new t.Cartesian2(80,-20),showBackground:!0,backgroundColor:new t.Color(0,0,0,.6)},billboard:{image:m,width:40,height:40,scale:1,verticalOrigin:t.VerticalOrigin.BOTTOM},properties:{entityType:"POINT"},show:!0});o&&(this.mainData.push(e),this.pointsCollection.add(o))}createPoint(e){const s=this.viewer.entities.add({position:e,point:{pixelSize:6,color:t.Color.TRANSPARENT,outlineColor:t.Color.YELLOW,outlineWidth:2,heightReference:t.HeightReference.CLAMP_TO_GROUND},properties:{entityType:"POINT"},show:!0});s&&(this.mainData.push(e),this.pointsCollection.add(s))}setMainData(){this.mainData=[],this.pointsCollection.values.forEach(e=>{var s;if(e.point){const i=new t.Cartesian3;(s=e.position)==null||s.getValue(t.JulianDate.now(),i),this.mainData.push(i)}})}}const v=(l,e)=>{const s=t.Cartographic.fromCartesian(l),i=t.Cartographic.fromCartesian(e);return new t.EllipsoidGeodesic(s,i).surfaceDistance},w=(l,e)=>{const s=new t.Cartesian3;return t.Cartesian3.add(l,e,s),t.Cartesian3.divideByScalar(s,2,s),s},p=(l,e,s,i=null)=>{let o={...{text:s,font:"16px sans-serif",fillColor:t.Color.ORANGE,showBackground:!0,backgroundColor:t.Color.BLACK,style:t.LabelStyle.FILL_AND_OUTLINE},...i},r={position:e,label:o};return l.entities.add(r)},d=l=>{let e="";return l>1e3?e=(l/1e3).toFixed(2)+" 公里":e=l.toFixed(2)+" 米",e},I=l=>{let e="";return l>1e3*1e3*1e4?e=(l/(1e3*1e3*1e4)).toFixed(2)+" 万平方公里":l>1e3*1e3?e=(l/(1e3*1e3)).toFixed(2)+" 平方公里":e=l.toFixed(2)+" 平方米",e},S=l=>{if(!l||l.length===0)return null;let e=0,s=0,i=0;const n=l.length;return l.forEach(r=>{e+=r.x,s+=r.y,i+=r.z}),new t.Cartesian3(e/n,s/n,i/n)},L=l=>{if(l.length<3)return 0;const s=t.BoundingSphere.fromPoints(l).center,i=t.Transforms.eastNorthUpToFixedFrame(s),n=t.Matrix4.inverse(i,new t.Matrix4),o=l.map(h=>t.Matrix4.multiplyByPoint(n,h,new t.Cartesian3));let r=0;for(let h=0;h<o.length;h++){const c=(h+1)%o.length;r+=o[h].x*o[c].y,r-=o[c].x*o[h].y}return Math.abs(r)/2};class g extends A{constructor(e,s){super(e,s),this.mainLineEntity=null,this.dashLineEntity=null,this.dashEndData=new t.Cartesian3,this.currentIndex=-1,this.labelsCollection=new t.EntityCollection,this.line_L_ClickEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(n=>{let o=this.viewer.camera.getPickRay(n.position),r=this.viewer.scene.globe.pick(o,this.viewer.scene);t.defined(r)&&a.DRAWABLE==super.getStatus()&&(super.createPoint(r),this.mainData.length>0&&(this.mainLineEntity||this.createMainLine(),this.dashLineEntity||this.createDashLine()))},t.ScreenSpaceEventType.LEFT_CLICK)},this.line_R_ClickEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(()=>{a.DRAWABLE==super.getStatus()?(super.editStatus(),this.dashLineEntity&&(this.dashLineEntity.show=!1),this.pointsCollection.show=!0):a.EDITING==super.getStatus()?(super.doneStatus(),this.showDistance(),this.pointsCollection.show=!1):a.DRAGABLE==super.getStatus()?(super.doneStatus(),this.showDistance(),this.pointsCollection.show=!1):a.DONE==super.getStatus()&&(super.stopStatus(),this.pointsReset(),this.lineReset())},t.ScreenSpaceEventType.RIGHT_CLICK)},this.line_L_DownEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(()=>{a.DRAGABLE==super.getStatus()&&(super.dragingStatus(),this.getEntityIndex(),this.viewer.scene.screenSpaceCameraController.enableRotate=!1)},t.ScreenSpaceEventType.LEFT_DOWN)},this.line_moveEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(n=>{const o=this.viewer.camera.getPickRay(n.endPosition);if(o){const r=this.viewer.scene.globe.pick(o,this.viewer.scene);t.defined(r)&&(a.DRAWABLE==super.getStatus()?this.mainData.length>0&&(this.dashEndData=r):a.EDITING==super.getStatus()?this.pickPoint(n.endPosition):a.DRAGABLE==super.getStatus()?(this.pointsBackEdit(),this.currentIndex=-1):a.DRAGING==super.getStatus()&&this.moveLine(r))}},t.ScreenSpaceEventType.MOUSE_MOVE)},this.createMainLine=()=>{this.mainLineEntity=this.viewer.entities.add({polyline:{positions:new t.CallbackProperty(()=>this.mainData,!1),width:2,material:t.Color.RED,show:!0,clampToGround:!0},properties:{entityType:"LINE"}})}}start(){super.start(),this.viewer.entities.add(this.labelsCollection),this.pointsCollection.show=!1,this.line_L_ClickEvent(),this.line_R_ClickEvent(),this.line_L_DownEvent(),this.line_moveEvent()}moveLine(e){this.currentDragPoint&&(this.currentDragPoint.position=new t.CallbackPositionProperty(()=>e,!1),this.currentIndex>-1&&(this.mainData[this.currentIndex]=e))}getEntityIndex(){for(let e=0,s=this.pointsCollection.values.length;e<s;e++)if(this.pointsCollection.values[e].id==this.currentDragPoint.id){this.currentIndex=e;break}}createDashLine(){this.dashLineEntity=this.viewer.entities.add({polyline:{positions:new t.CallbackProperty(()=>{const e=this.mainData.length;let s=this.mainData[e-1];return this.dashEndData.x==0&&this.dashEndData.y==0&&this.dashEndData.z==0&&(this.dashEndData=s),[s,this.dashEndData]},!1),width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.RED,dashLength:15}),show:!0,clampToGround:!0},properties:{entityType:"DASHLINE"}})}lineReset(){this.labelsCollection.show=!1,this.mainLineEntity&&this.viewer.entities.remove(this.mainLineEntity),this.dashLineEntity&&this.viewer.entities.remove(this.dashLineEntity),this.mainLineEntity=null,this.dashLineEntity=null,console.log(this.viewer.entities);for(let e=0,s=this.labelsCollection.values.length;e<s;e++){const i=this.labelsCollection.values[e];this.viewer.entities.removeById(i.id)}this.labelsCollection.removeAll(),this.viewer.entities.removeById(this.labelsCollection.id)}showDistance(){let e=0,s=this.mainData.length;for(let h=1;h<s;h++){const c=this.mainData[h-1],u=this.mainData[h],D=w(c,u),E=v(c,u);e+=E;let C=d(E),y=p(this.viewer,D,C);this.labelsCollection.add(y)}let i={font:"20px",fillColor:t.Color.WHITE,outlineWidth:0},n=this.mainData[s-1],o="共: "+d(e),r=p(this.viewer,n,o,i);this.labelsCollection.add(r)}}class R extends g{constructor(e,s){super(e,s),this.polygonEntity=null,this.areaText=null,this.polygon_L_ClickEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(n=>{let o=this.viewer.camera.getPickRay(n.position),r=this.viewer.scene.globe.pick(o,this.viewer.scene);t.defined(r)&&a.DRAWABLE==super.getStatus()&&(super.createPoint(r),this.mainData.length>0&&(this.mainLineEntity||this.createMainLine(),this.dashLineEntity||this.createDashLine(),!this.polygonEntity&&this.mainData.length>2&&this.createPolygon()))},t.ScreenSpaceEventType.LEFT_CLICK)},this.polygon_R_ClickEvent=()=>{var i;(i=this.handler)==null||i.setInputAction(()=>{a.DRAWABLE==super.getStatus()?(super.editStatus(),this.dashLineEntity&&(this.dashLineEntity.show=!1),this.pointsCollection.show=!0):a.EDITING==super.getStatus()?(super.doneStatus(),this.showArea(),this.pointsCollection.show=!1):a.DRAGABLE==super.getStatus()?(super.doneStatus(),this.showArea(),this.pointsCollection.show=!1):a.DONE==super.getStatus()&&(super.stopStatus(),this.pointsReset(),this.lineReset(),this.polygonReset())},t.ScreenSpaceEventType.RIGHT_CLICK)},this.createPolygon=()=>{this.polygonEntity=this.viewer.entities.add({polygon:{hierarchy:new t.CallbackProperty(()=>new t.PolygonHierarchy(this.mainData),!1),material:t.Color.RED.withAlpha(.4),outline:!1},properties:{entityType:"POLYGON"}}),console.log(this.polygonEntity)}}start(){super.start(),this.polygon_L_ClickEvent(),this.polygon_R_ClickEvent()}showArea(){let e=S(this.mainData);if(e){let s=L(this.mainData);const i=I(s);this.areaText=p(this.viewer,e,i)}}polygonReset(){this.polygonEntity&&this.viewer.entities.remove(this.polygonEntity),this.areaText&&this.viewer.entities.remove(this.areaText)}}exports.LineDrawer=g;exports.PointDrawer=A;exports.PolygonDrawer=R;
@@ -0,0 +1 @@
1
+ "use strict";const o=require("cesium"),d={DEFAULT:Symbol("default"),TEXT:Symbol("text"),ICON:Symbol("icon")},m={HOSPITAL:{name:"hospital",color:o.Color.RED},SCHOOL:{name:"school-JP",color:o.Color.BLUE},LIBRARY:{name:"library",color:o.Color.BLUE},BANK:{name:"bank-JP",color:o.Color.BLUE},AIRPORT:{name:"airport",color:o.Color.BLUE},FIRE_STATION:{name:"fire-station",color:o.Color.RED},BUS:{name:"airport",color:o.Color.BLUE},GAS_STATION:{name:"charging-station",color:o.Color.BLUE},PARKING:{name:"parking",color:o.Color.BLUE},POLICE:{name:"police",color:o.Color.BLUE},RAIL:{name:"rail",color:o.Color.BLUE},RESTAURANT:{name:"restaurant",color:o.Color.BLUE}},c="cp-pin",E=(i,l,e,n=48)=>{const t=new o.PinBuilder;return Promise.resolve(t.fromMakiIconId(e.name,e.color,n)).then(function(r){return i.entities.add({id:"def"+s(),name:e.name,position:l,billboard:{image:r.toDataURL(),verticalOrigin:o.VerticalOrigin.BOTTOM,disableDepthTestDistance:0},properties:{cpType:c}})}).catch(r=>(console.error("图标获取失败"+r),null))},T=(i,l,e="",n=o.Color.BLUE,t=48)=>{const r=new o.PinBuilder;return i.entities.add({id:"txt"+s(),name:e,position:l,billboard:{image:r.fromText(e,n,t).toDataURL(),verticalOrigin:o.VerticalOrigin.BOTTOM,disableDepthTestDistance:0},properties:{cpType:c}})},p=(i,l,e,n=o.Color.BLUE,t=48)=>{console.log(e),console.log(n),console.log(t);const r=new o.PinBuilder;return Promise.resolve(r.fromUrl(e,n,t)).then(a=>i.entities.add({id:"img"+s(),name:"",position:l,billboard:{image:a.toDataURL(),verticalOrigin:o.VerticalOrigin.BOTTOM,disableDepthTestDistance:0},properties:{cpType:c}})).catch(a=>(console.error("图标获取失败"+a),null))},s=()=>new Date().getTime().toString();exports.CP_TYPE=c;exports.PIN_CATEGORY=m;exports.PIN_MODE=d;exports.addDefault=E;exports.addImg=p;exports.addText=T;