!function(t){var e={};function o(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=t,o.c=e,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(i,n,function(e){return t[e]}.bind(null,n));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=5)}([function(t){t.exports=JSON.parse('{"exception":{"impl":"The implementation used cannot create Perfiltopografico controls."},"tooltip":"Topography Profile","title":"Topography Profile","profil":{"title":"Topographic Profile","zmin":"Min Alt.","zmax":"Max Alt.","altitude":"Alt.","distance":"Full Distance","ytitle":"Altitude (m)","xtitle":"Distance (km)"}}')},function(t){t.exports=JSON.parse('{"exception":{"impl":"La implementación no puede crear controles de Perfiltopografico."},"tooltip":"Perfil Topográfico","title":"Perfil Topográfico","profil":{"title":"Perfil Topográfico","zmin":"Alt. min","zmax":"Alt. max","altitude":"Altitud","distance":"Dist. total","ytitle":"Altitud (m)","xtitle":"Distancia (km)"}}')},function(t,e){t.exports='
\r\n \r\n
'},function(t){t.exports=JSON.parse('{"url":{"name":"topographicprofile","separator":"*"},"constructor":"M.plugin.Topographicprofile","parameters":[{"type":"object","properties":[{"type":"simple","name":"position","possibleValues":["TL","TR","BL","BR"],"position":0}]}],"files":{"ol":{"scripts":["topographicprofile.ol.min.js"],"styles":["topographicprofile.ol.min.css"]}},"metadata":{"name":"Perfil Topográfico","description":"Genera un perfil longitudinal","text":"A partir de un eje dibujado, el plugin muestra un perfil longitudinal del terreno","version":"1.0.0","date":"Junio, 2020","author":"","org":"Consejería de Hacienda, Industria y Energía. Junta de Andalucía.","tags":"mapea,plugin","icon":"./facade/assets/icons/icons.svg","centralized":true}}')},function(t,e,o){},function(t,e,o){"use strict";o.r(e);o(4);var i,n,r={en:o(0),es:o(1)},a=function(){var t="es";return"function"==typeof M.language.getLang&&(t=M.language.getLang()),t},s=function(t){return r[t]},l=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a(),o=s(e),i="";return M.utils.isNullOrEmpty(o)?console.warn("The translation '".concat(e,"' has not been defined.")):i=t.split(".").reduce((function(t,e){return t[e]}),o),i},c={zmin:"Zmin",zmax:"Zmax",ytitle:"Altitude (m)",xtitle:"Distance (km)",time:"Time",altitude:"Altitude",distance:"Distance",altitudeUnits:"m",distanceUnitsM:"m",distanceUnitsKM:"km"},p=function(t){var e=this,o=t||{};this.info=o.info||c;var i,n=this;if(o.target)(i=document.createElement("div")).classList.add(o.className||"ol-profil");else{(i=document.createElement("div")).className=((o.className||"ol-profil")+" ol-unselectable ol-control ol-collapsed").trim();var r=document.createElement("p");r.textContent=l("profil.title"),i.appendChild(r);var a=document.createElement("button");a.setAttribute("type","button"),a.setAttribute("class","profile-close-button");var s=function(i){t.map.removeControl(e),o.source.clear()};a.addEventListener("click",s),a.addEventListener("touchstart",s),r.appendChild(a)}var p=document.createElement("div");p.classList.add("ol-inner"),i.appendChild(p);var u=document.createElement("div");u.style.position="relative",p.appendChild(u);var f=this.ratio=2;this.canvas_=document.createElement("canvas"),this.canvas_.width=(o.width||300)*f,this.canvas_.height=(o.height||150)*f;var h={msTransform:"scale(0.5,0.5)",msTransformOrigin:"0 0",webkitTransform:"scale(0.5,0.5)",webkitTransformOrigin:"0 0",mozTransform:"scale(0.5,0.5)",mozTransformOrigin:"0 0",transform:"scale(0.5,0.5)",transformOrigin:"0 0"};Object.keys(h).forEach((function(t){t in n.canvas_.style&&(n.canvas_.style[t]=h[t])}));var d=document.createElement("div");u.appendChild(d),d.style.width=this.canvas_.width/f+"px",d.style.height=this.canvas_.height/f+"px",d.appendChild(this.canvas_),d.addEventListener("click",(function(t){n.onMove(t)})),d.addEventListener("mousemove",(function(t){n.onMove(t)})),ol.control.Control.call(this,{element:i,target:o.target}),this.margin_={top:10*f,left:40*f,bottom:30*f,right:10*f},this.info.ytitle||(this.margin_.left-=20*f),this.info.xtitle||(this.margin_.bottom-=20*f),this.bar_=document.createElement("div"),this.bar_.classList.add("ol-profilbar"),this.bar_.style.top=this.margin_.top/f+"px",this.bar_.style.height=(this.canvas_.height-this.margin_.top-this.margin_.bottom)/f+"px",u.appendChild(this.bar_),this.cursor_=document.createElement("div"),this.cursor_.classList.add("ol-profilcursor"),u.appendChild(this.cursor_),this.popup_=document.createElement("div"),this.popup_.classList.add("ol-profilpopup"),this.cursor_.appendChild(this.popup_);var m=document.createElement("table");m.cellPadding="0",m.cellSpacing="0",m.style.clientWidth=this.canvas_.width/f+"px",u.appendChild(m);var y=document.createElement("tr");y.classList.add("track-info"),m.appendChild(y);var _=document.createElement("td");_.innerHTML=(this.info.zmin||"Zmin")+': ',y.appendChild(_);var v=document.createElement("td");v.innerHTML=(this.info.zmax||"Zmax")+': ',y.appendChild(v);var g=document.createElement("td");g.innerHTML=(this.info.distance||"Distance")+': ',y.appendChild(g);var b=document.createElement("tr");b.classList.add("point-info"),m.appendChild(b);var w=document.createElement("td");w.innerHTML=(this.info.altitude||"Altitude")+': ',b.appendChild(w);var M=document.createElement("td");M.innerHTML='Dist. parcial: ',b.appendChild(M);var P=document.createElement("td");P.innerHTML=(this.info.time||"Time")+': ',b.appendChild(P),this.tab_=[],o.feature&&this.setGeometry(o.feature)};i=p,n=ol.control.Control,i.prototype=Object.create(n.prototype),i.prototype.constructor=i,p.prototype.popup=function(t){this.popup_.innerHTML=t},p.prototype.onMove=function(t){if(this.tab_.length){var e=this.canvas_.getBoundingClientRect(),o=e.top+window.pageYOffset-document.documentElement.clientTop,i=e.left+window.pageXOffset-document.documentElement.clientLeft,n=t.pageX-i,r=t.pageY-o,a=this.ratio;if(n>this.margin_.left/a&&n<(this.canvas_.width-this.margin_.right)/a&&r>this.margin_.top/a&&r<(this.canvas_.height-this.margin_.bottom)/a){this.bar_.style.left=n+"px",this.bar_.style.display="block";for(var s,l=(n*a-this.margin_.left)/this.scale_[0],c=this.tab_[0],p=1;s=this.tab_[p];p++)if(s[0]>=l){l<(s[0]+c[0])/2&&(s=c);break}s?(this.cursor_.style.left=n+"px",this.cursor_.style.top=(this.canvas_.height-this.margin_.bottom+s[1]*this.scale_[1]+this.dy_)/a+"px",this.cursor_.style.display="block"):this.cursor_.style.display="none",this.bar_.parentElement.classList.add("over"),this.element.querySelector(".point-info .z").textContent=s[1]+this.info.altitudeUnits,this.element.querySelector(".point-info .dist").textContent=(s[0]/1e3).toFixed(1)+this.info.distanceUnitsKM,this.element.querySelector(".point-info .time").textContent=s[2],n>this.canvas_.width/a/2?this.popup_.classList.add("ol-left"):this.popup_.classList.remove("ol-left"),this.dispatchEvent({type:"over",click:"click"==t.type,coord:s[3],time:s[2],distance:s[0]})}else this.bar_.parentElement.classList.contains("over")&&(this.bar_.style.display="none",this.cursor_.style.display="none",this.bar_.parentElement.classList.remove("over"),this.dispatchEvent({type:"out"}))}},p.prototype.show=function(){this.element.classList.remove("ol-collapsed"),this.dispatchEvent({type:"show",show:!0})},p.prototype.hide=function(){this.element.classList.add("ol-collapsed"),this.dispatchEvent({type:"show",show:!1})},p.prototype.toggle=function(){this.element.classList.toggle("ol-collapsed");var t=this.element.classList.contains("ol-collapsed");this.dispatchEvent({type:"show",show:!t})},p.prototype.isShown=function(){return!this.element.classList.contains("ol-collapsed")},p.prototype.setGeometry=function(t,e){e||(e={}),t instanceof ol.Feature&&(t=t.getGeometry());var o=this.canvas_,i=o.getContext("2d"),n=o.width,r=o.height;if(i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,n,r),/Z/.test(t.getLayout())){/M/.test(t.getLayout())?this.element.querySelector(".time").parentElement.style.display="block":this.element.querySelector(".time").parentElement.style.display="none";var a=t.getCoordinates();switch(t.getType()){case"LineString":break;case"MultiLineString":a=a[0];break;default:return}var s=e.projection||this.getMap().getView().getProjection();i.setTransform(1,0,0,1,this.margin_.left,r-this.margin_.bottom);var l=this.ratio;n-=this.margin_.right+this.margin_.left,r-=this.margin_.top+this.margin_.bottom,i.strokeStyle="#000",i.lineWidth=.5*l,i.beginPath(),i.moveTo(0,0),i.lineTo(0,-r),i.moveTo(0,0),i.lineTo(n,0),i.stroke();var c,p,u,f,h,d,m,y=1/0,_=-1/0,v=this.tab_=[];for(c=0;p=a[c];c++)(f=p[2])_&&(_=f),0==c?u=0:u+=(d=a[c-1],m=p,ol.sphere.getDistance(ol.proj.transform(d,s,"EPSG:4326"),ol.proj.transform(m,s,"EPSG:4326"))),h=C(a[0][3],p[3]),v.push([u,f,h,p]);this.element.querySelector(".track-info .zmin").textContent=y.toFixed(2)+this.info.altitudeUnits,this.element.querySelector(".track-info .zmax").textContent=_.toFixed(2)+this.info.altitudeUnits,this.element.querySelector(".track-info .dist").textContent=u>1e3?(u/1e3).toFixed(1)+this.info.distanceUnitsKM:u.toFixed(1)+this.info.distanceUnitsM;for(var g=e.graduation||100;;){if(!(r/(((_=Math.ceil(_/g)*g)-(y=Math.floor(y/g)*g))/g)<15*l))break;g*=2}"number"==typeof e.zmin&&y>e.zmin&&(y=e.zmin),"number"==typeof e.zmax&&_1e3?(S=100*Math.round(u/1e3))>1e3&&(S=1e3*Math.ceil(S/1e3)):(x="m",S=u>100?10*Math.round(u/100):u>10?Math.round(u/10):u>1?Math.round(u)/10:u),c=0;c<=u;c+=S){var T="m"==x?c:c/1e3;i.fillText(Math.round(10*T)/10,c*w,4*l),i.moveTo(c*w,2*l),i.lineTo(c*w,0)}for(i.font=12*l+"px arial",i.fillText(this.info.xtitle.replace("(km)","("+x+")"),n/2,18*l),i.save(),i.rotate(-Math.PI/2),i.fillText(this.info.ytitle,r/2,-this.margin_.left),i.restore(),i.stroke(),i.strokeStyle="#368",i.lineWidth=3,i.setLineDash([]),i.beginPath(),c=0;p=v[c];c++)0==c?i.moveTo(p[0]*w,p[1]*M+P):i.lineTo(p[0]*w,p[1]*M+P);i.stroke()}function C(t,e){if(!t||!e)return"-";var o=(e-t)/60,i=Math.trunc(o/60),n=Math.trunc(o-60*i);return i+"h"+(n<10?"0":"")+n+"mn"}},p.prototype.getImage=function(t,e){return"canvas"===t?this.canvas_:this.canvas_.toDataURL(t,e)};var u=p;function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){for(var o=0;othis.distancePoinst_?l/this.distancePoinst_:this.distancePoinst_,p=0;p<=l/c;p++){s>=0&&s<=90?(o=1,i=1):s>=90?(o=-1,i=1):s<=0&&s>=-90?(o=1,i=-1):(o=-1,i=-1);var u=[Math.cos(s*Math.PI/180)*(c*p)+r[0],Math.sin(s*Math.PI/180)*(c*p)+r[1]],f=[Math.cos(s*Math.PI/180)*(c*p+o)+r[0],Math.sin(s*Math.PI/180)*(c*p+i)+r[1]];n+=ol.proj.transform(u,this.mercator_,this.coordEPSG4326)+",",n+=ol.proj.transform(f,this.mercator_,this.coordEPSG4326)+"|"}return n}}},{key:"getDistBetweenPoints",value:function(t,e){return new ol.geom.LineString([ol.proj.transform(t,this.projectionMap_,this.mercator_),ol.proj.transform(e,this.projectionMap_,this.mercator_)]).getLength()}},{key:"getAngleBetweenPoints",value:function(t,e){var o=t[0],i=t[1],n=e[0],r=e[1];return 180*Math.atan2(r-i,n-o)/Math.PI}},{key:"startLoad",value:function(){document.body.style.cursor="wait",this.deactivate(),document.querySelector(".m-topographicprofile.activated").style.pointerEvents="none"}},{key:"endLoad",value:function(){document.body.style.cursor="default",this.activate(),document.querySelector(".m-topographicprofile.activated").style.pointerEvents="auto"}},{key:"activate",value:function(){this.draw_||this.createIteraction("LineString"),this.facadeMap_.getMapImpl().addInteraction(this.draw_),document.querySelector("#m-topographicprofile-btn").classList.add("activated")}},{key:"createIteraction",value:function(t){this.draw_=new ol.interaction.Draw({source:this.source_,type:t}),this.draw_.on("drawstart",function(t){this.projectionMap_=this.facadeMap_.getProjection().code,this.clearLayer()}.bind(this)),this.draw_.on("drawend",function(t){this.lineCoord_=t.feature.getGeometry().getCoordinates(),this.pointsCoord_=new String;for(var e=1;e3}))).forEach((function(t){var e="".concat("https://servicios.idee.es/wcs-inspire/mdt?request=GetCoverage&bbox=").concat(t).concat("&service=WCS&version=1.0.0&coverage=Elevacion4258_500&interpolationMethod=bilinear&crs=EPSG%3A4258&format=ArcGrid&width=2&height=2");i.push(M.remote.get(e))})),Promise.all(i).then((function(i){i.forEach((function(t){var e=t.text.split("dy")[1].split(" ").filter((function(t){return""!==t}))[1];o.push(parseFloat(e))}));var n=[];o.forEach((function(t,o){var i=e[o].split(","),r=ol.extent.getCenter([parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])]);n.push([r[0],r[1],t])})),t.controlProfile();var r=n.map((function(e){return ol.proj.transform(e,"EPSG:4326",t.facadeMap_.getProjection().code)}));t.lineString_.setCoordinates(r)})).catch((function(){M.dialog.error("No se han obtenido datos")}))}}},{key:"controlProfile",value:function(){if(!this.profil_){this.lineString_=new ol.geom.LineString([]),this.feature_=new ol.Feature({geometry:this.lineString_,name:"Line"}),this.sourceProfile_.addFeature(this.feature_),this.profil_=new u({info:{zmin:l("profil.zmin"),zmax:l("profil.zmax"),altitude:l("profil.altitude"),distance:l("profil.distance"),ytitle:l("profil.ytitle"),xtitle:l("profil.xtitle"),altitudeUnits:"m",distanceUnitsM:"m",distanceUnitsKM:"km"},projection:this.facadeMap_.getProjection().code,map:this.facadeMap_.getMapImpl(),source:this.source_}),this.facadeMap_.getMapImpl().addControl(this.profil_);var t=function(t){this.pt&&("over"==t.type?(this.pt.setGeometry(new ol.geom.Point(t.coord)),this.pt.setStyle(null)):this.pt.setStyle([]))}.bind(this);this.sourceProfile_.once("change",function(t){"ready"===this.sourceProfile_.getState()&&(this.profil_.setGeometry(this.sourceProfile_.getFeatures()[0]),this.pt=new ol.Feature(new ol.geom.Point([0,0])),this.pt.setStyle([]),this.source_.addFeature(this.pt))}.bind(this)),this.profil_.on(["over","out"],function(e){"over"==e.type&&this.profil_.popup(e.coord[2]+" m"),t(e)}.bind(this))}this.profil_.show()}},{key:"deactivate",value:function(){this.draw_&&(this.facadeMap_.getMapImpl().removeInteraction(this.draw_),this.clearLayer(),document.querySelector("#m-topographicprofile-btn").classList.remove("activated"))}},{key:"clearLayer",value:function(){this.source_.clear(),this.profil_&&(this.profil_.hide(),this.sourceProfile_.clear(),this.facadeMap_.getMapImpl().removeControl(this.profil_),this.profil_=null)}},{key:"removeLayer",value:function(){this.deactivate(),this.clearLayer(),this.facadeMap_.getMapImpl().removeLayer(this.vector_)}},{key:"destroy",value:function(){this.removeLayer(),this.facadeMap_.getMapImpl().removeControl(this)}},{key:"toggle",value:function(){this.profil_&&this.profil_.toggle()}}])&&h(o.prototype,i),n&&h(o,n),e}(),g=o(2),b=o.n(g);function w(t){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function P(t,e){for(var o=0;o0&&void 0!==arguments[0]?arguments[0]:{};return j(this,e),(t=z(this,I(e).call(this))).map_=null,t.controls_=[],t.position_=o.position?o.position:"TR",t.metadata_=k.metadata,t.facadeMap_=null,t.panel_=null,t.control_=null,t.options_=o,t}var o,i,n;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&A(t,e)}(e,M.Plugin),o=e,(i=[{key:"addTo",value:function(t){this.controls_.push(new L(this.options_)),this.map_=t,this.panel_=new M.ui.Panel("panelTopographicprofile",{className:"m-topographicprofile",collapsedButtonClass:"g-grafica-puntos2",position:M.ui.position[this.position_],tooltip:l("tooltip")}),this.panel_.addControls(this.controls_),t.addPanels(this.panel_)}},{key:"getMetadata",value:function(){return this.metadata_}},{key:"getAPIRest",value:function(){return"".concat(this.name,"=").concat(this.position_)}},{key:"destroy",value:function(){this.map_.removeControls(this.controls_);var t=[null,null,null];this.map_=t[0],this.controls_=t[1],this.panel_=t[2]}},{key:"name",get:function(){return"topographicprofile"}}])&&O(o.prototype,i),n&&O(o,n),e}();window.M.plugin||(window.M.plugin={}),window.M.control||(window.M.control={}),window.M.impl||(window.M.impl={}),window.M.impl.control||(window.M.impl.control={}),window.M.plugin.Topographicprofile=G,window.M.control.Topographicprofilecontrol=L,window.M.impl.control.TopographicprofileControl=v}]);
//# sourceMappingURL=topographicprofile.ol.min.js.map