UNPKG

rlayers

Version:

React Components for OpenLayers

1 lines 5.62 kB
"use strict";(self.webpackChunkrlayers=self.webpackChunkrlayers||[]).push([[1991],{1991:(e,t,r)=>{r.r(t),r.d(t,{default:()=>I});var a=r(6540),n=r(6391),l=r(6717),s=r(1217),o=r(8217),c=r(6888);const i=/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/,d=/^H.([A-Z]{3}).*?:(.*)/,u=/^HFDTE(\d{2})(\d{2})(\d{2})/,p=/^HFDTEDATE:(\d{2})(\d{2})(\d{2}),(\d{2})/,m=/\r\n|\r|\n/;class h extends c.A{constructor(e){super(),e=e||{},this.dataProjection=(0,n.Jt)("EPSG:4326"),this.altitudeMode_=e.altitudeMode?e.altitudeMode:"none",this.lad_=!1,this.lod_=!1,this.ladStart_=0,this.ladStop_=0,this.lodStart_=0,this.lodStop_=0}readFeatureFromText(e,t){const r=this.altitudeMode_,a=e.split(m),n={},c=[];let h,f,g=2e3,S=0,E=1,b=-1;for(h=0,f=a.length;h<f;++h){const e=a[h];let t;if("B"==e.charAt(0)){if(t=i.exec(e),t){const a=parseInt(t[1],10),n=parseInt(t[2],10),l=parseInt(t[3],10);let s=parseInt(t[4],10)+parseInt(t[5],10)/6e4;this.lad_&&(s+=parseInt(e.slice(this.ladStart_,this.ladStop_),10)/6e4/10**(this.ladStop_-this.ladStart_)),"S"==t[6]&&(s=-s);let o=parseInt(t[7],10)+parseInt(t[8],10)/6e4;if(this.lod_&&(o+=parseInt(e.slice(this.lodStart_,this.lodStop_),10)/6e4/10**(this.lodStop_-this.lodStart_)),"W"==t[9]&&(o=-o),c.push(o,s),"none"!=r){let e;e="gps"==r?parseInt(t[11],10):"barometric"==r?parseInt(t[12],10):0,c.push(e)}let i=Date.UTC(g,S,E,a,n,l);i<b&&(i=Date.UTC(g,S,E+1,a,n,l)),c.push(i/1e3),b=i}}else if("H"==e.charAt(0))t=p.exec(e),t?(E=parseInt(t[1],10),S=parseInt(t[2],10)-1,g=2e3+parseInt(t[3],10)):(t=u.exec(e),t?(E=parseInt(t[1],10),S=parseInt(t[2],10)-1,g=2e3+parseInt(t[3],10)):(t=d.exec(e),t&&(n[t[1]]=t[2].trim())));else if("I"==e.charAt(0)){const t=parseInt(e.slice(1,3),10);for(let r=0;r<t;r++){const t=e.slice(7+7*r,10+7*r);if("LAD"===t||"LOD"===t){const a=parseInt(e.slice(3+7*r,5+7*r),10)-1,n=parseInt(e.slice(5+7*r,7+7*r),10);"LAD"===t?(this.lad_=!0,this.ladStart_=a,this.ladStop_=n):"LOD"===t&&(this.lod_=!0,this.lodStart_=a,this.lodStop_=n)}}}}if(0===c.length)return null;const C="none"==r?"XYM":"XYZM",y=new s.A(c,C),I=new l.A((0,o.hX)(y,!1,t));return I.setProperties(n,!0),I}readFeaturesFromText(e,t){const r=this.readFeatureFromText(e,t);return r?[r]:[]}}const f=h;var g=r(7331),S=r(4294),E=r(7240),b=r(5111);r(5045);const C=[{c:"rgba(0, 0, 250, 0.7)",i:r.p+"35f98571579c799828e73f3e7cfc5634.igc"},{c:"rgba(0, 50, 200, 0.7)",i:r.p+"08d341a63428255a9f42d1dad7e19df5.igc"},{c:"rgba(0, 100, 150, 0.7)",i:r.p+"6634c672e2855bfb2def3ad33d01b0e4.igc"},{c:"rgba(0, 150, 200, 0.7)",i:r.p+"dbecb26a49a66da3c0a27ee0ad994925.igc"},{c:"rgba(0, 200, 50, 0.7)",i:r.p+"5f9b60a43fcd910126e0dff92120e4d7.igc"}],y=(0,n.Rb)([6,45.7]);function I(){const[e,t]=a.useState(""),[r,n]=a.useState(null),[l,o]=a.useState(null),[c,i]=a.useState(0),[d,u]=a.useState([]),[p,m]=a.useState({start:1/0,stop:-1/0,duration:0}),[h,I]=a.useState((()=>(Promise.all(C.map((e=>fetch(e.i).then((e=>e.text()))))).then((e=>I(e))),[]))),_={redCircle:(0,b.useRStyle)(),blueCircle:(0,b.useRStyle)(),flightPath:a.useRef([])},x=a.useRef(null),w=a.useRef(null);return a.createElement(a.Fragment,null,a.useMemo((()=>C.map(((e,t)=>a.createElement(b.RStyle,{key:t,ref:e=>{_.flightPath.current[t]=e}},a.createElement(b.RStroke,{color:e.c,width:3}))))),[_.flightPath]),a.createElement(b.RStyle,{ref:_.redCircle},a.createElement(b.RStroke,{color:"red",width:1}),a.createElement(b.RCircle,{radius:6},a.createElement(b.RFill,{color:"red"}))),a.createElement(b.RStyle,{ref:_.blueCircle},a.createElement(b.RCircle,{radius:6},a.createElement(b.RFill,{color:"blue"}))),a.createElement(E.f9,{className:"example-map",initial:{center:y,zoom:9},onPointerMove:(0,a.useCallback)((e=>{const r=x.current.source.getClosestFeatureToCoordinate(e.coordinate);if(null===r)return;const a=r.getGeometry().getClosestPoint(e.coordinate),l=new Date(1e3*a[2]);n(new S.A(a)),o(new s.A([e.coordinate,[a[0],a[1]]])),t("<strong>"+r.get("PLT")+"</strong><br><em>"+l.toUTCString()+"</em>"),e.map.render()}),[x])},a.createElement(E.HS,{zIndex:5,url:"https://{a-c}.tile.opentopomap.org/{z}/{x}/{y}.png",attributions:"Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)"}),a.createElement(E.j9,{zIndex:10,ref:x,onAddFeature:(0,a.useCallback)((e=>{const t=e.feature.getGeometry();p.start=Math.min(p.start,t.getFirstCoordinate()[2]),p.stop=Math.max(p.stop,t.getLastCoordinate()[2]),p.duration=p.stop-p.start,m({...p})}),[p]),onPostRender:(0,a.useCallback)((e=>{const t=(0,g.r2)(e);t.setStyle(b.RStyle.getStyleStatic(_.redCircle)),r&&l&&(t.drawGeometry(r),t.drawGeometry(l))}),[r,l,_.redCircle])},a.useMemo((()=>a.createElement(a.Fragment,null,h.map(((e,t)=>a.createElement(E.Dp,{key:t,feature:(new f).readFeatures(e,{featureProjection:"EPSG:3857"})[0],style:_.flightPath.current[t]}))))),[h,_.flightPath,_.flightPath.current[0]])),a.createElement(E.j9,{zIndex:10,ref:w,style:_.blueCircle},a.useMemo((()=>a.createElement(a.Fragment,null,d.map(((e,t)=>a.createElement(E.Dp,{key:t,geometry:new S.A(e)}))))),[d]))),a.createElement("div",{className:"d-flex flex-row mb-3 align-items-center"},a.createElement("div",{className:"jumbotron py-1 px-3 m-0 me-3 w-50",dangerouslySetInnerHTML:{__html:e}}),a.createElement("div",{className:"w-50"},a.createElement("input",{type:"range",className:"range-slider range-slider--primary w-100",min:"0",max:"100",value:c,onChange:(0,a.useCallback)((e=>{const t=parseInt(e.currentTarget.value);i(t);const r=x.current.source,a=p.start+p.duration*t/100,n=[];r.forEachFeature((e=>{if(!e.get("PLT"))return;const t=e.getGeometry().getCoordinateAtM(a,!0);n.push(t)})),u(n)}),[x,p])}))))}}}]);