text: 'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,c){a!=Array.prototype&&a!=Object.prototype&&(a[d]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
  $jscomp.polyfill=function(a,d,c,l){if(d){c=$jscomp.global;a=a.split(".");for(l=0;l<a.length-1;l++){var b=a[l];b in c||(c[b]={});c=c[b]}a=a[a.length-1];l=c[a];d=d(l);d!=l&&null!=d&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:d})}};$jscomp.polyfill("Math.log10",function(a){return a?a:function(a){return Math.log(a)/Math.LN10}},"es6-impl","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
  $jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};
  $jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var d=0;return $jscomp.iteratorPrototype(function(){return d<a.length?{done:!1,value:a[d++]}:{done:!0}})};
  $jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.iteratorFromArray=function(a,d){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,l={next:function(){if(c<a.length){var b=c++;return{value:d(b,a[b]),done:!1}}l.next=function(){return{done:!0,value:void 0}};return l.next()}};l[Symbol.iterator]=function(){return l};return l};
  $jscomp.polyfill("Array.prototype.values",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a,c){return c})}},"es6","es3");$jscomp.polyfill("Array.prototype.fill",function(a){return a?a:function(a,c,l){var b=this.length||0;0>c&&(c=Math.max(0,b+c));if(null==l||l>b)l=b;l=Number(l);0>l&&(l=Math.max(0,b+l));for(c=Number(c||0);c<l;c++)this[c]=a;return this}},"es6-impl","es3");
  $jscomp.polyfill("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}},"es6-impl","es3");$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,c){var d=this;d instanceof String&&(d=String(d));var b=d.length;for(c=c||0;c<b;c++)if(d[c]==a||Object.is(d[c],a))return!0;return!1}},"es7","es3");
  $jscomp.checkStringArgs=function(a,d,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(d instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,c){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,c||0)}},"es6-impl","es3");
  $jscomp.findInternal=function(a,d,c){a instanceof String&&(a=String(a));for(var l=a.length,b=0;b<l;b++){var f=a[b];if(d.call(c,f,b,a))return{i:b,v:f}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6-impl","es3");
  $jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(a,c){var d=$jscomp.checkStringArgs(this,a,"startsWith");a+="";var b=d.length,f=a.length;c=Math.max(0,Math.min(c|0,d.length));for(var m=0;m<f&&c<b;)if(d[c++]!=a[m++])return!1;return m>=f}},"es6-impl","es3");$jscomp.owns=function(a,d){return Object.prototype.hasOwnProperty.call(a,d)};
  $jscomp.polyfill("Object.assign",function(a){return a?a:function(a,c){for(var d=1;d<arguments.length;d++){var b=arguments[d];if(b)for(var f in b)$jscomp.owns(b,f)&&(a[f]=b[f])}return a}},"es6-impl","es3");(function(a){a&&a.prototype&&null==a.prototype.children&&Object.defineProperty(a.prototype,"children",{get:function(){for(var a=0,c,l=this.childNodes,b=[];c=l[a++];)1===c.nodeType&&b.push(c);return b}})})(window.Node||window.Element);
  "function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(a,d){if(null==a)throw new TypeError("Cannot convert undefined or null to object");for(var c=Object(a),l=1;l<arguments.length;l++){var b=arguments[l];if(null!=b)for(var f in b)Object.prototype.hasOwnProperty.call(b,f)&&(c[f]=b[f])}return c},writable:!0,configurable:!0});Math.log10=Math.log10||function(a){return Math.log(a)*Math.LOG10E};
  Array.prototype.filter||(Array.prototype.filter=function(a){if(void 0===this||null===this)throw new TypeError;var d=Object(this),c=d.length>>>0;if("function"!==typeof a)throw new TypeError;for(var l=[],b=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in d){var m=d[f];a.call(b,m,f,d)&&l.push(m)}return l});function Console(a){function d(a){a=(a+"").replace(/&/g,"&amp;");a=a.replace(/</g,"&lt;");a=a.replace(/>/g,"&gt;");a=a.replace(/\"/g,"&quot;");return a=a.replace(/\n/g,"<br>")}var c=a,l="";this.println=function(a,f){l=0==f?l+("<p class='stdoutmessage'>"+a+"</p>"):l+("<p class='stdoutmessage'>"+d(a)+"</p>");isDefined(c)&&(c.innerHTML=l,c.scrollTop=c.scrollHeight);17824<l.length&&(l=l.substring(l.length-13368))};this.errprintln=function(a,f){l=0==f?l+("<p class='stderrmessage'>"+a+"</p>"):l+("<p class='stderrmessage'>"+
  d(a)+"</p>");isDefined(c)&&(c.innerHTML=l,c.scrollTop=c.scrollHeight)};this.cls=function(){l="";isDefined(c)&&(c.innerHTML=l)};this.setSize=function(a,d){isDefined(c)&&(c.scrollTop=c.scrollHeight,c.style.width=a+"px",c.style.height=d+"px",c.width=a+"px",c.height=d+"px")};this.setElement=function(a){c=a;isDefined(c)&&(c.style.overflow="scroll",c.style.display="inline-block",c.style.position="absolute",c.style.width="100%",c.style.height="100%",c.style.font="normal 12px courier",c.noWrap=!0,c.style.whiteSpace=
  "nowrap",c.innerHTML=l,c.scrollTop=c.scrollHeight)};this.setElement(a)}function isDefined(a){return"undefined"===typeof a?!1:!0}function isNull(a){return null===a?!0:!1}function toArray(a){if(!a)return[];if(a.length)return a;var d=[];d[0]=a;return d}var WMJSSet=function(){};WMJSSet.prototype.add=function(a){this[a]=!0};WMJSSet.prototype.remove=function(a){delete this[a]};
  function WMJSKVP(a){var d=[];this._parse=function(a){var d=[];if(a=a.split("&"))for(var b in a){var c=a[b].split("=");if(2==c.length){var m=c[0],c=c[1];d[m]instanceof Array||(d[m]=[]);d[m].push(c)}}return d};this.getKeys=function(){var a=new WMJSSet;for(key in d)a.add(key);return a};this.getValues=function(a){return d[a]};this.getKeyValues=function(){return d};return d=this._parse(a)}
  var preventdefault_event=function(a){a=a||window.event;a.preventDefault?a.preventDefault():a.returnValue=!1},attach_event=function(a,d,c){if("mousewheel"==d){var l=function(a,d){var b=0;a||(a=window.event,window.event.cancelBubble=!0,window.event.returnValue=!1);a.wheelDelta?b=a.wheelDelta/120:a.detail&&(b=-a.detail/3);b&&d(b);a.preventDefault&&a.preventDefault();a.returnValue=!1};a.addEventListener&&a.addEventListener("DOMMouseScroll",function(a){l(a,c)},!1);a.onmousewheel=document.onmousewheel=
  function(a){l(a,c)}}else browser.isNS?a.addEventListener(d,c,!0):(a.attachEvent("on"+d,c),void 0!=window.event&&(window.event.cancelBubble=!0,window.event.returnValue=!1))},del_event=function(a,d,c){var l=!0;browser.isOP&&(l=!1);a.removeEventListener?a.removeEventListener(d,c,l):a.detachEvent&&(a.detachEvent(d,c),a.detachEvent("on"+d,c))},getClick_X=function(a){return browser.isNS?a.clientX+window.scrollX:window.event.clientX+document.documentElement.scrollLeft+document.body.scrollLeft},getClick_Y=
  function(a){return browser.isNS?a.clientY+window.scrollY:window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop},findElementPos=function(a){for(var d=a,c=curtop=0;a;)c+=a.offsetLeft,curtop+=a.offsetTop,a=a.offsetParent;return[c,curtop,parseInt(d.style.width+c),parseInt(d.style.height+curtop)]};
  function Browser(){this.isKonqueror=this.isOP=this.isNS=this.isIE=!1;this.name=navigator.appName;this.version=null;-1!=navigator.userAgent.indexOf("Opera")?this.isOP=!0:"Netscape"==navigator.appName||"Konqueror"==navigator.appName?this.isKonqueror=this.isNS=!0:-1!=navigator.appName.indexOf("Microsoft")&&(this.isIE=!0)}var browser=new Browser;function IsNumeric(a){var d=!0;for(i=0;i<a.length&&1==d;i++){var c=a.charAt(i);-1=="0123456789.".indexOf(c)&&(d=!1)}return d}
  function dump(a,d,c){var l="";c||(c="");d||(d=0);if("object"===typeof a)for(var b in a){var f=a[b];if(IsNumeric(b)){b="["+b+"]";var m=c.substr(0,c.length-1)+b}else m=c+b;l="object"===typeof f?l+dump(f,d+1,m+"."):l+(m+'="'+f+'"<br>\n')}else l="===>"+a+"<===("+typeof a+")";return l}
  var Url={encode:function(a){return escape(this._utf8_encode(a))},decode:function(a){alert("Deprecated function !!! WMJSTools line 325 with ["+a+"]");return this._utf8_decode(unescape(a))},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var d="",c=0;c<a.length;c++){var l=a.charCodeAt(c);128>l?d+=String.fromCharCode(l):(127<l&&2048>l?d+=String.fromCharCode(l>>6|192):(d+=String.fromCharCode(l>>12|224),d+=String.fromCharCode(l>>6&63|128)),d+=String.fromCharCode(l&63|128))}return d},_utf8_decode:function(a){var d=
  "",c=0;for(c1=c2=0;c<a.length;){var l=a.charCodeAt(c);128>l?(d+=String.fromCharCode(l),c++):191<l&&224>l?(c2=a.charCodeAt(c+1),d+=String.fromCharCode((l&31)<<6|c2&63),c+=2):(c2=a.charCodeAt(c+1),c3=a.charCodeAt(c+2),d+=String.fromCharCode((l&15)<<12|(c2&63)<<6|c3&63),c+=3)}return d}};Array.indexOf||(Array.prototype.indexOf=function(a){for(var d=0;d<this.length;d++)if(this[d]==a)return d;return-1});
  function createXHR(){try{return new XMLHttpRequest}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}return!1}
  function MakeJSONRequest(a,d,c,l,b){function f(a){c?c(a,l):d(void 0,l)}function m(){0==b?(a=requestProxy+"REQUEST="+URLEncode(a),MakeJSONRequest(a,d,c,l,!0)):f("status("+k.status+") to "+a)}a=-1==a.indexOf("?")?a+"?":a+"&";a+="rand="+Math.random();b||(b=!1);try{var k=createXHR();k.open("GET",a,!0);k.onreadystatechange=function(){if(4==k.readyState)if(200==k.status){try{var b=eval("("+k.responseText+")")}catch(e){f("Invalid JSON: '"+k.responseText+"'");return}void 0==b?f("request returned no data:"+
  a):d(b,l)}else m()};k.send(null)}catch(t){m()}}
  function MakeHTTPRequest(a,d,c,l,b){function f(a){c?c(a,l):d(void 0,l)}function m(){0==b?(a=requestProxy+"REQUEST="+URLEncode(a),MakeHTTPRequest(a,d,c,l,!0)):f("status("+k.status+") to "+a)}a=-1==a.indexOf("?")?a+"?":a+"&";a+="rand="+Math.random();b||(b=!1);try{var k=createXHR();k.open("GET",a,!0);k.onreadystatechange=function(){if(4==k.readyState)if(200==k.status){try{var a=k.responseText}catch(e){f("Exception occured:"+e);return}void 0==a||""==a?f("request returned no data"):d(a,l)}else m()};k.send(null)}catch(t){m()}}
  var URLDecode=function(a){if(!isDefined(a))return"";a=a.replaceAll("+"," ");a=a.replaceAll("%2B","+");a=a.replaceAll("%20"," ");a=a.replaceAll("%5E","^");a=a.replaceAll("%26","&");a=a.replaceAll("%3F","?");a=a.replaceAll("%3E",">");a=a.replaceAll("%3C","<");a=a.replaceAll("%5C","\\");a=a.replaceAll("%2F","/");a=a.replaceAll("%25","%");a=a.replaceAll("%3A",":");a=a.replaceAll("%27","'");return a=a.replaceAll("%24","$")},URLEncode=function(a){if(!a||void 0==a||""==a||"string"!==typeof a)return a;a=
  a.replace(/\%/g,"%25");a=a.replace(/\+/g,"%2B");a=a.replace(/\ /g,"%20");a=a.replace(/\^/g,"%5E");a=a.replace(/\&/g,"%26");a=a.replace(/\?/g,"%3F");a=a.replace(/\>/g,"%3E");a=a.replace(/\</g,"%3C");a=a.replace(/\\/g,"%5C");for(var d="",c=0;c<a.length;c++){var l=a.charAt(c);if(" "==l)d+="%20";else if(-1!="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz%-_.!~*'()".indexOf(l))d+=l;else{var b=l.charCodeAt(0);255<b?(alert("Unicode Character '"+l+"' cannot be encoded using standard URL encoding.\n(URL encoding only supports 8-bit characters.)\nA space (+) will be substituted."),
  d+="+"):(d+="%",d+="0123456789ABCDEF".charAt(b>>4&15),d+="0123456789ABCDEF".charAt(b&15))}}return d};String.prototype.replaceAll=function(a,d){for(var c=this,l=c.indexOf(a);-1!=l;)c=c.replace(a,d),l=c.indexOf(a);return c};String.prototype.trim=function(){var a=this.replace(/^\s+/,"");return a=a.replace(/\s+$/,"")};function checkValidInputTokens(a){var d=/^([a-zA-Z'_:~%?\$,\.\0-9 \-=/&])+$/;return d.test(a)&&(a=URLDecode(a),d.test(a))?!0:!1}
  function getUrlVars(){for(var a=[],d,c=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),l=0;l<c.length;l++)d=c[l].split("="),d[1]=URLDecode(d[1]),0!=checkValidInputTokens(d[0])&&0!=checkValidInputTokens(d[1])&&(a[d[0]]=d[1]+"");return a}
  function getUrlVarsFromHashTag(){var a=[];var d=window.location.hash.indexOf("#");"?"==window.location.hash[d+1]&&d++;for(var c=window.location.hash.slice(d+1).split("&"),l=0;l<c.length;l++)d=c[l].split("="),d[1]=URLDecode(d[1]),0!=checkValidInputTokens(d[0])&&0!=checkValidInputTokens(d[1])&&(a[d[0]]=d[1]+"");return a}
  var composeUrlObjectFromURL=function(a){var d=[];if(!isDefined(a))return d;var c="";a=a.split("?");1<a.length?(c=a[0],a=a[1].split("&")):a=a[0].split("&");for(var l=0;l<a.length;l++)hash=a[l].split("="),isDefined(hash[1])?(hash[1]=URLDecode(hash[1]),0!=checkValidInputTokens(hash[0])&&0!=checkValidInputTokens(hash[1])&&isDefined(hash[1])&&0<hash[1].length&&(d[hash[0].toLowerCase()]=hash[1]+"")):(hash=a[l].split("%3D"),isDefined(hash[1])&&(hash[1]=URLDecode(hash[1]),0!=checkValidInputTokens(hash[0])&&
  0!=checkValidInputTokens(hash[1])&&isDefined(hash[1])&&0<hash[1].length&&(d[hash[0].toLowerCase()]=hash[1]+"")));a[0].indexOf("=");return{location:c,kvp:d}},currentLocationHash="",hashTagCheckerInUse=!1,_checkIfHashTagChanged=function(a){var d=window.location.hash;currentLocationHash!=d&&0<d.length&&(currentLocationHash=d,-1!=window.location.href.indexOf("#")&&(d=window.location.href.split("#")[1],d=d.replaceAll("%27","'"),urlVars=getUrlVarsFromHashTag(),isDefined(urlVars.clearhash)&&"1"==urlVars.clearhash&&
  (currentLocationHash=window.location.hash=""),a(d,urlVars)));setTimeout(function(){_checkIfHashTagChanged(a)},100)},checkIfHashTagChanged=function(a){isDefined(a)&&(1==hashTagCheckerInUse?alert("checkIfHashTagChanged is in use"):(hashTagCheckerInUse=!0,_checkIfHashTagChanged(a)))},decodeBase64=function(a){var d={},c,l=0,b,f=0,m,k="",t=String.fromCharCode,e=a.length;for(c=0;64>c;c++)d["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c)]=c;for(b=0;b<e;b++)for(c=d[a.charAt(b)],
  l=(l<<6)+c,f+=6;8<=f;)((m=l>>>(f-=8)&255)||b<e-2)&&(k+=t(m));return k};var WMJSEmptyLayerName="empty_layer",WMJSEmptyLayerTitle="empty layer";
  function WMJSLayer(a){this.autoupdate=!1;this.getlegendgraphicURL=this.getfeatureinfoURL=this.getmapURL=this.WMJSService=this.service=this.timer=void 0;this.keepOnTop=!1;this.transparent=!0;this.hasError=!1;this.legendIsDimensionDependant=!0;this.wms130bboxcompatibilitymode=!1;this.version=WMSVersion.version111;this.path="";this.type="wms";this.objectpath=[];this.wmsextensions=function(a){this.wmsextensions.colorscalerange="";isDefined(a.colorscalerange)&&(this.wmsextensions.colorscalerange=a.colorscalerange);
  this.wmsextensions.url="";2<this.wmsextensions.colorscalerange.length&&(this.wmsextensions.url+="&COLORSCALERANGE="+this.wmsextensions.colorscalerange)};this.wmsextensions.url="";this.name=this.jsonlayer_v1_1_1=void 0;this.title=WMJSEmptyLayerTitle;this.abstract=void 0;this.dimensions=[];this.legendGraphic="";this.projectionProperties=[];this.queryable=!1;this.enabled=!0;this.styles=void 0;this.currentStyle="";this.id=-1;this.opacity=1;this.getCapabilitiesDoc=this.image=void 0;this.serviceTitle="not defined";
  this.onReady=function(a){};this.parentMaps=[];this.getLayerName=function(){return this.name};this.toggleAutoUpdate=function(){(this.autoupdate=!this.autoupdate)?this.timer=setInterval(function(a){return function(){a.parseLayer(void 0,!0,"WMJSLayer::autoupdate")}}(this),6E4):clearInterval(this.timer)};this.setAutoUpdate=function(a,c,l){a!==this.autoupdate&&((this.autoupdate=a)?this.timer=setInterval(function(a){return function(){a.parseLayer(l,!0,"WMJSLayer::autoupdate")}}(this),c):clearInterval(this.timer))};
  this.setOpacity=function(a){this.opacity=a;this.image&&(this.image.setOpacity(this.opacity),this.parentMaps[0].redrawBuffer())};this.remove=function(){for(var a=0;a<this.parentMaps.length;a++)this.parentMaps[a].deleteLayer(this),this.parentMaps[a].draw("WMJSLayer::remove");clearInterval(this.timer)};this.moveUp=function(){for(var a=0;a<this.parentMaps.length;a++)this.parentMaps[a].moveLayerUp(this),this.parentMaps[a].draw("WMJSLayer::moveUp")};this.moveDown=function(){for(var a=0;a<this.parentMaps.length;a++)this.parentMaps[a].moveLayerDown(this),
  this.parentMaps[a].draw("WMJSLayer::moveDown")};this.zoomToLayer=function(){for(var a=0;a<this.parentMaps.length;a++)this.parentMaps[a].zoomToLayer(this)};this.draw=function(a){for(var c=0;c<this.parentMaps.length;c++)this.parentMaps[c].draw("WMJSLayer::draw::"+a)};this.handleReferenceTime=function(a,c){"reference_time"===a&&(a=this.getDimension("time"))&&(a.setStartTime(c),this.parentMaps&&0<this.parentMaps.length&&this.parentMaps[0].getListener().triggerEvent("ondimchange","time"))};this.setDimension=
  function(a,c){for(var d,b=0;b<this.dimensions.length;b++)this.dimensions[b].name==a&&(d=this.dimensions[b]);if(0!=isDefined(d)&&0!=isDefined(c)&&(d.setValue(c),this.handleReferenceTime(a,c),1==d.linked))for(b=0;b<this.parentMaps.length;b++)this.parentMaps[b].setDimension(a,d.getValue())};this.configureDimensions=function(){var a=this.cloneLayer(),c=this.jsonlayer_v1_1_1;if(c){for(var l=toArray(c.Dimension),b=this.objectpath.length-1;0<=b;b--){var f=this.objectpath[b].Dimension;if(!isNull(f)&&isDefined(f))for(var m=
  0;m<f.length;m++){var k=f[m];if(!isNull(k)&&isDefined(k)){for(var t=!1,e=0;e<l.length;e++)if(k.attr.name.toLowerCase()===l[b].attr.name.toLowerCase()){t=!0;break}t||l.push(k)}}}c=toArray(c.Extent);this.dimensions=[];f=!1;for(b=0;b<l.length;b++){if("reference_time"===l[b].attr.name.toLowerCase()){f=!0;var n=new WMJSDimension({linked:!1})}else n=new WMJSDimension;n.name=l[b].attr.name.toLowerCase();n.units=l[b].attr.units;for(e=0;e<c.length;e++)c[e].attr.name.toLowerCase()==n.name&&(n.values=c[e].value?
  c[e].value.trim():"",c[e].attr["default"]?n.defaultValue=c[e].attr["default"].trim():(m=n.values.split("/"),1<m.length?n.defaultValue=m[1]:0<m.length&&(n.defaultValue=m[0])),c[e].value||(error("No extent defined for dim "+n.name+" in layer "+this.title),error("Using default value "+n.defaultValue),n.values=n.defaultValue));this.version==WMSVersion.version130&&(n.values=l[b].value,n.defaultValue=l[b].attr["default"]);e=n.defaultValue;0<this.parentMaps.length?(m=this.parentMaps[0].getDimension(n.name),
  isDefined(m)&&m.linked&&(isDefined(m.currentValue)?(e=n.getClosestValue(m.currentValue),debug("WMJSLayer::configureDimensions Dimension "+n.name+" default value ["+e+"] is based on map value ["+m.currentValue+"]")):debug("WMJSLayer::configureDimensions Map dimension currentValue for "+n.name+" does not exist."))):debug("WMJSLayer::configureDimensions Layer has no parentmaps");1===a.dimensions.filter(function(a){return a.name===n.name}).length?(m=a.dimensions.filter(function(a){return a.name===n.name})[0],
  isDefined(m.currentValue)?n.setValue(m.currentValue):n.setValue(e)):n.setValue(e);n.parentLayer=this;isDefined(n.values)?this.dimensions.push(n):error("Skipping dimension "+n.name)}f&&(a=this.getDimension("reference_time"),this.handleReferenceTime("reference_time",a.getValue()))}};this.parseLayer=function(d,c,l){var b=this;b.hasError=!1;var f=function(a){isDefined(d)&&d(a)},m=function(c,d){b.hasError=!0;b.lastError=d;b.title=I18n.service_has_error.text;error(d);f(c);isDefined(a.failure)&&a.failure(c,
  d)};b.WMJSService=WMJSgetServiceFromStore(this.service);b.WMJSService.getCapabilities(function(a){(function(a,b){function c(b,d,l){for(var e=[],f=0;f<l.length;f++)e.push(l[f]);e.push(b);for(l=0;l<b.length;l++)if(b[l].Layer){f=d;try{f+=b[l].Title.value+"/"}catch(F){}c(toArray(b[l].Layer),f,e)}else if(b[l].Name&&b[l].Name.value==a.name){I(b[l],d,e);break}}if(0==b||void 0==b)a.title=I18n.service_has_error.text,a.abstract=I18n.not_available_message.text,m(a,I18n.unable_to_connect_server.text);else{try{var d=
  a.WMJSService.getCapabilityElement(b)}catch(C){m(a,C);return}a.version=a.WMJSService.version;var l=d.Layer;if(isDefined(l)){try{a.serviceTitle=l.Title.value}catch(C){a.serviceTitle="Unnamed service"}try{for(var e=d.Request.GetMap.Format,k=0;k<e.length;k++)e[k].value.indexOf("24"),e[k].value.indexOf("32")}catch(C){error("This WMS service has no getmap formats listed: using image/png")}if(void 0==a.name||1>a.name.length)a.title=WMJSEmptyLayerTitle,a.abstract=I18n.not_available_message.text,f(a);else{var t=
  0,I=function(c,e,f){a.jsonlayer_v1_1_1=c;a.getmapURL=void 0;try{a.getmapURL=d.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr["xlink:href"]}catch(u){}isDefined(a.getmapURL)||(a.getmapURL=a.service,error("GetMap OnlineResource is not specified. Using default."));a.getfeatureinfoURL=void 0;try{a.getfeatureinfoURL=d.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr["xlink:href"]}catch(u){}isDefined(a.getfeatureinfoURL)||(a.getfeatureinfoURL=a.service,error("GetFeatureInfo OnlineResource is not specified. Using default."));
  a.getlegendgraphicURL=void 0;try{a.getlegendgraphicURL=d.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr["xlink:href"]}catch(u){}isDefined(a.getlegendgraphicURL)||(a.getlegendgraphicURL=a.service,error("GetLegendGraphic OnlineResource is not specified. Using default."));a.getmapURL=WMJScheckURL(a.getmapURL);a.getfeatureinfoURL=WMJScheckURL(a.getfeatureinfoURL);a.getlegendgraphicURL=WMJScheckURL(a.getlegendgraphicURL);a.getCapabilitiesDoc=b;a.title=c.Title.value;try{a.abstract=c.Abstract.value}catch(u){a.abstract=
  I18n.not_available_message.text}a.path=e;a.objectpath=f;a.styles=void 0;a.jsonlayer=a;try{e="";c.Style&&(e=toArray(c.Style));a.styles=e;for(var k=0;k<a.styles.length;k++){var g=a.styles[k];g.index=k;g.nrOfStyles=a.styles.length;g.title="default";g.name="default";g.legendURL="";g.abstracttext="No abstract available";try{g.title=g.Title.value}catch(u){}try{g.name=g.Name.value}catch(u){}try{g.legendURL=g.LegendURL.OnlineResource.attr["xlink:href"]}catch(u){}try{g.abstracttext=g.Abstract.value}catch(u){}}""==
  a.currentStyle&&(a.currentStyle=a.styles[0].Name.value);a.setStyle(a.currentStyle)}catch(u){a.currentStyle="",a.styles="",error("No styles found for layer "+a.title)}a.configureDimensions();g=toArray(c.SRS);isDefined(c.CRS)&&(g=toArray(c.CRS));a.projectionProperties=[];var m=[];e=function(b){if(isDefined(b.BoundingBox))for(b=toArray(b.BoundingBox),k=0;k<b.length;k++){var c=b[k].attr.SRS;isDefined(b[k].attr.CRS)&&(c=b[k].attr.CRS);c&&0<c.length&&(c=decodeURIComponent(c));for(var d=!1,l=0;l<a.projectionProperties.length;l++)if(c==
  a.projectionProperties[l].srs){d=!0;break}0==d&&(d=new WMJSProjection,d.srs=c,c=!1,a.version==WMSVersion.version130&&"EPSG:4326"==d.srs&&0==a.wms130bboxcompatibilitymode&&(c=!0),0==c?(d.bbox.left=parseFloat(b[k].attr.minx),d.bbox.bottom=parseFloat(b[k].attr.miny),d.bbox.right=parseFloat(b[k].attr.maxx),d.bbox.top=parseFloat(b[k].attr.maxy)):(d.bbox.left=parseFloat(b[k].attr.miny),d.bbox.bottom=parseFloat(b[k].attr.minx),d.bbox.right=parseFloat(b[k].attr.maxy),d.bbox.top=parseFloat(b[k].attr.maxx)),
  a.projectionProperties.push(d),m.push(d.srs))}};e(c);e(l);for(k=0;k<g.length;k++)-1==m.indexOf(g[k].value)&&(e=new WMJSProjection,error("Warning: BoundingBOX missing for SRS "+g[k].value),e.bbox.left=-180,e.bbox.bottom=-90,e.bbox.right=180,e.bbox.top=90,e.srs=g[k].value,a.projectionProperties.push(e));m="";a.queryable=!1;try{1==parseInt(c.attr.queryable)?a.queryable=!0:a.queryable=!1}catch(u){error("Unable to detect whether this layer is queryable (for layer "+a.title+")")}t=1},e=toArray(l.Layer),
  k=[];k.push(l);c(e,"",k);if(0==t)return e="",e=a.name?"Unable to find layer '"+a.name+"' in service '"+a.service+"'":"Unable to find layer '"+a.title+"' in service '"+a.service+"'",a.title="--- layer not found in service ---",a.abstract=I18n.not_available_message.text,m(a,e),a;if(a.onReady)a.onReady(a);f(a);return a}}else m(a,"No Layer element in service")}})(b,a)},function(a){m(b,a)},c)};this.cloneLayer=function(){var a=new WMJSLayer,c;for(c in this)a[c]=this[c];return a};this.setName=function(a){this.name=
  a;this.parseLayer(void 0,void 0,"WMJSLayer::setName")};this.getLayerRelative=function(a,c,l){isDefined(l)||(l=0);var b=this;b.WMJSService.getLayerObjectsFlat(function(d){for(var f=-1,k=0;k<d.length;k++)if(d[k].name==b.name){f=k;break}-1==f?c("Current layer ["+b.name+"] not in this service"):(-1===l&&f--,1===l&&f++,f>d.length-1&&(f=0),0>f&&(f=d.length-1),a(d[f],f,d.length))},c)};this.autoSelectLayer=function(a,c){this.WMJSService.getLayerObjectsFlat(function(c){for(var b=0;b<c.length;b++)if(isDefined(c[b].name)&&
  -1==c[b].name.indexOf("baselayer")&&-1==c[b].path.indexOf("baselayer")){a(c[b]);break}},c)};this.getNextLayer=function(a,c){this.getLayerRelative(a,c,1)};this.getPreviousLayer=function(a,c){this.getLayerRelative(a,c,-1)};this.setStyle=function(a){debug("WMJSLayer::setStyle: "+a);if(0==this.styles.length)this.legendGraphic=this.currentStyle="",debug("Layer has no styles.");else{for(var c=0;c<this.styles.length;c++)if(this.styles[c].name==a){this.legendGraphic=this.styles[c].legendURL;this.currentStyle=
  this.styles[c].name;return}debug("WMJSLayer::setStyle: Style "+a+" not found, setting style "+this.styles[0].name);this.currentStyle=this.styles[0].name;this.legendGraphic=this.styles[0].legendURL}};this.getStyles=function(){return this.styles?this.styles:[]};this.getStyleObject=function(a,c){if(0!=isDefined(this.styles))for(var d=0;d<this.styles.length;d++)if(this.styles[d].name==a)return-1===c&&d--,1===c&&d++,0>d&&(d=this.styles.length-1),d>this.styles.length-1&&(d=0),this.styles[d].nrOfStyles=
  this.styles.length,this.styles[d].index=d,this.styles[d]};this.getStyle=function(){return this.currentStyle};this.setService=function(a){this.getgraphinfoURL=this.getlegendgraphicURL=this.getfeatureinfoURL=this.getmapURL=this.service=a};this.getDimension=function(a){for(var c=0;c<this.dimensions.length;c++)if(this.dimensions[c].name==a)return this.dimensions[c]};this.getProjection=function(a){for(var c=0;c<this.projectionProperties.length;c++)if(this.projectionProperties[c].srs==a)return a=[],a.srs=
  this.projectionProperties[c].srs+"",a.bbox=new WMJSBBOX(this.projectionProperties[c].bbox.left,this.projectionProperties[c].bbox.bottom,this.projectionProperties[c].bbox.right,this.projectionProperties[c].bbox.top),a};this.display=function(a){this.enabled=a;for(a=0;a<this.parentMaps.length;a++)this.parentMaps[a].displayLayer(this,this.enabled)};a&&(this.getlegendgraphicURL=this.getfeatureinfoURL=this.getmapURL=this.service=a.service,this.name=a.name,a.getgraphinfoURL&&(this.getgraphinfoURL=a.getgraphinfoURL),
  a.style&&(this.currentStyle=a.style),this.format=a.format?a.format:"image/png",a.opacity&&(this.opacity=a.opacity),a.title&&(this.title=a.title),this.abstract=I18n.not_available_message.text,!1===a.enabled&&(this.enabled=!1),1==a.keepOnTop&&(this.keepOnTop=!0),!0===a.transparent&&(this.transparent=!0),!1===a.transparent&&(this.transparent=!1),isDefined(a.onReady)&&(this.onReady=a.onReady,this.parseLayer(void 0,void 0,"WMJSLayer::configOptions")),isDefined(a.type)&&(this.type=a.type))};function DateInterval(a,d,c,l,b,f){this.year=parseInt(a);this.month=parseInt(d);this.day=parseInt(c);this.hour=parseInt(l);this.minute=parseInt(b);this.second=parseInt(f);this.isRegularInterval=!1;0==this.month&&0==this.year&&(this.isRegularInterval=!0);this.getTime=function(){if(0!=this.month)throw"month != 0";if(0!=this.year)throw"year != 0";var a=0+86400*this.day;a+=3600*this.hour;a+=60*this.minute;a+=this.second;return 1E3*a};this.toISO8601=function(){var a="P";0!=this.year&&(a+=this.year+"Y");
  0!=this.month&&(a+=this.month+"M");0!=this.day&&(a+=this.day+"D");0!=this.hour&&0!=this.minute&&0!=this.second&&(a+="T");0!=this.hour&&(a+=this.hour+"H");0!=this.minute&&(a+=this.minute+"M");0!=this.second&&(a+=this.second+"S");return a}}
  function parseISO8601DateToDate(a){if(a){var d=a.split("T");d[0]=d[0].replace(/-/g,":");d[0]=d[0].replace(/::/g,":-");a=d[0].split(":");var d=d[1].split(":"),c=new Date(Date.UTC(a[0],a[1]-1,a[2],d[0],d[1],d[2].split("Z")[0]));c.add=function(a){0==a.isRegularInterval?(0!=a.year&&this.setUTCFullYear(this.getUTCFullYear()+a.year),0!=a.month&&this.setUTCMonth(this.getUTCMonth()+a.month),0!=a.day&&this.setUTCDate(this.getUTCDate()+a.day),0!=a.hour&&this.setUTCHours(this.getUTCHours()+a.hour),0!=a.minute&&
  this.setUTCMinutes(this.getUTCMinutes()+a.minute),0!=a.second&&this.setUTCSeconds(this.getUTCSeconds()+a.second)):this.setTime(this.getTime()+a.getTime())};c.substract=function(a){0==a.isRegularInterval?(0!=a.year&&this.setUTCFullYear(this.getUTCFullYear()-a.year),0!=a.month&&this.setUTCMonth(this.getUTCMonth()-a.month),0!=a.day&&this.setUTCDate(this.getUTCDate()-a.day),0!=a.hour&&this.setUTCHours(this.getUTCHours()-a.hour),0!=a.minute&&this.setUTCMinutes(this.getUTCMinutes()-a.minute),0!=a.second&&
  this.setUTCSeconds(this.getUTCSeconds()-a.second)):this.setTime(this.getTime()-a.getTime())};c.addMultipleTimes=function(a,b){0==a.isRegularInterval?(0!=a.year&&this.setUTCFullYear(this.getUTCFullYear()+a.year*b),0!=a.month&&this.setUTCMonth(this.getUTCMonth()+a.month*b),0!=a.day&&this.setUTCDate(this.getUTCDate()+a.day*b),0!=a.hour&&this.setUTCHours(this.getUTCHours()+a.hour*b),0!=a.minute&&this.setUTCMinutes(this.getUTCMinutes()+a.minute*b),0!=a.second&&this.setUTCSeconds(this.getUTCSeconds()+a.second*
  b)):this.setTime(this.getTime()+a.getTime()*b)};c.substractMultipleTimes=function(a,b){0==a.isRegularInterval?(0!=a.year&&this.setUTCFullYear(this.getUTCFullYear()-a.year*b),0!=a.month&&this.setUTCMonth(this.getUTCMonth()-a.month*b),0!=a.day&&this.setUTCDate(this.getUTCDate()-a.day*b),0!=a.hour&&this.setUTCHours(this.getUTCHours()-a.hour*b),0!=a.minute&&this.setUTCMinutes(this.getUTCMinutes()-a.minute*b),0!=a.second&&this.setUTCSeconds(this.getUTCSeconds()-a.second*b)):this.setTime(this.getTime()-
  a.getTime()*b)};c.toISO8601=function(){function a(a,c){a+="";c-=a.length;var b,d="";for(b=0;b<c;b++)d+="0"+d;return d+a}return a(this.getUTCFullYear(),4)+"-"+a(this.getUTCMonth()+1,2)+"-"+a(this.getUTCDate(),2)+"T"+a(this.getUTCHours(),2)+":"+a(this.getUTCMinutes(),2)+":"+a(this.getUTCSeconds(),2)+"Z"};c.clone=function(){return parseISO8601DateToDate(c.toISO8601())};return c}console.log("Warning: no date given to parseISO8601DateToDate")}
  function parseISO8601IntervalToDateInterval(a){if("P"==a.charAt(0)){var d=a.split("T"),c=a=0,l=0,b=0,f=0,m=0,k=d[0].split("P")[1];if(k){var t=k.indexOf("Y");var e=k.indexOf("M"),n=k.indexOf("D");-1!=t&&(a=k.substring(0,t));-1!=e&&(c=k.substring(t+1,e));-1!=n&&(-1!=e&&(t=e),l=k.substring(t+1,n))}0<d.length&&isDefined(d[1])&&(d=d[1])&&(t=d.indexOf("H"),k=d.indexOf("M"),e=d.indexOf("S"),-1!=t&&(b=d.substring(0,t)),-1!=k&&(f=d.substring(t+1,k)),-1!=e&&(-1!=k&&(t=k),m=d.substring(t+1,e)));return new DateInterval(a,
  c,l,b,f,m)}}function getNumberOfTimeSteps(a,d,c){var l=0;if(0!=c.month||0!=c.year){a=a.clone();for(d=d.getTime();a.getTime()<d;)a.add(c),l++;l++}else l=parseInt((d.getTime()-a.getTime())/c.getTime()+.5)+1;return l}
  function parseISOTimeRangeDuration(a){a=a.split("/");void 0==a[2]&&(a[2]="PT1M");void 0==a[1]&&(a[1]=a[0],a[2]="PT1M");this.startTime=parseISO8601DateToDate(a[0]);this.stopTime=parseISO8601DateToDate(a[1]);this.timeInterval=parseISO8601IntervalToDateInterval(a[2]);this.timeSteps=getNumberOfTimeSteps(this.startTime,this.stopTime,this.timeInterval);this.getTimeSteps=function(){return this.timeSteps};this.getDateAtTimeStep=function(a){if(0==this.timeInterval.isRegularInterval){var c=this.startTime.clone();
  c.addMultipleTimes(this.timeInterval,a)}else{c=this.startTime.clone();var d=this.timeInterval.getTime(),d=d*a;c.setTime(c.getTime()+d)}return c};this.getTimeStepFromISODate=function(a,c){try{currentDate=parseISO8601DateToDate(a)}catch(l){throw"The date '"+a+"' is not a valid date";}return this.getTimeStepFromDate(currentDate,c)};this.getTimeStepFromDate=function(a,c){c||(c=!1);var d=a.getTime();if(d<this.startTime.getTime()){if(1==c)throw 0;return 0}var b=this.stopTime.clone();b.add(this.timeInterval);
  if(d>b.getTime()){if(1==c)throw this.timeSteps-1;return this.timeSteps-1}if(d>this.stopTime.getTime())return this.timeSteps-1;if(0==this.timeInterval.isRegularInterval){c=this.startTime.clone();for(j=0;j<this.timeSteps;j++){b=c.getTime();c.add(this.timeInterval);var f=c.getTime();if(d>=b&&d<f)return j}throw"Date "+a.toISO8601()+" not found!";}a=(a.getTime()-this.startTime.getTime())/this.timeInterval.getTime();return a=parseInt(a);throw"Date "+a.toISO8601()+" not found";};this.getTimeStepFromDate_WithinRange=
  function(a){return this.getTimeStepFromDate(a,!0)};this.getTimeStepFromDate_Clipped=function(a){return this.getTimeStepFromDate(a,!1)}}function getCurrentDateIso8601(){return parseISO8601DateToDate((new Date).toISOString().substring(0,19)+"Z")};Proj4js.defs["EPSG:3575"]="+proj=laea +lat_0=90 +lon_0=10 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";Proj4js.defs["EPSG:3785"]="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs";Proj4js.defs["EPSG:3857"]="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs";Proj4js.defs["EPSG:3411"]="+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs";
  Proj4js.defs["EPSG:3412"]="+proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs";Proj4js.defs["EPSG:4326"]="+proj=longlat +datum=WGS84 +no_defs";Proj4js.defs["EPSG:28992"]="+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs  <>";Proj4js.defs["EPSG:32661"]="+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
  Proj4js.defs["EPSG:102100"]=Proj4js.defs["EPSG:3857"];var epsgDescriptionLookup=[];epsgDescriptionLookup["EPSG:3411"]="NSIDC Sea Ice Polar Stereographic North";epsgDescriptionLookup["EPSG:3412"]="NSIDC Sea Ice Polar Stereographic South";epsgDescriptionLookup["EPSG:3575"]="Lambert azimuthal equal-area projection Europe";epsgDescriptionLookup["EPSG:3785"]="Mercator (deprecated)";epsgDescriptionLookup["EPSG:3857"]="Mercator";epsgDescriptionLookup["EPSG:4258"]="ETRS89";
  epsgDescriptionLookup["EPSG:4326"]="World Lat lon WGS84";epsgDescriptionLookup["CRS:84"]="World Lat lon WGS84";epsgDescriptionLookup["EPSG:25831"]="ETRS89 / UTM zone 31N";epsgDescriptionLookup["EPSG:25832"]="ETRS89 / UTM zone 32N";epsgDescriptionLookup["EPSG:28992"]="Dutch Amersfoort / RD New";epsgDescriptionLookup["EPSG:32661"]="Polar Stereographic WGS 84 / UPS North";$.widget("ui.iconbutton",$.extend({},$.ui.button.prototype,{_init:function(){$.ui.button.prototype._init.call(this);this.element.removeClass("ui-corner-all").addClass("ui-iconbutton").unbind(".button")}}));var WMJSTileRenderer=function(a,d,c,l,b,f,m,k,t){if(t){"streetmap"===t&&(t="OSM");"pdok"===t&&(t="OSM");"naturalearth2"===t&&(t="NaturalEarth2");var e=k[t];if(e){var n=e[c];if(!n)for(var D in k)if(k.hasOwnProperty(D))for(var E in k[D])k[D].hasOwnProperty(E)&&E===c&&(n=k[D][E]);k=Math.PI;var v=256,z=12756274*k/v,q=-12756274*k/2,I=12756274*k/2;n.tileSize&&(v=n.tileSize);n.resolution&&(z=n.resolution);n.origX&&(q=n.origX);n.origY&&(I=n.origY);k=z*v+q;var C=I-z*v,T=k-q,g=I-C;(function(e){var k=n.home,
  t=n.tileServerType,D=n.tms||!1;e<n.minLevel&&(e=n.minLevel);e>n.maxLevel&&(e=n.maxLevel);var E=Math.pow(2,e),K=T/(z/E*v),N=g/(z/E*v),E=parseInt(Math.round((a.left-q)/T*K/1+.5)),r=parseInt(Math.round((a.right-q)/T*K/1+.5)),A=parseInt(Math.round(N-(a.bottom-C)/g*N+.5)),O=parseInt(Math.round(N-(a.top-C)/g*N+.5)),sa=function(a,b,c){a=z/Math.pow(2,a);return{x:b*a+q,y:I-c*a}},V=function(a,b,c,d){d=d*(a.y-b.top)/(b.bottom-b.top);return{x:parseFloat(c*(a.x-b.left)/(b.right-b.left)),y:parseFloat(d)}},P=function(a,
  c,e,f){var g=sa(c,e*v,f*v);var n=sa(c,(e+1)*v,(f+1)*v);var q=g.x;var z=g.y;g=n.x;n=n.y;q=V({x:q,y:z},d,l,b);g=V({x:g,y:n},d,l,b);var E;"osm"===t&&(E=D?k+c+"/"+e+"/"+(N-1-f)+".png":k+c+"/"+e+"/"+f+".png");if("arcgisonline"===t||"wmst"===t)E=k+c+"/"+f+"/"+e;c=m.getImage(E);!1===c.isLoaded()&&!1===c.hasError()&&!1===c.isLoading()&&c.load();if(c.isLoaded())try{a.drawImage(c.getElement()[0],parseInt(q.x),parseInt(q.y),parseInt(g.x-q.x)+1,parseInt(g.y-q.y)+1)}catch(ba){}};if("EPSG:4326"===c||"EPSG:4258"===
  c)K*=2;1>O&&(O=1);O>N&&(O=N);1>E&&(E=1);E>K&&(E=K);1>A&&(A=1);A>N&&(A=N);1>r&&(r=1);r>K&&(r=K);if(20<A-O)console.error("Too many tiles in vertical",A-O);else if(20<r-E)console.error("Too many tiles in horizontal",A-O);else for(K=O-1;K<A;K++)for(O=E-1;O<r;O++)P(f,e,O,K)})(parseInt(Math.log(Math.abs(k-q)/((a.right-a.left)/l*v))/Math.log(2)+.5))}else console.error("Tiled layer with name "+t+" not found")}else console.error("layerName not defined")};var WMJSImageStore=function(a,d,c){this.imagesbysrc={};var l=this.imageLife=0,b=this,f=[],m=function(a,b){for(b=0;b<f.length;b++)f[b](a)};b.getImageForSrc=function(a){if(b.imagesbysrc[a])return b.imagesbysrc[a]};b.clear=function(){for(var a in b.imagesbysrc)b.imagesbysrc.hasOwnProperty(a)&&b.imagesbysrc[a].clear()};b.addLoadEventCallback=function(a){f.push(a)};b.getNumImagesLoading=function(){var a=0,c;for(c in b.imagesbysrc)b.imagesbysrc.hasOwnProperty(c)&&b.imagesbysrc[c].isLoading()&&a++;return a};
  b.getImage=function(f){var k=b.getImageForSrc(f);if(void 0!==k)return k.imageLife=l++,k;k=b.imagesbysrc;if(Object.keys)var e=Object.keys(k);else{var n=[];for(e in k)Object.prototype.hasOwnProperty.call(k,e)&&n.push(e);e=n}if(e.length<a)k=new WMJSImage(f,m,d,c);else{e=-1;var k=l,D;for(D in b.imagesbysrc)b.imagesbysrc.hasOwnProperty(D)&&(n=b.imagesbysrc[D],!1===n.isLoading()&&!0===n.isLoaded()&&k>=n.imageLife&&(k=n.imageLife,e=D));console.log("Reusing image "+e+" with lifetime "+k);if(-1===e){console.error("not enough cache for "+
  d);return}k=b.imagesbysrc[e];delete b.imagesbysrc[e];k.clear()}k.setSource(f);k.KVP=WMJSKVP(f);b.imagesbysrc[f]=k;k.imageLife=l++;return k}};var WebMapJSMapNo=0,WebMapJSMapVersion="3.0.4",logging=!1,base="./",noimage,showDialog=!0,loadingImageSrc,WMSControlsImageSrc,mapPinImageSrc,scaleBarURL,enableConsoleDebugging=!1,enableConsoleErrors=!1,debug=function(a){enableConsoleDebugging&&console.log(a)},error=function(a){enableConsoleErrors&&console.log("WebMapJS warning: ",a)},WMJScheckURL=function(a){if(!isDefined(a))return"?";a=a.trim();-1==a.indexOf("?")&&(a+="?");return a};
  function WMJSProjection(){this.bbox=new WMJSBBOX;this.srs="EPSG:4326"}var legendImageStore,getMapImageStore,bgMapImageStore,maxAnimationSteps=1E3;legendImageStore=new WMJSImageStore(5*maxAnimationSteps,"wmjslegendbuffer");getMapImageStore=new WMJSImageStore(5*maxAnimationSteps,"wmjsimagebuffer");bgMapImageStore=new WMJSImageStore(5E3,"wmjsimagebuffer",{randomizer:!1});
  var setBaseURL=function(a){base=a;noimage=base+"/img/blank.gif?";loadingImageSrc=base+"/img/ajax-loader.gif";WMSControlsImageSrc=base+"/img/mapcontrols.gif";mapPinImageSrc=base+"/img/dot.gif";isDefined(scaleBarURL)||(scaleBarURL=base+"/php/makeScaleBar.php?");xml2jsonrequestURL=base+"/php/xml2jsonrequest.php?"},showDialogs=function(a){showDialog=a};
  function WMJSMap(a,d){var c,l,b,f;function m(a){function p(ea){ea.currentTarget.removeEventListener("load",p,!1);c(a)}function b(p){(p=(p||event).srcElement)&&/^(complete|loaded)$/i.test(p.readyState)&&(p.detachEvent("onreadystatechange",b),c(a))}function c(a){1!=a.loadEventDone&&(a.loadEventDone=!0,a.loadEvent&&a.loadEvent(a))}a.style.left="0px";a.style.top="0px";a.loadEventDone=!1;a.failed=!1;a.addEventListener?a.addEventListener("load",p,!1):a.attachEvent("onreadystatechange",b);a.onerror=function(){a.src&&
  a.src!=noimage&&(error(a.src),a.failed=!0,a.loadEvent&&a.loadEvent(a))}}function k(a){if(a){for(var p=0;p<q.length;p++)if(q[p]==a)return p;return-1}}function t(){e.mousedown(g.mouseDownEvent);e.mousewheel(g.mouseWheelEvent);attach_event(document,"mouseup",g.mouseUpEvent);attach_event(document,"mousemove",g.mouseMoveEvent);if(g.isTouchDevice()){g.enableInlineGetFeatureInfo(!1);var a=new Hammer.Manager(document.body);a.add(new Hammer.Pan);a.add(new Hammer.Pinch);a.get("pan").set({direction:Hammer.DIRECTION_ALL});
  a.add(new Hammer.Swipe).recognizeWith(a.get("pan"));a.on("panstart",function(a){a.preventDefault();g.mouseDown(a.center.x,a.center.y,a)});a.on("panmove",function(a){a.preventDefault();g.mouseMove(a.center.x,a.center.y,a)});a.on("panend",function(a){a.preventDefault();g.mouseUp(a.center.x,a.center.y,a)});a.on("pinchstart",function(a){a.preventDefault();g.pinchStart(a.center.x,a.center.y,a)});a.on("pinchmove",function(a){a.preventDefault();g.pinchMove(a.center.x,a.center.y,a)});a.on("pinchend",function(a){a.preventDefault();
  g.pinchEnd(a.center.x,a.center.y,a)})}g.setMapModePan()}this.setBaseURL=function(a){base=a;noimage=base+"/img/blank.gif?";loadingImageSrc=base+"/img/ajax-loader.gif";WMSControlsImageSrc=base+"/img/mapcontrols.gif";mapPinImageSrc=base+"/img/dot.gif";isDefined(scaleBarURL)||(scaleBarURL=base+"/php/makeScaleBar.php?")};this.showDialogs=function(a){showDialog=a};this.setBaseURL(base);this.setXML2JSONURL=function(a){xml2jsonrequest=a};this.setWMJSTileRendererTileSettings=function(a){tileRenderSettings=
  a};try{isDefined(d)&&(xml2jsonrequestURL=d)}catch(p){xml2jsonrequestURL=base+"/php/xml2jsonrequest.php?"}try{isDefined(requestProxy)}catch(p){requestProxy=base+"/php/MakeRequest.php?"}try{isDefined(scaleBarURL)}catch(p){scaleBarURL=base+"/php/makeScaleBar.php?"}var e,n,D=new WMJSBBOX,E=new WMJSBBOX,v=2,z=2,q=[],I=[],C="",T=0,g=this;g.renderer="WMJSCanvasBuffer";var da=!1,ka=!1,F=document.createElement("div"),u=document.createElement("div"),w=document.createElement("div"),K=document.createElement("div"),
  N=!0,r=new WMJSBBOX,A=new WMJSBBOX,O=new WMJSBBOX,sa=new WMJSBBOX,V=new WMJSBBOX,P=[];g.getLegendStore=function(){return legendImageStore};var J=[],ra=!1,ab="default",Ea=!1,Na="default",bb=!1,cb=!1,Oa=$('<div class="WMJSDivBuffer-loading"/>',{}),db=0,ba=0,fa=1,Ga,ta=0,W=0,Pa=0,Qa=0,Y=Array(3),Ra=Array(3);for(j=0;3>j;j++)Y[j]=new WMJSProjection,Ra[j]=new WMJSProjection;var eb=!0,B=new WMJSListener;this.getGraphingData=function(){return this.graphingData};this.setGraphingData=function(a){this.graphingData=
  a};var Ha=function(p){a.id||(a.id="WebMapJSMapNo_"+WebMapJSMapNo);!1===ka&&(ka=!0,WebMapJSMapNo++);return a.id+"_"+p};this.enableInlineGetFeatureInfo=function(a){eb=a};this.closeAllGFIDialogs=function(){WMJSDialog.closeAllDialogs(U)};var U=[],fb=function(){enableConsoleDebugging&&console.log("onlegendready called");ga()},ua=[],Ia=0,va=!1,ga=function(a){if(!(2>P.length)){try{0==isDefined(a)&&(a=!1);if(1==va&&isDefined(fb)){1==B.addToCallback("onlegendready",fb)&&enableConsoleDebugging&&console.log("Suspending on onlegendready");
  return}va=!0;if(1==N){if(ua.length!=q.length)a=!0;else for(var p=0;p<q.length;p++){var b=g.getLegendGraphicURLForLayer(q[p]);isDefined(b)&&ua[p]!==b&&(ua[p]=b,a=!0)}if(a){ua=[];for(p=0;p<q.length;p++)!1!==q[p].enabled&&(b=g.getLegendGraphicURLForLayer(q[p]),isDefined(b)&&(ua[p]=b,P[Ia].setSrc(p,b)));var c=Ia;Ia=1-Ia;try{P[c].load(function(){enableConsoleDebugging&&console.log("Legend buffer nr"+c);try{for(var a=0,p=0;p<P[c].layers.length;p++){P[c].layers[p].getElement();var b=P[c].layers[p].getElement()[0].height;
  a<b&&(a=b)}P[c].display();P[1-c].hide()}catch(rb){console.error(rb)}va=!1;B.triggerEvent("onlegendready")})}catch(la){console.error(la),P[0].hide(),P[1].hide(),va=!1,B.triggerEvent("onlegendready")}return}}else P[0].hide(),P[1].hide()}catch(la){console.log(la)}va=!1;B.triggerEvent("onlegendready")}},Ta="",Ua="";this.setMessage=function(a){Ua=a&&""!==a?a:""};this.setTimeOffset=function(a){Ta=a&&""!==a?a:""};this.canvasErrors=[];this.getCapabilitiesJSON=function(a,b){WMJSGetCapabilities(a,!0,b,function(a){error(a);
  b(a)})};this.rebuildMapDimensions=function(){for(var a=0;a<I.length;a++)I[a].used=!1;for(i=0;i<q.length;i++)for(a=0;a<q[i].dimensions.length;a++){var b=q[i].dimensions[a],c=g.getDimension(b.name);isDefined(c)?c.used=!0:(b=b.clone(),b.used=!0,I.push(b))}for(a=0;a<I.length;a++)0==I[a].used&&(I.splice(a,1),a--);B.triggerEvent("onmapdimupdate")};this.getLayerByServiceAndName=function(a,b){for(var p=0;p<q.length;p++){var c=q[q.length-p-1];if(c.name==b&&c.service==a)return c}};this.getLayers=function(){for(var a=
  [],b=0;b<q.length;b++)a.push(q[q.length-b-1]);return a};this.setLayer=function(a,b){return g.addLayer(a,b,a)};this.setActive=function(a){bb=a;cb=!0};this.setActiveLayer=function(a){Ga=a;ga();B.triggerEvent("onchangeactivelayer")};this.calculateNumBaseLayers=function(){T=0;if(C)for(var a=0;a<C.length;a++)C[a].enabled&&0==C[a].keepOnTop&&T++};this.enableLayer=function(a){a.enabled=!0;g.calculateNumBaseLayers();g.rebuildMapDimensions();ga(!0)};this.disableLayer=function(a){a.enabled=!1;g.calculateNumBaseLayers();
  g.rebuildMapDimensions();ga(!0)};this.toggleLayer=function(a){a.enabled=1==a.enabled?!1:!0;g.calculateNumBaseLayers();g.rebuildMapDimensions();ga(!0)};this.displayLayer=function(a,b){a.enabled=b;g.calculateNumBaseLayers();g.rebuildMapDimensions();ga(!0)};this.removeAllLayers=function(){for(var a=0;a<q.length;++a)q[a].setAutoUpdate(!1);q=[];I=[];B.triggerEvent("onlayeradd")};this.deleteLayer=function(a){if(!(0>=q.length)){a.setAutoUpdate(!1);a=k(a);if(0<=a){for(var p=a;p<q.length-1;p++)q[p]=q[p+1];
  q.length--;Ga=void 0;0<=a&&a<q.length?(g.rebuildMapDimensions(),g.setActiveLayer(q[a])):0<q.length&&(g.rebuildMapDimensions(),g.setActiveLayer(q[q.length-1]))}B.triggerEvent("onlayerchange");g.rebuildMapDimensions()}};this.moveLayerDown=function(a){var p=k(a);if(0<p){a=q[p-1];var b=q[p];a&&b&&(q[p]=a,q[p-1]=b)}else try{error("moveLayerDown: layer '"+a.name+"' not found.")}catch(Fa){error("moveLayerDown: layer invalid.")}};this.moveLayerUp=function(a){var p=k(a);if(p<q.length-1){a=q[p+1];var b=q[p];
  a&&b&&(q[p]=a,q[p+1]=b)}else try{error("moveLayerUp: layer '"+a.name+"' not found.")}catch(Fa){error("moveLayerUp: layer invalid.")}};this.addLayer=function(a){isDefined(a)&&(a.parentMaps.includes(g)||a.parentMaps.push(g),q.push(a),a.parseLayer(function(a){for(var p=0;p<a.dimensions.length;p++){var b=g.getDimension(a.dimensions[p].name);isDefined(b)&&isDefined(b.currentValue)&&1==a.dimensions[p].linked&&a.dimensions[p].setClosestValue(b.currentValue)}g.rebuildMapDimensions();B.triggerEvent("onlayeradd")},
  void 0,"WMJSLayer::addLayer"))};this.getActiveLayer=function(){return Ga};this.setProjection=function(a,b){g.hideMapPin();a||(a="EPSG:4326");"object"===typeof a&&(b=a.bbox,a=a.srs);a||(a="EPSG:4326");n=a;g.proj4.srs==n&&isDefined(this.proj4.projection)||(g.proj4.projection="GFI:TIME_ELEVATION"===n?new Proj4js.Proj("EPSG:4326"):new Proj4js.Proj(n),g.proj4.srs=n);g.setBBOX(b);E.setBBOX(b);g.updateMouseCursorCoordinates();B.triggerEvent("onsetprojection",[n,r])};this.getBBOX=function(){return A};this.getProjection=
  function(a){return{srs:n,bbox:r}};this.getSize=function(){return{width:v,height:z}};this.getWidth=function(){return v};this.getHeight=function(){return z};this.repositionLegendGraphic=function(a){N?ga(a):(P[0].hide(),P[1].hide())};this.resizeHeight=this.resizeWidth=-1;var Va=!1,sb=new WMJSTimer;this.setSize=function(a,b,c){enableConsoleDebugging&&console.log("setSize",a,b);4>parseInt(a)||4>parseInt(b)||(this.resizeWidth=parseInt(a),this.resizeHeight=parseInt(b),!0===c?g._setSize(g.resizeWidth,g.resizeHeight):
  !1===Va?(Va=!0,g._setSize(g.resizeWidth,g.resizeHeight)):sb.init(200,function(){Va=!1;g._setSize(g.resizeWidth,g.resizeHeight);g.draw("resizeTimer")}))};this._setSize=function(p,b){if(p&&b&&!(4>parseInt(p)||4>parseInt(b))){enableConsoleDebugging&&console.log("setSize("+p+","+b+")");var c=this.getProjection();v=parseInt(p);z=parseInt(b);if(4>v||isNaN(v))v=4;if(4>z||isNaN(z))z=4;c.srs&&c.bbox||(error("this.setSize: Setting default projection (EPSG:4326 with (-180,-90,180,90)"),c.srs="EPSG:4326",c.bbox.left=
  -180,c.bbox.bottom=-90,c.bbox.right=180,c.bbox.top=90,g.setProjection(c.srs,c.bbox));e.css({width:v,height:z});a.style.width=v+"px";a.style.height=z+"px";g.setBBOX(D);g.repositionMapPin();g.showBoundingBox();1<J.length&&(J[0].resize(g.getWidth(),g.getHeight()),J[1].resize(g.getWidth(),g.getHeight()));1<P.length&&(P[0].resize(g.getWidth(),g.getHeight()),P[1].resize(g.getWidth(),g.getHeight()));g.repositionLegendGraphic(!0);J[fa]&&J[fa].display();B.triggerEvent("onresize",[v,z])}};this.getBBOXandProjString=
  function(a){var p="";if(a.version==WMSVersion.version100||a.version==WMSVersion.version111)p+="SRS="+URLEncode(n)+"&",p+="BBOX="+r.left+","+r.bottom+","+r.right+","+r.top+"&";a.version==WMSVersion.version130&&(p+="CRS="+URLEncode(n)+"&",p="EPSG:4326"==n&&0==a.wms130bboxcompatibilitymode?p+("BBOX="+r.bottom+","+r.left+","+r.top+","+r.right+"&"):p+("BBOX="+r.left+","+r.bottom+","+r.right+","+r.top+"&"));return p};this.isTouchDevice=function(){var a=null;try{a=webMapJSSettings}catch(ea){}return null!==
  a&&!0===a.enableTouchDevice?"undefined"!==typeof window.ontouchstart:!1};this.getDimensionRequestString=function(a){return wa(a)};this.dateToISO8601=function(a){function b(a,b){a+="";b-=a.length;var p,c="";for(p=0;p<b;p++)c+="0"+c;return c+a}return b(a.getUTCFullYear(),4)+"-"+b(a.getUTCMonth()+1,2)+"-"+b(a.getUTCDate(),2)+"T"+b(a.getUTCHours(),2)+":"+b(a.getUTCMinutes(),2)+":"+b(a.getUTCSeconds(),2)+"Z"};this.buildWMSGetMapRequest=function(a){if(isDefined(a.name)&&(a.format||(a.format="image/png",
  error("layer format missing!")),!(1>a.name.length))){if("GFI:TIME_ELEVATION"==n){var b=a.getmapURL;b+="&SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION="+a.version;b+="&LAYERS="+URLEncode(a.name);var p=a.name.split(",");b+="&QUERY_LAYERS="+URLEncode(p[p.length-1]);b+="&BBOX=29109.947643979103,6500000,1190890.052356021,7200000";if(a.version==WMSVersion.version100||a.version==WMSVersion.version111)b+="&SRS="+URLEncode("EPSG:3857")+"&";a.version==WMSVersion.version130&&(b+="&CRS="+URLEncode("EPSG:3857")+
  "&");b+="WIDTH="+v;b+="&HEIGHT="+z;if(a.version==WMSVersion.version100||a.version==WMSVersion.version111)b+="&X=707&Y=557";a.version==WMSVersion.version130&&(b+="&I=707&J=557");b+="&FORMAT=image/gif&INFO_FORMAT=image/png&STYLES=";a=g.dateToISO8601(new Date(r.left));p=g.dateToISO8601(new Date(r.right));return b=b+("&time="+a+"/"+p)+("&elevation="+r.bottom+"/"+r.top)}b=a.getmapURL;b+="&SERVICE=WMS&";b+="VERSION="+a.version+"&";b+="REQUEST=GetMap&";b+="LAYERS="+URLEncode(a.name)+"&";b+="WIDTH="+v+"&";
  b+="HEIGHT="+z+"&";b+=g.getBBOXandProjString(a);b+="STYLES="+URLEncode(a.currentStyle)+"&";b+="FORMAT="+a.format+"&";b=!0===a.transparent?b+"TRANSPARENT=TRUE&":b+"TRANSPARENT=FALSE&";try{b+=wa(a)}catch(Fa){return}return b+=a.wmsextensions.url}};this.abort=function(){B.triggerEvent("onmapready");da=!1;B.triggerEvent("onloadingcomplete")};this.isBusy=function(){return da||0==J[0].ready||0==J[1].ready?!0:!1};this.getLegendGraphicURLForLayer=function(a){if(a){var b=a.legendGraphic;if(b){b+="&layers="+
  URLEncode(a.name)+"&";try{1==a.legendIsDimensionDependant&&(b+=g.getDimensionRequestString(a)+"&")}catch(ma){return}return b=b+"&transparent=true&width=90&height=250&"+a.wmsextensions.url}}};var Wa=!0;this.showScaleBar=function(){Wa=!0;console.log("todo showScaleBar")};this.hideScaleBar=function(){Wa=!1;console.log("todo hideScaleBar")};this.getMaxNumberOfAnimations=function(){return maxAnimationSteps};this.drawLastTimes=function(a,b){b||(b="hours");if(0!==q.length){var p=this.getActiveLayer();if(p&&
  (p=p.getDimension("time"))){var c=p.size()-1,d=[],e=moment.utc(p.getValueForIndex(c));for(a=e.subtract(a,b);0<=c;){e=p.getValueForIndex(c--);if(!e||e===WMJSDateTooEarlyString||a.isAfter(moment.utc(e)))break;d.unshift({name:"time",value:e})}this.draw(d)}}};this.drawAutomatic=function(a,b){if(0!==q.length){a=a.format("YYYY-MM-DDTHH:mm:ss");for(var p=[],c=0;moment(a)<b&&1E3>c;){c++;for(var d=null,e=q.length-1;0<=e;e--){var ea=q[e].getDimension("time");ea&&(ea=ea.getNextClosestValue(a))&&"date too early"!==
  ea&&(null===d||moment(ea)<moment(d))&&(d=ea)}if(null===d)break;p.push({name:"time",value:d});a=d}if(0<p.length)p.pop(),this.draw(p);else if(b=q[0].getDimension("time")){a=b.size();c=Math.min(b.size(),100);p=[];for(c=a-c;c<a;++c)p.push({name:b.name,value:b.getValueForIndex(c)});this.draw(p)}}};new WMJSDebouncer;this.display=function(){J[fa].display(A,O);enableConsoleDebugging&&console.log("drawnBBOX.setBBOX(bbox)");V.setBBOX(r)};this.draw=function(a){g.isAnimating?enableConsoleDebugging&&console.log("ANIMATING: Skipping draw:"+
  a):g._draw(a)};this._draw=function(a){enableConsoleDebugging&&console.log("draw:"+a);enableConsoleDebugging&&console.log("drawnBBOX.setBBOX(bbox)");V.setBBOX(r);a:if(!(4>v||4>z)){B.triggerEvent("beforedraw");if(!1===g.isAnimating&&void 0!==a&&"object"===typeof a&&0<a.length){if(a.length>maxAnimationSteps){alert("Too many animations given, max is "+maxAnimationSteps);g.draw("self");break a}g.isAnimating=!0;B.triggerEvent("onstartanimation",g);g.currentAnimationStep=0;g.animationList=[];g.mouseHoverAnimationBox=
  !1;for(var b=0;b<a.length;b++){var c={name:a[b].name,value:a[b].value};g.setDimension(a[b].name,a[b].value,!1);c.requests=g.getWMSRequests();g.animationList.push(c)}g.setDimension(g.animationList[g.currentAnimationStep].name,g.animationList[g.currentAnimationStep].value,!1);gb.checkAnimation()}4>v||4>z?console.log("map too small, skipping"):g._pdraw()}};var tb=function(){debug("--\x3e onmapready event called");g.draw("onmapready callback")};this.getWMSRequests=function(){var a=[],b=g.getNumLayers();
  for(j=0;j<b;j++)if(q[j].service&&q[j].enabled){var c=g.buildWMSGetMapRequest(q[j]);c&&a.push(c)}return a};this.prefetch=function(a){var b=[];for(j=0;j<a.length;j++){var c=getMapImageStore.getImage(a[j]);0==c.isLoaded()&&0==c.isLoading()&&(b.push(c),c.load())}return b};this.getImageStore=function(){return getMapImageStore};this.isThisRequestLoaded=function(a){a=getMapImageStore.getImageForSrc(a);if(void 0==a)return 0;if(a.isLoaded())return 2;if(a.isLoading())return 1};this.mouseHoverAnimationBox=!1;
  this._pdraw=function(){if(0!=db)if(da)1==B.addToCallback("onmapready",tb)&&debug("Suspending on onmapready");else{enableConsoleDebugging&&console.log("loadLayers");var a,b=0;T=0;if(C)for(var c=0;c<C.length;c++)C[c].enabled&&!1===C[c].keepOnTop&&(!C[c].type||"twms"!==C[c].type)&&(T++,a=g.buildWMSGetMapRequest(C[c]))&&(J[ba].setSrc(b,a,g.getWidth(),g.getHeight(),{layer:C[c]}),J[ba].setOpacity(b,C[c].opacity),b++);for(c=0;c<g.getNumLayers();c++)q[c].service&&q[c].enabled&&(a=g.buildWMSGetMapRequest(q[c],
  q[c].dimensions))&&(J[ba].setSrc(b,a,g.getWidth(),g.getHeight(),{layer:q[c]}),J[ba].setOpacity(b,q[c].opacity),q[c].image=J[ba].layers[b],b++);if(C)for(c=0;c<C.length;c++)C[c].enabled&&1==C[c].keepOnTop&&(a=g.buildWMSGetMapRequest(C[c]))&&(J[ba].setSrc(b,a,g.getWidth(),g.getHeight(),{layer:C[c]}),J[ba].setOpacity(b,C[c].opacity),b++);g.flipBuffers();B.triggerEvent("ondrawready",g);ga()}};var gb,na=function(a){if(0!=J.length){var b=r;isDefined(a)&&(b=a);A.copy(b);J[fa].setBBOX(A,O);J[fa].mapbbox=A;
  g.showBoundingBox(u.bbox,A);B.triggerEvent("onupdatebbox",A);g.repositionMapPin(a)}},hb=new WMJSTimer;g.flipBuffers=function(){enableConsoleDebugging&&console.log("flipBuffers");var a=fa,b=ba;B.triggerEvent("onmapstartloading");da=!0;hb.init(500,function(){Oa.show()});sa.setBBOX(r);J[b]&&J[b].load(function(){enableConsoleDebugging&&console.log("flipBuffers loadcomplete");try{J[a].srs=n,J[b].bbox=r.clone(),J[b].srs=n,enableConsoleDebugging&&console.log("loadedBBOX.setBBOX(bbox)"),O.setBBOX(sa),enableConsoleDebugging&&
  console.log("-----------------------"),J[b].display(A,O),w.oldx=w.exactX,w.oldy=w.exactY,J[a].hide(),fa=b,ba=a}catch(ma){console.log(ma)}da=!1;B.triggerEvent("onmaploadingcomplete",g);B.triggerEvent("onloadingcomplete",g);B.triggerEvent("onmapready",g);Oa.hide();hb.stop()})};g.getBackBufferCanvasContext=function(){return J[ba].getCanvasContext()};g.getFrontBufferCanvasContext=function(){return J[fa].getCanvasContext()};g.redrawBuffer=function(){J[fa].display();enableConsoleDebugging&&console.log("drawnBBOX.setBBOX(bbox)");
  V.setBBOX(r)};this.addBaseLayers=function(a){if(a){T=0;a=toArray(a);C.push(a);for(j=0;j<C.length;j++)1==C.keepOnTop&&T++;B.triggerEvent("onlayeradd")}else C=void 0};this.setBaseLayers=function(a){if(a){T=0;C=a;for(j=0;j<C.length;j++)1==C.keepOnTop&&T++;B.triggerEvent("onlayerchange")}else C=void 0};this.getBaseLayers=function(){return C};this.getNumLayers=function(){return q.length};this.getBaseElement=function(){return e};var xa=0,ya,ib=new WMJSDebouncer,oa=0,za=new WMJSBBOX,ha=new WMJSBBOX,Aa=new WMJSBBOX,
  jb=new WMJSBBOX,ia=0,pa=0,lb=function(){oa=ya/1;var a=1-oa;ha.left=za.left*a+Aa.left*oa;ha.bottom=za.bottom*a+Aa.bottom*oa;ha.right=za.right*a+Aa.right*oa;ha.top=za.top*a+Aa.top*oa;na(ha);ya+=1;1<ya?(ya=1,g.setBBOX(ha),g.display(),0===pa?(ia=pa=0,g.draw("flyZoomToBBOXTimerFunc")):(ia=pa=0,kb(A,jb))):ib.init(10,lb)},kb=function(a,b){1===ia?(jb.copy(b),pa=1):(za.copy(a),Aa.copy(b),ya=1,pa=0,0===ia&&(ia=1,lb()))},mb=new WMJSBBOX,Ba=new WMJSBBOX;this.mouseWheelEvent=function(a,b,c,d){a.stopPropagation();
  preventdefault_event(a);if(1!=xa){xa=1;var p=A.right-A.left,e=A.bottom-A.top;a=g.getGeoCoordFromPixelCoord({x:G,y:H},V);d=(a.x-A.left)/p;c=(a.y-A.top)/e;if(0>b){p*=-.15;var f=-.15*e}else p*=.1,f=.1*e;b=A.left+p;e=A.top+f;p=A.right-p;f=A.bottom-f;d=d*(p-b)+b-a.x;a=c*(f-e)+e-a.y;b-=d;p-=d;e-=a;f-=a;mb.copy(A);Ba.left=b;Ba.bottom=f;Ba.right=p;Ba.top=e;xa=0;kb(mb,Ba)}};var Q;this.pinchStart=function(a,d,e){b=e.pointers[0].clientX;f=e.pointers[0].clientY;c=e.pointers[1].clientX;l=e.pointers[1].clientY;
  Q=r.clone();X=0;xa=ca=1};this.pinchMove=function(a,d,e){X=0;pinchMove1={x:e.pointers[0].clientX,y:e.pointers[0].clientY};pinchMove2={x:e.pointers[1].clientX,y:e.pointers[1].clientY};a=pinchMove2.x-pinchMove1.x;d=c-b;e=pinchMove2.y-pinchMove1.y;var p=l-f;0==d&&(d=1);0==p&&(p=1);a*a>e*e?(a/=d,d=b-pinchMove1.x/a,r.right=((v-pinchMove1.x)/a+b)/v*(Q.right-Q.left)+Q.left,r.left=d/v*(Q.right-Q.left)+Q.left,a=(Q.right-Q.left)/(Q.top-Q.bottom),d=(r.top+r.bottom)/2,a=(r.left-r.right)/2/a,r.bottom=d+a,r.top=
  d-a):(a=e/p,d=f-pinchMove1.y/a,r.bottom=((z-pinchMove1.y)/a+f)/z*(Q.bottom-Q.top)+Q.top,r.top=d/z*(Q.bottom-Q.top)+Q.top,a=(Q.right-Q.left)/(Q.top-Q.bottom),d=(r.right+r.left)/2,a*=(r.bottom-r.top)/2,r.left=d+a,r.right=d-a);na(r)};this.pinchEnd=function(a,b,c){xa=ca=X=0;g.zoomTo(r);g.draw("pinchEnd")};g.destroy=function(){g.stopAnimating();for(var a=q.length-1;0<=a;a--)q[a].setAutoUpdate(!1);console.log("Detaching...");e.off("mousedown");e.off("mousewheel");del_event(document,"mouseup",g.mouseUpEvent);
  del_event(document,"mousemove",g.mouseMoveEvent)};var nb=function(a){return"TIME"==a.toUpperCase()||"ELEVATION"==a.toUpperCase()?a:"DIM_"+a},wa=function(a){for(var b="",c=0;c<a.dimensions.length;c++){var p=a.dimensions[c].getValue(),b=b+("&"+nb(a.dimensions[c].name)),b=b+("="+URLEncode(p));if(p==WMJSDateOutSideRange||p==WMJSDateTooEarlyString||p==WMJSDateTooLateString)throw WMJSDateOutSideRange;}return b},G=0,H=0,L=-1E4,M=-1E4,Z=1E4,aa=1E4,ca=0,X=0,R="pan";this.getMapMode=function(){return R};this.getWMSMetaDataRequestURL=
  function(a){var b=a.service,b=b+("&SERVICE=WMS&REQUEST=GetMetaData&VERSION="+a.version),b=b+("&LAYER="+URLEncode(a.name)),b=b+"&FORMAT=text/html";try{b+="&"+wa(a)}catch(ma){return}debug("<a target='_blank' href='"+b+"'>"+b+"</a>",!1);return b};var ja=0,Xa=[],Ya=function(a,b){this.layer=a;this.data=b},ub=function(a,b,c,d,e){d=d+("&GRAPHSTYLE="+e)+("&"+g.getBBOXandProjString(a));d+="&LAYERS="+URLEncode(a.name);d+="WIDTH="+v;d+="&HEIGHT="+z;d+="&X="+b;d+="&Y="+c;d+="&FORMAT=image/png";d+="&INFO_FORMAT=text/html";
  d+="&STYLES=";try{d+="&"+wa(a)}catch(Sa){return}debug("<a target='_blank' href='"+d+"'>"+d+"</a>",!1);return d};this.getWMSGetFeatureInfoRequestURL=function(a,b,c,d){d=void 0===d?"text/html":d;var p=WMJScheckURL(a.service),p=p+("&SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION="+a.version),p=p+("&LAYERS="+URLEncode(a.name)),e=a.name.split(","),p=p+("&QUERY_LAYERS="+URLEncode(e[e.length-1])),p=p+("&"+g.getBBOXandProjString(a)),p=p+("WIDTH="+v),p=p+("&HEIGHT="+z);if(a.version==WMSVersion.version100||a.version==
  WMSVersion.version111)p=p+("&X="+b)+("&Y="+c);a.version==WMSVersion.version130&&(p=p+("&I="+b)+("&J="+c));p=p+"&FORMAT=image/gif"+("&INFO_FORMAT="+d)+"&STYLES=";try{p+="&"+wa(a)}catch(xb){return}debug("<a target='_blank' href='"+p+"'>"+p+"</a>",!1);return p};var Ja=function(a,b){ja--;a=b?1==b.queryable?new Ya(b,a):new Ya(b,"not queryable"):new Ya(b,"Query failed...");Xa.push(a);0>=ja&&(ja=0,B.triggerEvent("ongetfeatureinfoready",Xa))},vb=function(){debug("resuming on ongetpointinfoready");g.getPointInfo(L,
  M)},Ka=!1;this.getPointInfo=function(a,b){if(Ka)debug("suspending on ongetpointinfoready"),g.addListener("ongetpointinfoready",vb,!1);else{Ka=!0;B.triggerEvent("beforegetpointinfo",{x:a,y:b});var c=g.getGraphingData();if(void 0==c)error("getPointInfo getGraphingData is undefined"),Ka=!1;else{debug("getPointInfo("+a+","+b+") "+c.layer.name);var d=ub(c.layer,a,b,c.service,c.style);debug("GetPointInfo: "+d);var p=new Image;p.loadEvent=function(){Ka=!1;var a={};a.url=d;a.layer=c.layer;a.img=p;B.triggerEvent("ongetpointinfoready",
  a)};m(p);p.src=d}}};var wb=function(){debug("resuming on ongetfeatureinfoready");B.triggerEvent("beforegetfeatureinfo");g.getFeatureInfo(L,M)};this.getFeatureInfo=function(a,b){if(0<ja)debug("suspending on ongetfeatureinfoready"),g.addListener("ongetfeatureinfoready",wb,!1);else{debug("GetFeatureInfo:");Xa=[];for(var c=ja=0;c<q.length;c++){var d=q[q.length-c-1];d.getFeatureInfoUrl="";d.service&&d.enabled&&1==d.queryable&&(d.getFeatureInfoUrl=g.getWMSGetFeatureInfoRequestURL(d,a,b),isDefined(d.getFeatureInfoUrl)?
  ja++:d.getFeatureInfoUrl="")}0==ja&&B.triggerEvent("ongetfeatureinfoready",["No layers to query"]);for(c=0;c<q.length;c++)if(a=q[q.length-c-1],""!=a.getFeatureInfoUrl)if(0==a.queryable)Ja("Layer is not queryable.",a);else try{MakeHTTPRequest(a.getFeatureInfoUrl,Ja,function(a,b){Ja(a,b);error(a)},a)}catch(la){Ja("Exception: "+la,a)}}};this.getGetFeatureInfoObjectAsHTML=function(a){var b="";try{for(var b=b+'<div class="getfeatureinfo">',c=0;c<q.length;c++)for(var d=0;d<a.length;d++)a[d].layer==q[c]&&
  (b+='<div class="getfeatureinfolayer">',b+="<b><a target='_blank' href='"+a[d].layer.getFeatureInfoUrl+"'>"+a[d].layer.title+"</a></b><br/>",b+=a[d].data,b+="</div>");b+="</div>"}catch(la){b="No layers to query."}return b};this.getMapPinXY=function(){return[w.exactX,w.exactY]};this.positionMapPinByLatLon=function(a){debug("positionMapPinByLatLon at "+a.x+","+a.y);a=g.getPixelCoordFromLatLong(a);g.setMapPin(a.x,a.y);g.showMapPin()};this.repositionMapPin=function(a){var b=r;isDefined(a)&&(b=a);a=g.getPixelCoordFromGeoCoord({x:w.geoPosX,
  y:w.geoPosY},b);g.setMapPin(a.x,a.y,b)};this.setMapPin=function(a,b,c){var d=a;"object"===typeof a&&(d=a.x,b=a.y);d&&b&&(w.x=parseInt(d),w.y=parseInt(b),w.exactX=parseFloat(d),w.exactY=parseFloat(b),a=g.getGeoCoordFromPixelCoord({x:w.exactX,y:w.exactY},c),w.geoPosX=a.x,w.geoPosY=a.y,w.style.left=w.x-5+"px",w.style.top=w.y-7+"px")};this.isMapPinVisible=function(){return"none"==w.style.display?!1:!0};this.showMapPin=function(){w.innerHTML="<img src='"+mapPinImageSrc+"'>";w.style.display=""};this.hideMapPin=
  function(){w.style.display="none"};this.setMapModeGetInfo=function(){R="info";e.css("cursor","default")};this.setMapModeZoomBoxIn=function(a){R="zoom";e.css("cursor","default")};this.setMapModeZoomOut=function(a){R="zoomout";e.css("cursor","default")};this.setMapModePan=function(a){R="pan";e.css("cursor","default")};this.setMapModePoint=function(a,b){R="point";e.css("cursor","url(webmapjs/img/aero_pen.cur), default")};var Ca;this.setMapModeNone=function(a){R="none";e.css("cursor","default")};this.getMouseCoordinatesForDocument=
  function(b){if(isDefined(b.changedTouches))return{x:parseInt(b.changedTouches[0].screenX),y:parseInt(b.changedTouches[0].screenY)};var c=$(a).parent().offset(),d=b.pageX,e=b.pageY;void 0==d&&(d=getClick_X(b));void 0==e&&(e=getClick_Y(b));return{x:d-c.left,y:e-c.top}};this.getMouseCoordinatesForElement=function(b){if(isDefined(b.changedTouches))return{x:parseInt(b.changedTouches[0].screenX),y:parseInt(b.changedTouches[0].screenY)};var c=$(a).parent().offset(),d=b.pageX,e=b.pageY;void 0==d&&(d=getClick_X(b));
  void 0==e&&(e=getClick_Y(b));return{x:d-c.left,y:e-c.top}};this.mouseDown=function(a,b,c){function d(a){a=a||window.event;return"buttons"in a?1==a.buttons:1==(a.which||a.button)}var e=!1;c&&1==c.shiftKey&&(e=!0);L=a;M=b;X=1;if(0===ca&&0===(0>M|0>L|L>v|M>z?-1:0))for(a=B.triggerEvent("beforemousedown",{mouseX:a,mouseY:b,mouseDown:!0,event:c,leftButton:d(c),shiftKey:e}),b=0;b<a.length;b++)if(!1===a[b])return;e?(void 0==Ca&&(Ca=R),R="zoom"):void 0!=Ca&&(R=Ca,Ca=void 0);B.triggerEvent("mousedown",{map:g,
  x:L,y:M});"info"==R?(debug("GetFeatureInfo"),g.setMapPin(L,M),g.showMapPin(),B.triggerEvent("beforegetfeatureinfo",{map:g,x:L,y:M}),g.getFeatureInfo(L,M)):"point"==R&&(g.setMapPin(L,M),g.showMapPin(),g.getPointInfo(L,M))};var ob=!1,S=!1,La,Za;this.updateMouseCursorCoordinates=function(a){Za=a;La=g.getGeoCoordFromPixelCoord(a);g.display("updateMouseCursorCoordinates")};this.mouseDownEvent=function(a){preventdefault_event(a);var b=g.getMouseCoordinatesForDocument(a);ra&&0>b.y||g.mouseDown(b.x,b.y,a)};
  this.mouseMoveEvent=function(a){preventdefault_event(a);var b=g.getMouseCoordinatesForDocument(a);0===X&&0<=b.y&&0>b.y&&0<=b.x&&b.x<=v?!1===ra&&(ra=!0,ab=Na,Ea=!0,g.setCursor("pointer"),g.draw("mouseMoveEvent")):!0===ra&&(Ea=ra=!1,g.setCursor(ab),g.draw("mouseMoveEvent"));g.mouseMove(b.x,b.y,a)};this.mouseUpEvent=function(a){preventdefault_event(a);var b=g.getMouseCoordinatesForDocument(a);g.mouseUp(b.x,b.y,a)};this.mouseMove=function(b,c){G=b;H=c;if(0===ca)for(b=B.triggerEvent("beforemousemove",
  {mouseX:G,mouseY:H,mouseDown:1===X?!0:!1}),c=0;c<b.length;c++)if(!1===b[c])return;if(1==u.displayed&&0==qa){b=g.getPixelCoordFromGeoCoord({x:u.bbox.left,y:u.bbox.top});c=g.getPixelCoordFromGeoCoord({x:u.bbox.right,y:u.bbox.bottom});var d=!1;0==X&&(!1===S&&(ob=e.css("cursor")),6>Math.abs(G-b.x)&&H>b.y&&H<c.y&&(d=!0,e.css("cursor","col-resize"),S="left"),6>Math.abs(H-b.y)&&G>b.x&&G<c.x&&(d=!0,e.css("cursor","row-resize"),S="top"),6>Math.abs(G-c.x)&&H>b.y&&H<c.y&&(d=!0,e.css("cursor","col-resize"),S=
  "right"),6>Math.abs(H-c.y)&&G>b.x&&G<c.x&&(d=!0,e.css("cursor","row-resize"),S="bottom"),6>Math.abs(G-b.x)&&6>Math.abs(H-b.y)&&(d=!0,e.css("cursor","nw-resize"),S="topleft"),6>Math.abs(G-c.x)&&6>Math.abs(H-b.y)&&(d=!0,e.css("cursor","ne-resize"),S="topright"),6>Math.abs(G-b.x)&&6>Math.abs(H-c.y)&&(d=!0,e.css("cursor","sw-resize"),S="bottomleft"),6>Math.abs(G-c.x)&&6>Math.abs(H-c.y)&&(d=!0,e.css("cursor","se-resize"),S="bottomright"));if(1==d||!1!==S&&1==X){1==X&&("left"==S&&(b.x=G),"top"==S&&(b.y=
  H),"right"==S&&(c.x=G),"bottom"==S&&(c.y=H),"topleft"==S&&(b.x=G,b.y=H),"topright"==S&&(c.x=G,b.y=H),"bottomleft"==S&&(b.x=G,c.y=H),"bottomright"==S&&(c.x=G,c.y=H),b=g.getGeoCoordFromPixelCoord(b),c=g.getGeoCoordFromPixelCoord(c),u.bbox.left=b.x,u.bbox.top=b.y,u.bbox.right=c.x,u.bbox.bottom=c.y,g.showBoundingBox(u.bbox),B.triggerEvent("bboxchanged",{map:g,bbox:u.bbox}));return}S=!1;e.css("cursor",ob)}if(-1==(0>H|0>G|G>v|H>z?-1:0)){try{B.triggerEvent("onmousemove",[void 0,void 0]),g.updateMouseCursorCoordinates(void 0)}catch(Sa){console.log(Sa)}Z=
  G;aa=H;0!=qa&&(1==X&&"zoomout"==R&&g.zoomOut(),X=0,1==ca&&pb(Z,aa))}else{if(1==X&&!(3>Math.abs(L-G)&&3>Math.abs(M-H))){c=G;b=H;if(0==ca){if("pan"==R){ia&&g.setBBOX(ha);ia=pa=0;ib.stop();e.css("cursor","move");var d=parseInt(c),f=parseInt(b);w.oldx=w.exactX;w.oldy=w.exactY;for(var p=0;p<U.length;p++)U[p].origX=U[p].x,U[p].origY=U[p].y;qa=1;enableConsoleDebugging&&console.log("updateBBOX.setBBOX(drawnBBOX)");A.setBBOX(V);Da=g.getGeoCoordFromPixelCoord({x:d,y:f},r)}"zoom"==R&&(e.css("cursor","crosshair"),
  Ma=1);ca=1}"pan"==R&&0!=qa&&(c=parseInt(c),b=parseInt(b),0>G||0>H||G>parseInt(a.clientWidth)||H>parseInt(a.clientHeight)?qb(c,b):(c=g.getGeoCoordFromPixelCoord({x:c,y:b},A),b=c.x-Da.x,c=c.y-Da.y,A.left-=b,A.bottom-=c,A.right-=b,A.top-=c,na(A)));"zoom"==R&&0!=Ma&&(c=G-L,b=H-M,0>c&&0>b?e.css("cursor","not-allowed"):e.css("cursor","crosshair"),h=b,F.style.display="",0>c?(c=-c,F.style.left=G+"px"):F.style.left=L+"px",0>h?(h=-h,F.style.top=H+"px"):F.style.top=M+"px",F.style.width=c+"px",F.style.height=
  h+"px")}B.triggerEvent("onmousemove",[G,H]);g.updateMouseCursorCoordinates({x:G,y:H})}};this.mouseUp=function(a,b,c){Z=a;aa=b;if(0===ca&&0===(0>aa|0>Z|Z>v|aa>z?-1:0))for(a=B.triggerEvent("beforemouseup",{mouseX:a,mouseY:b,mouseDown:!1,event:c}),b=0;b<a.length;b++)if(!1===a[b]){X=0;return}if(1==X){"zoomout"==R&&g.zoomOut();if(0==ca&&3>Math.abs(L-Z)&&3>Math.abs(M-aa))if(isDefined(c)&&B.triggerEvent("mouseclicked",{map:g,x:Z,y:aa,shiftKeyPressed:1==c.shiftKey}),1==eb){if(0==U.length){var d=WMJSDialog.createDialog({show:showDialog,
  x:Z,y:aa,autoDestroy:!1},e,g);U.push(d)}else d=U[0];0==d.hasBeenDragged&&(1==d.moveToMouseCursor?d.setXY(Z,aa):d.setXY(5,45));d.on("hide",function(a,b){d.hasBeenDragged=!1});d.setLoading();d.show();g.addListener("ongetfeatureinfoready",function(a){d.setHTML(g.getGetFeatureInfoObjectAsHTML(a))},!0);g.setMapPin(L,M);g.showMapPin();B.triggerEvent("beforegetfeatureinfo");g.getFeatureInfo(L,M)}else g.setMapPin(L,M),g.showMapPin();B.triggerEvent("mouseup",{map:g,x:Z,y:aa})}X=0;1==ca&&pb(Z,aa)};var pb=function(a,
  b){if(0!=ca){ca=0;"pan"==R&&qb(a,b);if("zoom"==R){b=Z-L;var c=aa-M;e.css("cursor","default");0!=Ma&&(Ma=0,F.style.display="none",0>b&&0>c||(a=new WMJSBBOX,0>b?(a.left=L+b,a.right=L):(a.left=L,a.right=L+b),0>c?(a.top=M+c,a.bottom=M):(a.top=M,a.bottom=M+c),b=g.pixelCoordinatesToXY({x:a.left,y:a.bottom}),c=g.pixelCoordinatesToXY({x:a.right,y:a.top}),a.left=b.x,a.bottom=b.y,a.right=c.x,a.top=c.y,g.zoomTo(a),g.draw("mapZoomEnd")))}B.triggerEvent("mapdragend",{map:g,x:Z,y:aa})}},qa=0,Da,qb=function(a,b){e.css("cursor",
  "default");a=parseInt(a);b=parseInt(b);0!=qa&&(qa=0,a=g.getGeoCoordFromPixelCoord({x:a,y:b},V),b=a.x-Da.x,a=a.y-Da.y,A.left=V.left-b,A.bottom=V.bottom-a,A.right=V.right-b,A.top=V.top-a,na(A),g.zoomTo(A),g.draw("mapPanEnd"))},Ma=0;this.setCursor=function(a){Na=a?a:"default";e.css("cursor",Na)};this.getId=function(){return Ha("webmapjsinstance")};this.zoomTo=function(a){enableConsoleDebugging&&console.log("zoomTo");var b=!1;a=new WMJSBBOX(a);try{var c=(D.left-D.right)/(D.bottom-D.top)}catch(Fa){b=!0}isNaN(c)&&
  (b=!0);1==b&&(error("Invalid bbox: setting ratio to 1"),c=1);0>c&&(c=-c);c>v/z?(b=(a.top+a.bottom)/2,c=(a.left-a.right)/2/c,a.bottom=b+c,a.top=b-c):(b=(a.right+a.left)/2,c*=(a.bottom-a.top)/2,a.left=b+c,a.right=b-c);g.setBBOX(a);na(r);V.setBBOX(r);g.getPixelCoordFromGeoCoord({x:w.geoPosX,y:w.geoPosY});for(a=0;a<U.length;a++)g.getPixelCoordFromGeoCoord({x:U[a].geoPosX,y:U[a].geoPosY}),0==U[a].hasBeenDragged&&1==U[a].moveToMouseCursor&&U[a].setXY(U[a].origX+x,U[a].origY+y)};this.pixelCoordinatesToXY=
  function(a){return g.getGeoCoordFromPixelCoord(a)};this.getGeoCoordFromPixelCoord=function(a,b){var c=r;b&&(c=b);if(isDefined(a)){try{var d=a.x/v*(c.right-c.left)+c.left;var e=a.y/z*(c.bottom-c.top)+c.top}catch(Sa){return}return{x:d,y:e}}};this.proj4={};this.proj4.srs="empty";this.proj4.projection=void 0;var $a=new Proj4js.Proj("EPSG:4326");this.getProj4=function(){if(!n||"GFI:TIME_ELEVATION"===n)return null;g.proj4.srs==n&&isDefined(this.proj4.projection)||(g.proj4.projection=new Proj4js.Proj(n),
  g.proj4.srs=n);return{lonlat:$a,proj4:g.proj4.projection,Proj4js:Proj4js}};this.getPixelCoordFromLatLong=function(a){if(!n||"GFI:TIME_ELEVATION"===n)return a;var b=new Proj4js.Point;try{b.x=parseFloat(a.x),b.y=parseFloat(a.y),g.proj4.srs==n&&isDefined(this.proj4.projection)||(g.proj4.projection=new Proj4js.Proj(n),g.proj4.srs=n),Proj4js.transform($a,g.proj4.projection,b)}catch(ma){alert(debug("error in getPixelCoordFromLatLong "+ma));return}return g.getPixelCoordFromGeoCoord(b)};this.WCJSSearchRequest=
  function(a){console.log(a);a.trim().match(/^(-?(?:[1-8]?\d(?:\.\d+)?|90(?:\.0+)?),-?(?:180(?:\.0+)?|(?:(?:1[0-7]\d)|(?:[1-9]?\d))(?:\.\d+)?))$/)?(splitted=a.split(","),lat=splitted[0],lng=splitted[1],g.calculateBoundingBoxAndZoom(lat,lng)):"undefined"===typeof geoNamesURL&&"undefined"===typeof knmiGeoNamesURL?error(I18n.no_urls_in_config.text):a.trim()?(searchDef=a.trim().match(/^[a-zA-Z0-9 ]*$/))?"undefined"!==typeof knmiGeoNamesURL?(a=knmiGeoNamesURL.replace("{searchTerm}",searchDef),debug(I18n.debug_searching_location.text),
  debug("<a target='_blank' href='"+a+"'>"+a+"</a>",!1),$.ajax({dataType:"jsonp",contentType:"application/jsonp",jsonpCallback:"resultGeo",crossDomain:!0,type:"GET",url:a,success:function(a){if(0===$(a).length){var b=geoNamesURL.replace("{searchTerm}",searchDef).replace("{username}",defaultUsernameSearch);console.log("urlApiGeonames",b);g.WCJSSearchRequestGeoNames(b)}else b=parseFloat($(a)[0].lat),a=parseFloat($(a)[0].lon),g.calculateBoundingBoxAndZoom(b,a)},error:function(a,b,c){error(I18n.geonames_api_call_failed.text)}})):
  (a=geoNamesURL.replace("{searchTerm}",searchDef).replace("{username}",defaultUsernameSearch),console.log("urlApiGeonames",a),g.WCJSSearchRequestGeoNames(a)):(debug(I18n.only_alpha_num_allowed.text),$("#searchtextfield").attr("value","")):(debug(I18n.no_search_definition.text),$("#searchtextfield").attr("value",""))};this.WCJSSearchRequestGeoNames=function(a){debug(I18n.debug_searching_sqlite_location.text);debug("<a target='_blank' href='"+a+"'>"+a+"</a>",!1);$.ajax({dataType:"xml",type:"GET",url:a,
  success:function(a){if("0"===$(a).find("totalResultsCount").text())error(I18n.no_results_search.text);else{var b=parseFloat($(a).find("geoname").find("lat").text());a=parseFloat($(a).find("geoname").find("lng").text());g.calculateBoundingBoxAndZoom(b,a)}},error:function(a,b,c){error(I18n.geonames_sqlite_call_failed.text)}})};this.calculateBoundingBoxAndZoom=function(a,b){var c=5E5;if("EPSG:4326"===g.proj4.projection.srsCode||"EPSG:50001"===g.proj4.projection.srsCode)c=5;var d=g.getPixelCoordFromLatLong({x:b,
  y:a}),d=g.getGeoCoordFromPixelCoord(d),e=new WMJSBBOX;e.left=d.x-c;e.bottom=d.y-c;e.right=d.x+c;e.top=d.y+c;g.zoomTo(e);g.positionMapPinByLatLon({x:b,y:a});g.draw("zoomIn")};this.getLatLongFromPixelCoord=function(a){if(!n||"GFI:TIME_ELEVATION"===n)return a;var b=new Proj4js.Point;try{b.x=a.x/v*(r.right-r.left)+r.left,b.y=a.y/z*(r.bottom-r.top)+r.top,this.proj4.srs!=n&&(this.proj4.projection=new Proj4js.Proj(n),this.proj4.srs=n),Proj4js.transform(this.proj4.projection,$a,b)}catch(ma){return}return{x:b.x,
  y:b.y}};this.getPixelCoordFromGeoCoord=function(a,b,c,d){var e=v,f=z,k=A;isDefined(c)&&(e=c);isDefined(d)&&(f=d);isDefined(b)&&(k=b);b=f*(a.y-k.top)/(k.bottom-k.top);return{x:parseFloat(e*(a.x-k.left)/(k.right-k.left)),y:parseFloat(b)}};this.addListener=function(a,b,c){return B.addToCallback(a,b,c)};this.removeListener=function(a,b){return B.removeEvents(a,b)};this.getListener=function(a){return B};this.suspendEvent=function(a){B.suspendEvent(a)};this.resumeEvent=function(a){B.resumeEvent(a)};this.getDimensionList=
  function(){return I};this.getDimension=function(a){for(var b=0;b<I.length;b++)if(I[b].name==a)return I[b]};this.setDimension=function(a,b,c){debug("WebMapJS::setDimension('"+a+"','"+b+"')");if(isDefined(a)&&isDefined(b)){var d=g.getDimension(a);0==isDefined(d)&&(d={name:a,currentValue:b},I.push(d));isDefined(void 0)&&(void 0).setValue(a,b);if(d.currentValue!=b){d.currentValue=b;if(1==g.buildLayerDimsBusy)alert("b");else for(b=0;b<I.length;b++)for(var d=I[b],e=0;e<q.length;e++)for(var f=0;f<q[e].dimensions.length;f++){var k=
  q[e].dimensions[f];if(1==k.linked&&k.name==d.name){if("current"==d.currentValue||"default"==d.currentValue||""==d.currentValue||"earliest"==d.currentValue||"middle"==d.currentValue||"latest"==d.currentValue)d.currentValue=k.getClosestValue(d.currentValue);g.buildLayerDimsBusy=!0;k.setClosestValue(d.currentValue);g.buildLayerDimsBusy=!1}}!1!==c&&(c=!0);!0===c&&B.triggerEvent("ondimchange",a)}}else error("Unable to set dimension with undefined value or name")};this.setLayerOpacity=function(a,b){if(a){a.opacity=
  b;var c=T;for(j=0;j<g.getNumLayers();j++)if(q[j].service&&q[j].enabled){if(a==q[j]){g.setBufferImageOpacity(ba,c,b);break}c++}}};this.zoomToLayer=function(a){var b=a;b||(b=Ga);if(b){for(var c=0;c<b.projectionProperties.length;c++)if(b.projectionProperties[c].srs==n){a=b.projectionProperties[c].bbox.right-b.projectionProperties[c].bbox.left;var d=b.projectionProperties[c].bbox.top-b.projectionProperties[c].bbox.bottom,b=b.projectionProperties[c].bbox.clone();b.left-=a/100;b.right+=a/100;b.bottom-=
  d/100;b.top+=d/100;g.zoomTo(b);g.draw("zoomTolayer");return}error("Unable to find the correct bbox with current map projection "+n+" for layer "+b.title+". Using default bbox instead.")}g.zoomTo(E);g.draw("zoomTolayer")};this.setPreviousExtent=function(){Pa=1;W++;W>=ta&&(W=ta-1);g.setProjection(Y[W].srs,Y[W].bbox);g.draw("setPreviousExtent")};this.setNextExtent=function(){Qa=1;W--;0>W&&(W=0);g.setProjection(Y[W].srs,Y[W].bbox);g.draw("setNextExtent")};this.setBBOX=function(a,b,c,d){enableConsoleDebugging&&
  console.log("setBBOX");r.setBBOX(a,b,c,d);D.setBBOX(r);if("GFI:TIME_ELEVATION"!==n){var e=v/z;if((r.right-r.left)/(r.top-r.bottom)>e){var f=(r.top+r.bottom)/2,e=(r.left-r.right)/2/e;r.bottom=f+e;r.top=f-e}else f=(r.right+r.left)/2,e*=(r.bottom-r.top)/2,r.left=f+e,r.right=f-e}A.setBBOX(r);V.setBBOX(r);if(0==Qa&&0==Pa){if(0!=W){for(j=0;j<=W;j++)Ra[j]=Y[j];for(j=0;j<=W;j++)Y[j]=Ra[W-j];W=0}for(j=2;0<j;j--)Y[j].bbox.setBBOX(Y[j-1].bbox),Y[j].srs=Y[j-1].srs;Y[0].bbox.setBBOX(r);Y[0].srs=n;ta++;3<ta&&(ta=
  3)}Pa=Qa=0;if(!0===r.equals(a,b,c,d))return!1;B.triggerEvent("aftersetbbox",g);return!0};this.zoomOut=function(){var a=(D.right-D.left)/6;this.zoomTo(new WMJSBBOX(D.left-a,D.bottom-a,D.right+a,D.top+a));g.draw("zoomOut")};this.zoomIn=function(a){var b=(D.left-D.right)/8;if(0==isDefined(a))a=1;else if(0==a)return;b*=a;this.zoomTo(new WMJSBBOX(D.left-b,D.bottom-b,D.right+b,D.top+b));g.draw("zoomIn")};this.searchForLocation=function(a){g.WCJSSearchRequest(a)};this.displayLegendInMap=function(a){N=a;
  g.repositionLegendGraphic()};this.showBoundingBox=function(a,b){isDefined(a)&&(u.bbox=a,u.style.display="",u.displayed=!0);!0===u.displayed&&(a=r,isDefined(b)&&(a=b),b=this.getPixelCoordFromGeoCoord({x:u.bbox.left,y:u.bbox.top},a),a=this.getPixelCoordFromGeoCoord({x:u.bbox.right,y:u.bbox.bottom},a),u.style.left=b.x-1+"px",u.style.top=b.y-2+"px",u.style.width=a.x-b.x+"px",u.style.height=a.y-b.y-1+"px")};this.hideBoundingBox=function(){u.style.display="none";u.displayed=!1};this.setDebugFunction=function(a){debug=
  a};this.setErrorFunction=function(a){error=a};(function(){try{tileRenderSettings=WMJSTileRendererTileSettings}catch(Fa){}a.style.height||(a.style.height="1px");a.style.width||(a.style.width="1px");this.baseDivId=Ha("baseDiv");jQuery("<div/>",{id:this.baseDivId,css:{position:"relative",overflow:"hidden",width:a.clientWidth,height:a.clientHeight,border:"0px  solid black",margin:0,padding:0,clear:"both",left:"0px",top:"0px"}}).appendTo(a);e=$("#"+this.baseDivId);e.css("cursor","default");a.style.margin=
  "0px";a.style.padding="0px";a.style.border="none";a.style.lineHeight="0px";a.style.display="inline-block";F.style.position="absolute";F.style.display="none";F.style.border="2px dashed #000000";F.style.margin="0px";F.style.padding="0px";F.style.lineHeight="0";F.style.background="#AFFFFF";F.style.opacity="0.3";F.style.filter="alpha(opacity=30)";F.style.left="0px";F.style.top="0px";F.style.width="100px";F.style.height="100px";F.style.zIndex=1E3;F.oncontextmenu=function(){return!1};e.append(F);u.style.position=
  "absolute";u.style.display="none";u.style.border="3px solid #6060FF";u.style.margin="0px";u.style.padding="0px";u.style.lineHeight="0";u.style.left="0px";u.style.top="0px";u.style.width="100px";u.style.height="100px";u.style.zIndex=1E3;u.oncontextmenu=function(){return!1};e.append(u);w.style.position="absolute";w.style.display="none";w.style.border="none";w.style.margin="0px";w.style.padding="0px";w.style.lineHeight="0";w.style.background="none";w.style.opacity="1.0";w.style.filter="alpha(opacity=100)";
  w.style.left="0px";w.style.top="0px";w.style.width="100px";w.style.height="100px";w.style.zIndex=1E3;w.oncontextmenu=function(){return!1};w.innerHTML="<img src='"+mapPinImageSrc+"'>";w.style.display="";e.append(w);K.style.position="absolute";K.style.zIndex=1E3;K.style.width="auto";K.style.height="auto";K.style.background="none";K.oncontextmenu=function(){return!1};K.innerHTML="";e.append(K);e.append(Oa);"undefined"!==typeof defaultUsernameSearch&&(jQuery("<div/>",{id:Ha("searchboxdiv"),mousedown:function(a){a.stopPropagation()}}).addClass("webmapjs_searchboxdiv").html("<input class='webmapjs_locationfield' type='text' name='searchtextfield' id='searchtextfield' placeholder="+
  I18n.place_search_term.text+" />",{mousedown:function(a){a.stopPropagation();preventdefault_event(a)}}).appendTo(e),jQuery("<button/>",{id:Ha("searchboxbutton"),mousedown:function(a){a.stopPropagation()},click:function(){var a=$("#searchtextfield").val();g.searchForLocation(a)}}).addClass("webmapjs_locationbutton").appendTo(e),$("#searchtextfield").keypress(function(a){if(13==a.which)return a=$("#searchtextfield").val(),g.searchForLocation(a),!1}));t();r.left=-180;r.bottom=-90;r.right=180;r.top=90;
  n="EPSG:4326";g.setSize(a.clientWidth,a.clientHeight);for(var b=0;2>b;b++){var c=new WMJSCanvasBuffer(B,"imagebuffer",getMapImageStore,g.getWidth(),g.getHeight());getMapImageStore.addLoadEventCallback(c.imageLoadComplete);e.append(c.getBuffer());J.push(c)}for(b=0;2>b;b++)c=new WMJSCanvasBuffer(B,"legendbuffer",legendImageStore,g.getWidth(),g.getHeight()),legendImageStore.addLoadEventCallback(c.imageLoadComplete),e.append(c.getBuffer()),P.push(c);B.addToCallback("display",g.display,!0);B.addToCallback("draw",
  function(){console.log("draw event triggered externally, skipping")},!0);gb=new WMJSAnimate(g);bgMapImageStore.addLoadEventCallback(function(a){g.draw("bgMapImageStore loaded")});g.addListener("beforecanvasstartdraw",function(a){if(C)for(var b=0;b<C.length;b++)!C[b].enabled||!1!==C[b].keepOnTop||C[b].type&&"twms"!==C[b].type||WMJSTileRenderer(r,A,n,v,z,a,bgMapImageStore,tileRenderSettings,C[b].name)},!0);var d=function(a,b,c,d,e){a.textBaseline="top";a.fillStyle="#FFF";a.globalAlpha=.75;var f=a.measureText(b).width;
  a.fillRect(c-8,d-8,f+16,parseInt(e)+14);a.fillStyle="#444";a.globalAlpha=1;a.fillText(b,c,d+2)};g.addListener("beforecanvasdisplay",function(a){cb&&(a.beginPath(),a.rect(0,0,v,0),!1===bb?(a.globalAlpha=Ea?.9:.4,a.fillStyle=Ea?"#017daf":"#EEE"):(a.globalAlpha=1,a.fillStyle="#017daf"),a.fill(),a.globalAlpha=1);for(i=0;i<q.length;i++)for(var b="",c=0;c<q[i].dimensions.length;c++)b+="&"+nb(q[i].dimensions[c].name),b+="="+URLEncode(q[i].dimensions[c].currentValue),q[i].dimensions[c].currentValue==WMJSDateOutSideRange?
  g.canvasErrors.push({linkedInfo:{layer:q[i],message:"Time outside range"}}):q[i].dimensions[c].currentValue==WMJSDateTooEarlyString?g.canvasErrors.push({linkedInfo:{layer:q[i],message:"Time too early"}}):q[i].dimensions[c].currentValue==WMJSDateTooLateString&&g.canvasErrors.push({linkedInfo:{layer:q[i],message:"Time too late"}});if(g.canvasErrors&&0<g.canvasErrors.length){var c=v/2,e=6+15*g.canvasErrors.length,b=v-c;a.beginPath();a.rect(b,0,b+c,0+e);a.fillStyle="white";a.globalAlpha=.9;a.fill();a.globalAlpha=
  1;a.fillStyle="black";a.font="10pt Helvetica";for(c=0;c<g.canvasErrors.length;c++)g.canvasErrors[c].linkedInfo?a.fillText("Layer with title "+g.canvasErrors[c].linkedInfo.layer.title+" failed to load"+(g.canvasErrors[c].linkedInfo.message?", "+g.canvasErrors[c].linkedInfo.message:""),b+5,11+15*c):a.fillText("Layer failed to load.",b+5,11+15*c);g.canvasErrors=[]}""!==Ta&&(a.font="20px Helvetica",d(a,Ta,v/2-70,z-26,20));""!==Ua&&(a.font="15px Helvetica",d(a,Ua,v/2-70,2,15));if(!0===Wa&&(b=function(){var a=
  1E-7,b=v/(A.right-A.left);if(!(0>=b)){var c=25/b;do{a*=10;var d=c/a;if(0===d)return;d=25/d}while(25>d);do{a/=2;d=c/a;if(0===d)return;d=25/d}while(25<d);do{a*=1.2;d=c/a;if(0===d)return;d=25/d}while(25>d);c=Math.pow(10,Math.round(Math.log10(a)+.5)-1);a=Math.round(a/c);2.5>a&&(a=2.5);2.5<a&&7.5>a&&(a=5);7.5<a&&(a=10);a*=c;return{width:parseInt(25/(25/b/a)),mapunits:a}}}())){c=z-25.5;a.beginPath();a.lineWidth=2.5;a.fillStyle="#000";a.strokeStyle="#000";a.font="9px Helvetica";a.textBaseline="middle";for(e=
  0;2>e;e++)a.moveTo(7.5,21-e+c),a.lineTo(2*b.width+8.5,21-e+c);e=parseInt(Math.round(b.width/5));a.lineWidth=.5;for(var f=1;5>f;f++)a.moveTo(7.5+e*f,21+c),a.lineTo(7.5+e*f,16+c);a.lineWidth=1;a.moveTo(7.5,21+c);a.lineTo(7.5,14+c);a.moveTo(7.5+b.width,21+c);a.lineTo(7.5+b.width,14+c);a.moveTo(2*b.width+8.5,21+c);a.lineTo(2*b.width+8.5,14+c);e="";"EPSG:3411"===n&&(e="meter");"EPSG:3412"===n&&(e="meter");"EPSG:3575"===n&&(e="meter");"EPSG:4326"===n&&(e="degrees");"EPSG:28992"===n&&(e="meter");"EPSG:32661"===
  n&&(e="meter");"EPSG:3857"===n&&(e="meter");"EPSG:900913"===n&&(e="meter");"EPSG:102100"===n&&(e="meter");"meter"===e&&1E3<b.mapunits&&(b.mapunits/=1E3,e="km");a.fillText("0",4.5,12+c);f=b.mapunits.toPrecision()+"";a.fillText(f,7.5+b.width-2.5*f.length+0,12+c);f=(2*b.mapunits).toPrecision()+"";a.fillText(f,7.5+2*b.width-2.5*f.length+0,12+c);a.fillText(e,2*b.width+17.5,18+c);a.stroke()}a.font="10px Helvetica";a.textBaseline="middle";isDefined(La)&&(c=1/Math.pow(10,parseInt(Math.log((r.right-r.left)/
  v)/Math.log(10))-2),1>c&&(c=1),a.fillStyle="#000000",b=Math.round(La.x*c)/c,c=Math.round(La.y*c)/c,e="","EPSG:3857"===n&&(e="meter"),a.fillText("CoordYX: ("+c+", "+b+") "+e,5,z-50));isDefined(Za)&&(b=g.getLatLongFromPixelCoord(Za),isDefined(b)&&(a.fillStyle="#000000",c=Math.round(100*b.x)/100,a.fillText("Lat/Lon: ("+(Math.round(100*b.y)/100).toFixed(2)+", "+c.toFixed(2)+")  degrees",5,z-38)));a.fillStyle="#000000";a.fillText("Map projection: "+n,5,z-26);a.font="7px Helvetica";a.fillText("ADAGUC webmapjs "+
  WebMapJSMapVersion,v-85,z-5)},!0);g.addListener("canvasonerror",function(a){g.canvasErrors=a},!0);db=1})();na(r)};function WMJSBBOX(a,d,c,l){this.left=-180;this.bottom=-90;this.right=180;this.top=90;this.clone=function(a){void 0==a&&(a=this);var b=new WMJSBBOX;b.left=a.left;b.bottom=a.bottom;b.right=a.right;b.top=a.top;return b};this.copy=function(a){this.setBBOX(a)};this.setBBOX=function(a,c,d,k){if(void 0===a||null===a)this.left=-180,this.bottom=-90,this.right=180,this.top=90;else{if(!c)if("object"===typeof a){var b=a;void 0===b.length||null===b.length?(a=b.left,c=b.bottom,d=b.right,k=b.top):(a=parseFloat(b[0]),
  c=parseFloat(b[1]),d=parseFloat(b[2]),k=parseFloat(b[3]))}else try{b=a.split(","),4!==b.length&&error("Invalid map bounding box: '"+a+"'"),a=parseFloat(b[0]),c=parseFloat(b[1]),d=parseFloat(b[2]),k=parseFloat(b[3])}catch(e){}if(void 0===a||void 0===c||void 0===d||void 0===k||null===a||null===c||null===d||null===k)void 0==a&&(a=-180),void 0==d&&(d=180),void 0==c&&(c=-90),void 0==k&&(k=90);this.left=a;this.bottom=c;this.right=d;this.top=k}};this.equals=function(b,c,d,k){if(!b)return!1;if(void 0!==c&&
  this.left===b&&this.right===d&&this.top===k&&this.bottom===c)return!0;if("object"===typeof b){if(this.left===b.left&&this.right===b.right&&this.top===b.top&&this.bottom===b.bottom)return!0}else if(k=b.split(","),4!==k.length&&console.log("Invalid map bounding box: "+b),a=parseFloat(k[0]),c=parseFloat(k[1]),d=parseFloat(k[2]),k=parseFloat(k[3]),b=0,this.left===a&&b++,this.right===d&&b++,this.top===k&&b++,this.bottom===c&&b++,2<=b)return!0;return!1};this.toString=function(){return this.left+","+this.bottom+
  ","+this.right+","+this.top};this.setBBOX(a,d,c,l)};var WMJSDateOutSideRange="outside range",WMJSDateTooEarlyString="date too early",WMJSDateTooLateString="date too late";
  function WMJSDimension(a){var d=this;this.timeRangeDuration=this.parentLayer=this.defaultValue=this.currentValue=this.values=this.units=this.name=void 0;this.linked=!0;this.generateAllValues=function(){var a=[];if(5E3<d.size())throw"Error: Dimension too large to query all possible values at once";for(var b=0;b<d.size();b++)a.push(d.getValueForIndex(b));return a};var c=this;isDefined(a)&&(isDefined(a.name)&&(this.name=a.name),isDefined(a.units)&&(this.units=a.units),isDefined(a.values)&&(this.values=
  a.values),isDefined(a.currentValue)&&(this.currentValue=a.currentValue),isDefined(a.defaultValue)&&(this.defaultValue=a.defaultValue),isDefined(a.parentLayer)&&(this.parentLayer=a.parentLayer),isDefined(a.linked)&&(this.linked=a.linked));var l=!1,b,f=[],m,k=[];this.setStartTime=function(a){l||t(this);if(a&&0!==a.length)if(a=parseISO8601DateToDate(a).toISO8601(),"timestartstopres"===m){var b=c.values;a+=b.substring(b.indexOf("/"));c.reInitializeValues(a);c.setClosestValue()}else{if("timevalues"===
  m){var d=parseISO8601DateToDate(a);a=arr.filter(function(a){return f[e]>=d});for(var b="",e=0;e<a.length;e++)0<e&&(b+="/"),b+=a[e].toISO8601();c.reInitializeValues(b);c.setClosestValue()}}else c.reInitializeValues(c.values),timeDim.setClosestValue(!0),console.log("returning")};c.reInitializeValues=function(a){l=!1;t(c,a)};var t=function(a,c){if(1!=l){var d=a.values;c&&(d=c);if(isDefined(d)){k=[];l=!0;"ISO8601"==a.units?0<d.indexOf("/")?(m="timestartstopres",b=new parseISOTimeRangeDuration(d)):m="timevalues":
  (m="anyvalue",a.linked=!1);if("timestartstopres"!=m){c=d.split(",");for(var e=0;e<c.length;e++){var n=c[e].split("/");if(3==n.length)for(e=parseFloat(n[0]),d=parseFloat(n[1]),n=parseFloat(n[2]),d+=n,e>d&&(d=e),0>=n&&(n=1);e<d;e+=n)k.push(e);else k.push(c[e])}if("timevalues"==m)for(e=0;e<k.length;e++)f[e]=parseISO8601DateToDate(k[e])}isDefined(a.defaultValue)||(a.defaultValue=a.getValueForIndex(0));isDefined(a.currentValue)||(a.currentValue=a.getValueForIndex(0));a.dimMinValue=a.getValueForIndex(0);
  a.dimMaxValue=a.getValueForIndex(a.size()-1)}}};this.getValue=function(){l||t(c);var a=c.defaultValue;isDefined(c.currentValue)&&(a=c.currentValue);return a=c.addTimeRangeDurationToValue(a)};this.setValue=function(a){l||t(c);a!=WMJSDateOutSideRange&&a!=WMJSDateTooEarlyString&&a!=WMJSDateTooLateString&&(c.currentValue=a)};this.setClosestValue=function(a,b){a||(a=this.getValue(),b=!0);this.currentValue=this.getClosestValue(a,b)};this.getNextClosestValue=function(a){var b=this.getClosestValue(a),b=this.getIndexForValue(b),
  b=this.getValueForIndex(b+1);return!b||"date too early"===b||moment(a)>=moment(b)?null:b};this.addTimeRangeDurationToValue=function(a){if(a==WMJSDateOutSideRange||a==WMJSDateTooEarlyString||a==WMJSDateTooLateString)return a;if(c.timeRangeDuration&&0<c.timeRangeDuration.length){var b=parseISO8601IntervalToDateInterval(c.timeRangeDuration),d=parseISO8601DateToDate(a);d.add(b);b=d.toISO8601();return a+"/"+b}return a};this.setTimeRangeDuration=function(a){if((c.timeRangeDuration=a)&&0<a.length){c.reInitializeValues(c.values);
  a=parseISO8601DateToDate(c.dimMinValue);var b=c.dimMaxValue,d=parseISO8601IntervalToDateInterval(c.timeRangeDuration);0!=d.second&&a.setUTCSeconds(0);0!=d.minute&&(a.setUTCSeconds(0),a.setUTCMinutes(0));0!=d.hour&&(a.setUTCSeconds(0),a.setUTCMinutes(0),a.setUTCSHours(0));0!=d.day&&(a.setUTCSeconds(0),a.setUTCMinutes(0),a.setUTCSHours(0),a.setUTCDate(0));0!=d.month&&(a.setUTCSeconds(0),a.setUTCMinutes(0),a.setUTCSHours(0),a.setUTCDate(0));c.reInitializeValues(a.toISO8601()+"/"+b+"/"+c.timeRangeDuration)}else console.log("reset"),
  c.reInitializeValues(c.values)};this.getClosestValue=function(a,b){a&&-1!=a.indexOf("/")&&(a=a.split("/")[0]);b="undefined"!==typeof b?b:!1;var c=-1,d=WMJSDateOutSideRange;try{c=this.getIndexForValue(a),d=this.getValueForIndex(c)}catch(v){"number"===typeof v&&(d=0==v?WMJSDateTooEarlyString:WMJSDateTooLateString)}"current"==a||"default"==a||""==a?d=this.defaultValue:"latest"==a||b&&d===WMJSDateTooLateString?d=this.getValueForIndex(this.size()-1):"earliest"==a||b&&d===WMJSDateTooEarlyString?d=this.getValueForIndex(0):
  "middle"==a&&(a=this.size()/2-1,0>a&&(a=0),d=this.getValueForIndex(a));return d};this.getValueForIndex=function(a){t(this);if(0>a)return-1==a?WMJSDateTooEarlyString:-2==a?WMJSDateTooLateString:-1;if("timestartstopres"==m){try{return b.getDateAtTimeStep(a).toISO8601()}catch(n){}return b.getDateAtTimeStep(a)}if("timevalues"==m||"anyvalue"==m)return k[a]};this.get=function(a){return this.getValueForIndex(a)};this.getIndexForValue=function(a,c){t(this);isDefined(c)||(c=!0);if("string"===typeof a&&"current"==
  a&&"current"!=this.defaultValue)return this.getIndexForValue(this.defaultValue);if("timestartstopres"==m)try{return"string"===typeof a?b.getTimeStepFromISODate(a,c):b.getTimeStepFromDate(a,c)}catch(z){return 0==parseInt(z)?-1:-2}if("timevalues"==m)try{var d=parseISO8601DateToDate(a).getTime(),e;for(c=a=0;c<k.length;c++){var l=f[c].getTime()-d;0>l&&(l=-l);0==c&&(e=l);l<e&&(e=l,a=c)}return a}catch(z){return error("WMSJDimension::getIndexForValue,2: "+z),-1}if("anyvalue"==m)for(c=0;c<k.length;c++)if(k[c]==
  a)return c;return-1};this.size=function(){t(this);if("timestartstopres"==m)return b.getTimeSteps();if("timevalues"==m||"anyvalue"==m)return k.length};this.clone=function(){var a=new WMJSDimension;a.name=c.name;a.units=c.units;a.values=c.values;a.initialize();a.currentValue=c.currentValue;a.defaultValue=c.defaultValue;a.parentLayer=c.parentLayer;a.linked=c.linked;return a};this.initialize=function(){t(this)}};var WMSVersion={version100:"1.0.0",version111:"1.1.1",version130:"1.3.0"};String.prototype.startsWith||(String.prototype.startsWith=function(a,d){d=d||0;return this.indexOf(a,d)===d});
  var loadGetCapabilitiesViaProxy=function(a,d,c,l){var b=l+"request=",f=function(a){c(I18n.unable_to_do_getcapabilities.text+":\n"+b+"\n"+I18n.result.text+":\n"+a)};debug("<a target='_blank' href='"+a+"'>"+a+"</a>",!1);b+=URLEncode(a);console.log("loadGetCapabilitiesViaProxy wrapped",b);debug(b);debug(URLEncode(a));debug(a);try{$.ajax({url:b,crossDomain:!0,dataType:"jsonp"}).done(function(a){console.log("loadGetCapabilitiesViaProxy succesfully finished");d(a)}).fail(function(){f({error:"Request failed for "+
  b})})}catch(m){console.log("catch: ",m),f({error:"Request failed for "+b})}},WMJSGetCapabilities=function(a,d,c,l){if(0==isDefined(a))console.log("Service not defined"),l(I18n.no_service_defined.text);else if(0==a.length)console.log("Service is empty"),l(I18n.service_url_empty.text);else if(a.startsWith("http://")||a.startsWith("https:")||a.startsWith("//")){-1==a.indexOf("?")&&(a+="?");debug("GetCapabilities:");var b=a+"&service=WMS&request=GetCapabilities";(new WMJSXMLParser).fetchXMLAndParseToJSON(b,
  c,function(a){console.log("Unable to use browser based XML reading, trying proxy: ",a);loadGetCapabilitiesViaProxy(b,c,function(){l("Request failed for "+b)},xml2jsonrequestURL)})}else console.log("Service does not start with HTTPS"),l(I18n.service_url_empty.text)},WMJSServiceStore=[],WMJSgetServiceFromStore=function(a){for(var d=0;d<WMJSServiceStore.length;d++)if(WMJSServiceStore[d].service==a)return WMJSServiceStore[d];a=new WMJSService({service:a});WMJSServiceStore.push(a);return a};
  function WMJSService(a){function d(a,b){return a.sort(function(a,c){a=a[b];c=c[b];return a<c?-1:a>c?1:0})}this.abstract=this.onlineresource=this.title=this.service=void 0;this.version=WMSVersion.version111;this.getcapabilitiesDoc=void 0;this.busy=!1;var c,l=this;a&&(this.service=a.service,this.title=a.title);this.getCapabilityElement=function(a){try{var b=a.WMT_MS_Capabilities.Capability}catch(k){try{b=a.WMS_Capabilities.Capability}catch(t){throw I18n.no_capability_element_found.text;}}if(!isDefined(b))throw I18n.no_capability_element_found.text;
  return b};this.checkVersion=function(a){var b=null;try{WMSVersion.version100==a.WMT_MS_Capabilities.attr.version&&(b=WMSVersion.version100),WMSVersion.version111==a.WMT_MS_Capabilities.attr.version&&(b=WMSVersion.version111),WMSVersion.version130==a.WMT_MS_Capabilities.attr.version&&(b=WMSVersion.version130)}catch(k){try{WMSVersion.version100==a.WMS_Capabilities.attr.version&&(b=WMSVersion.version100),WMSVersion.version111==a.WMS_Capabilities.attr.version&&(b=WMSVersion.version111),WMSVersion.version130==
  a.WMS_Capabilities.attr.version&&(b=WMSVersion.version130)}catch(t){console.log("165");if(a=l.checkException(a))throw console.log(a),Error(a);throw Error("Unable to determine WMS version");}}if(null===b)throw Error("Unable to determine WMS version");return b==WMSVersion.version111||b==WMSVersion.version130?b:WMSVersion.version111};var b=[];this.getCapabilities=function(a,d,k){c=void 0;var f=this;if(this.busy)a={callback:a,fail:d},b.push(a);else if(f.getcapabilitiesDoc&&1!=k)a(this.getcapabilitiesDoc);
  else{f.busy=!0;var e=function(a){console.log("Failed");f.busy=!1;for(var c=0;c<b.length;c++)b[c].fail(a),b[c].fail=function(){};b=[]};a={callback:a,fail:d};b.push(a);WMJSGetCapabilities(this.service,!1,function(a){f.busy=!1;f.getcapabilitiesDoc=a;try{f.version=f.checkVersion(a)}catch(E){console.log("version error",E);e(E.message);return}var c=a.WMS_Capabilities;c||(c=a.WMT_MS_Capabilities);try{f.abstract=c.Service.Abstract.value}catch(E){this.abstract=I18n.not_available_message.text}try{f.title=c.Service.Title.value}catch(E){this.title=
  I18n.not_available_message.text}try{f.onlineresource=c.Service.OnlineResource.value?c.Service.OnlineResource.value:c.Service.OnlineResource.attr["xlink:href"]}catch(E){f.onlineresource=I18n.not_available_message.text}for(c=0;c<b.length;c++)b[c].callback(a),b[c].callback=function(){};b=[];f.busy=!1},e)}};this.checkException=function(a){console.log("271");try{if(a.ServiceExceptionReport){var b="Undefined",c=b,d=a.ServiceExceptionReport.ServiceException;if(d){try{d.attr.code&&(b=d.attr.code)}catch(e){}if(d.value)return c=
  d.value,"Exception: "+b+".\n"+c}return I18n.wms_service_exception_code.text+b}}catch(e){}};this.getNodes=function(a,b,c){this.nodeCache=void 0;b||(b=function(a){error(a)});var k=function(c){function e(a,b,c){for(var k=0;k<a.length;k++){var f=!1;a[k].Name&&(f=!0);try{a[k].Layer&&(f=!1)}catch(T){}a[k].Name?f={name:a[k].Name.value,text:a[k].Title.value,leaf:f,path:c}:(isNull(a[k].Title)&&(a[k].Title=[],a[k].Title.value="Layer"),f={text:a[k].Title.value,leaf:f});b.push(f);a[k].Layer&&(f.children=[],e(toArray(a[k].Layer),
  f.children,c+a[k].Title.value))}d(b,"text")}var k={},f=l.getCapabilityElement(c).Layer;try{l.version=l.checkVersion(c)}catch(v){b(v);return}c=toArray(f.Layer);try{k.text=f.Title.value}catch(v){k.text=I18n.unnamed_service.text}k.leaf=!1;k.expanded=!0;k.children=[];e(c,k.children,"");a(k)};this.getCapabilities(function(a){k(a)},function(a){b(a)},c)};this.getLayerNames=function(a,b,c){this.getNodes(function(b){var c=[],d=function(a){for(var b=0;b<a.length;b++)a[b].name&&c.push(a[b].name),a[b].children&&
  d(a[b].children)};d(b.children);a(c)},b,c)};this.getLayerObjectsFlat=function(a,b,d){isDefined(c)&&a(c);this.getNodes(function(b){var c=[],d=function(a){for(var b=0;b<a.length;b++)a[b].name&&c.push(a[b]),a[b].children&&d(a[b].children)};d(b.children);a(c)},b,d)}};function WMJSListener(){function a(){this.functionpointer=this.name=void 0;this.finished=0;this.keepOnCall=!1}var d=[],c=0,l=[],b=this;this.addToCallback=function(b,l,k){var f=-1;k||(k=!1);for(var e=0;e<c;e++){if(1===d[e].finished){f=e;break}if(d[e].name===b&&d[e].functionpointer===l)return d[e].keepOnCall=k,!1}-1===f&&(f=c,c++,d[f]=new a);d[f].name=b;d[f].functionpointer=l;d[f].finished=0;d[f].keepOnCall=k;return!0};this.removeEvents=function(a,b){for(var k=0;k<c;k++)0===d[k].finished&&d[k].name===
  a&&(b?d[k].functionpointer===b&&(d[k].finished=1):d[k].finished=1)};this.suspendEvent=function(a){l[a]=!0};this.resumeEvent=function(a){l[a]=!1};this.triggerEvent=function(a,m){if(!0!==l[a]){for(var k=[],f=0,e=0;e<c;e++)if(0===d[e].finished&&d[e].name===a){!1===d[e].keepOnCall&&(d[e].finished=1);try{f++,k.push(d[e].functionpointer(m,b))}catch(n){console.log("Error for event ["+a+"]: ",m,n)}}return k}}};function WMJSTimer(){function a(){l&&clearTimeout(c);l=!1}function d(){0==f?(a(),""!=k&&k()):(--f,l=!0,c=self.setTimeout(function(){d()},b))}this.init=function(b,c){f=parseInt(b/10+.5);1>f&&(f=1);m=f;k=c;a();0<f&&d()};this.reset=function(){f=m};this.stop=function(){a()};var c=null,l=!1,b=10,f,m,k=""}var WMJSDebouncer=function(){var a=!1,d=10,c=!1;this.init=function(l,b){c=!1;d=l;10>d&&(d=10);!1===a&&(self.setTimeout(function(){a=!1;!1===c&&b()},d),a=!0)};this.stop=function(){c=!0}};var sliderTooltip=function(a){isDefined(a)?(a='<div class="slidertooltip"><div class="slidertooltip-inner">'+a+"</div></div>",$(".relativecontrol .ui-slider-handle").html(a)):$(".ui-slider-handle .relativecontrol").html("")},RelativeSlider=function(a){var d=this,c=a.renderTo;$('<input class="datetimepicker"/><br/><span class="relativeslider"/><span class="timeprevious"/><span class="timenext"/>').appendTo(c);var l=0,b=function(b){l+=b;NaN<l&&(l=NaN);0>l&&(l=0);isDefined(a.change)&&a.change(d,l)},
  f=c.find(".relativeslider").slider({min:0,max:100,value:50,animate:1E3,change:function(a,c){a.originalEvent&&(a=parseInt(c.value-50),b(a),50!=c.value&&f.slider("value",50))},slide:function(b,c){c=parseInt(c.value-50);b=l;c=l+c;void 0<c&&(c=void 0);0>c&&(c=0);isDefined(a.slide)&&a.slide(d,c);l=b}});f.addClass("relativecontrol");c.find(".timeprevious").iconbutton({text:!1,icons:{primary:"ui-icon-circle-triangle-w"}});c.find(".timenext").iconbutton({text:!1,icons:{primary:"ui-icon-circle-triangle-e"}});
  c.find(".timeprevious").click(function(){b(-1)});c.find(".timenext").click(function(){b(1)});var m=c.find(".datetimepicker").datetimepicker({dateFormat:"yy-mm-dd",timeFormat:"HH:mm:ss",separator:"T",showOn:"button",buttonText:"",altFieldTimeOnly:!1,showAnim:"slideDown",changeMonth:!0,changeYear:!0,showTimezone:!1,onSelect:function(a,b){b=d.setPositionByText(a);a!=b.dimvalue&&m.datetimepicker("setDate",b.dimvalue.replace("Z",""))},css:{zIndex:4E3}});this.setPosition=function(a){l=a};this.setPositionByText=
  function(b){if(isDefined(a.textUpdate))return a.textUpdate(d,b)};this.setText=function(a,b){a=a.replace("Z","");c.find(".datetimepicker").val(a)};this.setMax=function(a,b,c){m.datetimepicker("option",{minDate:b.replace("Z",""),maxDate:c.replace("Z","")})}},TimeSlider=function(a){var d,c;this.setDimension=function(a,b,f){d=a;isDefined(void 0)&&(void 0).setMax(a.size(),a.getValueForIndex(0),a.getValueForIndex(a.size()-1));c="";this.setValue(a.name,a.getValue())};this.setValue=function(a,b){if(isDefined(d)&&
  "time"==a&&c!=b){c=b;try{var f=d.getIndexForValue(b)}catch(m){f=d.size()-1,b=d.getValueForIndex(f),debug("Date "+b+" is outside range: "+f)}isDefined(void 0)&&((void 0).setText(b),(void 0).setPosition(f));return{index:f,dimvalue:b}}}};var WMJSProcessing=function(a){var d=a.url,c=!1;a.failure||(a.failure=function(a){alert(dump(a))});var l=function(b){try{var d=b["wps:ExecuteResponse"]["wps:Status"]["wps:ProcessAccepted"].value}catch(n){}if(isDefined(d)){var l=b["wps:ExecuteResponse"].attr.statusLocation,k=new WMJSTimer,t=function(b){if(0!=c){if(b.error){var d=!0;var e=b.error}try{d=!0,e=dump(b.ExceptionReport.Exception)}catch(I){}try{d=b["wps:ExecuteResponse"]["wps:Status"]["wps:ProcessFailed"],e="Process failed",e=b["wps:ExecuteResponse"]["wps:Status"]["wps:ProcessFailed"]["wps:ExceptionReport"]["ows:Exception"]["ows:ExceptionText"].value}catch(I){}if(isDefined(d))c=
  !1,a.failure({message:e});else{try{var k=b["wps:ExecuteResponse"]["wps:Status"]["wps:ProcessSucceeded"].value}catch(I){}try{var f=b["wps:ExecuteResponse"]["wps:Status"]["wps:ProcessStarted"].attr.percentCompleted;var l=b["wps:ExecuteResponse"]["wps:Status"]["wps:ProcessStarted"].value;0==l.indexOf("processstarted")&&(l=l.substr(14))}catch(I){}isDefined(k)?(k=b["wps:ExecuteResponse"]["wps:ProcessOutputs"]["wps:Output"],a.progress(100,"completed"),a.success(k,b),c=!1):a.progress(parseFloat(f),l)}}},
  e=function(){$.ajax({dataType:"jsonp",url:xml2jsonrequestURL+"request="+URLEncode(l),data:"",success:t}).fail(function(b){c=!1;a.failure({message:"<h1>Invalid JSON returned from server:</h1><hr/>"+b.responseText})});c&&k.init(1E3,e)};e()}else{d="";try{d=dump(b.ExceptionReport.Exception.attr),a.failure({message:"Process was not accepted, ExceptionReport:\n"+d})}catch(n){b.error?(b.message||(b.message=b.error),a.failure(b)):(d=dump(b),a.failure({message:"Process was not accepted (dump):\n"+d}))}}};
  this.execute=function(b,f){c=!0;b=d+"service=WPS&request=execute&identifier="+b+"&version=1.0.0&storeExecuteResponse=true&status=true&";b+="datainputs=";var m="",k;for(k in f)if("object"===typeof f[k])for(var t in f[k])0<m.length&&(m+=";"),m+=k+"="+encodeURIComponent(f[k][t]);else 0<m.length&&(m+=";"),m+=k+"="+encodeURIComponent(f[k]);$.ajax({dataType:"jsonp",url:xml2jsonrequestURL,data:{request:b+m},success:l}).fail(function(b){a.failure({message:b.responseText})})}};var WMJSCoverage=function(a){this.service=this.name=void 0;this.dimensions=[];this.supportedProjections=[];this.nativeFormat=this.nativeCRS=this.originY=this.originX=this.cellsizeY=this.cellsizeX=this.height=this.width=void 0;this.formats=[];this.setDimension=function(a,c){this.dimensions.push({name:a,value:c,currentValue:c})};isDefined(a)&&(this.name=a.name,this.service=a.service)},WCJSRequest=function(a,d,c,l){var b=xml2jsonrequestURL+"request=";-1==a.indexOf("?")&&(a+="?");debug("GetCapabilities:");
  var f=a+"&service=WCS&REQUEST=DescribeCoverage&COVERAGE="+d;debug("<a target='_blank' href='"+f+"'>"+f+"</a>",!1);b+=URLEncode(f);$.ajax({dataType:"jsonp",url:b,success:function(b){b.service=a;b.name=d;c(b)},error:function(a){l(I18n.unable_to_do_getcapabilities.text+":\n"+b+"\n"+I18n.result.text+":\n"+a)}})},parseDescribeCoverage=function(a,d){d=d?d:new WMJSCoverage;d.service=a.service;try{d.name=a.CoverageDescription.CoverageOffering.name.value}catch(k){alert("This layer has no Web Coverage Service.");
  return}d.title=a.CoverageDescription.CoverageOffering.label.value;d["abstract"]=a.CoverageDescription.CoverageOffering.description.value;var c=a.CoverageDescription.CoverageOffering.lonLatEnvelope["gml:pos"][0].value.replaceAll(" ",",");var l=a.CoverageDescription.CoverageOffering.lonLatEnvelope["gml:pos"][1].value.replaceAll(" ",",");d.lonlatbox=new WMJSBBOX(c+","+l);for(var b=toArray(a.CoverageDescription.CoverageOffering.domainSet.spatialDomain["gml:Envelope"]),f=0;f<b.length;f++){var m=b[f].attr.srsName;
  c=b[f]["gml:pos"][0].value.replaceAll(" ",",");l=b[f]["gml:pos"][1].value.replaceAll(" ",",");l=new WMJSBBOX(c+","+l);d.supportedProjections.push({srs:m,bbox:l.toString()})}f=a.CoverageDescription.CoverageOffering.domainSet.spatialDomain["gml:RectifiedGrid"]["gml:limits"]["gml:GridEnvelope"]["gml:high"].value.split(" ");d.width=parseInt(f[0])+1;d.height=parseInt(f[1])+1;d.cellsizeX=parseFloat(a.CoverageDescription.CoverageOffering.domainSet.spatialDomain["gml:RectifiedGrid"]["gml:offsetVector"][0].value.split(" ")[0]);
  d.cellsizeY=parseFloat(a.CoverageDescription.CoverageOffering.domainSet.spatialDomain["gml:RectifiedGrid"]["gml:offsetVector"][1].value.split(" ")[1]);d.originX=a.CoverageDescription.CoverageOffering.domainSet.spatialDomain["gml:RectifiedGrid"]["gml:origin"]["gml:pos"].value.split(" ")[0];d.originY=a.CoverageDescription.CoverageOffering.domainSet.spatialDomain["gml:RectifiedGrid"]["gml:origin"]["gml:pos"].value.split(" ")[1];d.nativeCRS=a.CoverageDescription.CoverageOffering.supportedCRSs.nativeCRSs?
  a.CoverageDescription.CoverageOffering.supportedCRSs.nativeCRSs.value:"EPSG:4326";d.nativeFormat=a.CoverageDescription.CoverageOffering.supportedFormats.attr.nativeFormat;a=toArray(a.CoverageDescription.CoverageOffering.supportedFormats.formats);for(f=0;f<a.length;f++)d.formats.push(a[f].value);return d};var WMJSImage=function(a,d,c,l){var b=this,f=!0;isDefined(l)&&isDefined(l.randomizer)&&!1===l.randomizer&&(f=!1);var m,k,t,e,n;b.init=function(){m="undefined image";e=t=k=!1;n=1};b.init();this.srcToLoad=a;b.isLoaded=function(){return t?!1:k};b.isLoading=function(){return t};b.checkIfThisSourceIsSet=function(a){return m==a||this.srcToLoad==a?!0:!1};b.setSource=function(a){t?console.log("-------------------------\x3e Source set while still loading!!! "):(this.srcToLoad=a,k=m==this.srcToLoad?!0:!1)};
  b.clear=function(){b.init()};b.getSrc=function(){return this.srcToLoad};b.hasError=function(){return e};b.load=function(){e=!1;1==k?D(b,!1):(t=!0,this.srcToLoad?!1===this.srcToLoad.startsWith("http")&&!1===this.srcToLoad.startsWith("//")?(console.log("Source does not start with http"),D(b,!0)):this.srcToLoad==m?D(b,!1):(E.load(function(){D(b,!1)}),E.error(function(a){D(b,!0)}),f?E.attr("src",this.srcToLoad+"&"+Math.random()):E.attr("src",this.srcToLoad)):(console.log("Source not set"),D(b,!0)))};
  var D=function(a,c){e=c;t=!1;k=!0;m=this.srcToLoad;isDefined(d)&&d(b)};b.setOpacity=function(a){n=parseFloat(a);E.css("opacity",n)};b.getOpacity=function(a){return n};b.setPosition=function(a,b){E.css({top:parseInt(b)+"px",left:parseInt(a)+"px",position:"absolute"})};b.setSize=function(a,b){a=parseInt(a);b=parseInt(b);0===a||0===b||isNaN(a)||isNaN(b)||(E.width(parseInt(a)+"px"),E.height(parseInt(b)+"px"))};b.setZIndex=function(a){E.zIndex=a};b.getElement=function(){return E};var E=$(document.createElement("img"));
  E.onselectstart=function(){return!1};E.ondrag=function(){return!1};return b};function WMJSXMLParser(){this.fetchXMLAndParseToJSON=function(a,d,c){$.ajax({url:a,crossDomain:!0,xhrFields:{withCredentials:!0}}).done(function(a){if("object"!==typeof a&&(a=(new DOMParser).parseFromString(a,"text/xml"),"parseerror"===a.documentElement.nodeName))throw"Error while parsing: "+a;var b={},f=function(a,b,c){if(a.children&&a.children.length)for(var d=0;d<a.children.length;d++){var k=a.children[d],l=b+"->"+k.nodeName,m=k.nodeName;if(c[m]){var t={attr:{}};if(!(c[m]instanceof Array)){var z=
  Object.assign({},c[m]);c[m]=[];c[m].push(z)}c[m].push(t)}else c[m]={attr:{}},t=c[m];k.childNodes&&0<k.childNodes.length&&k.childNodes[0].nodeValue&&(m=k.childNodes[0].nodeValue.trim(),"\n"!==m&&0<m.length&&(t.value=m));if(k.attributes&&0<k.attributes.length)for(m=0;m<k.attributes.length;m++)t.attr[k.attributes[m].name]=k.attributes[m].value;f(k,l,t)}};f(a,"",b);try{d(b)}catch(m){c({error:"WMJSXMLParser: ready failed",exception:m})}}).fail(function(d){c({error:"WMJSXMLParser: Request failed for "+
  a,exception:d})})}};var WMJSCanvasBuffer=function(a,d,c,l,b){var f=this;this.canvas=$("<canvas/>",{"class":"WMJSCanvasBuffer"}).width(l).height(b);var m=f.canvas[0].getContext("2d");m.canvas.width=l;m.canvas.height=b;m.mozImageSmoothingEnabled=!0;m.webkitImageSmoothingEnabled=!0;m.imageSmoothingQuality="high";m.msImageSmoothingEnabled=!0;this.hidden=this.ready=m.imageSmoothingEnabled=!0;this.layerstodisplay=[];this.layers=[];var k=l,t=b;"imagebuffer"===d&&this.canvas.addClass("wmjsimagebuffer");"legendbuffer"===d&&this.canvas.addClass("wmjslegendbuffer");
  this.canvas.addClass("WMJSCanvasBuffer-noselect");this.getCanvasContext=function(){return m};this.imageLoadComplete=function(b){e();a.triggerEvent("onimageload");"imagebuffer"===d&&a.triggerEvent("onimagebufferimageload",b)};var e=function(){for(var a=0;a<f.layers.length;a++)if(!1===f.layers[a].isLoaded())return;f.finishedLoading()},n=new WMJSImage("webmapjs/img/stoploading.png",function(){console.log("fake image loaded");e()},d);this.hide=function(){f.hidden=!0;f.canvas.hide();f.layers=[]};this.display=
  function(b,c){var e=[];if(b&&!c)console.log("skipping WMJSCanvasBuffer:display because newbbox is undefined");else{f.hidden=!1;m.globalAlpha=1;"legendbuffer"===d&&m.clearRect(0,0,k,t);"imagebuffer"===d&&(m.beginPath(),m.rect(0,0,k,t),m.fillStyle="white",m.fill(),a.triggerEvent("beforecanvasstartdraw",m));if(b){var l=D({x:c.left,y:c.top},b);var n=D({x:c.right,y:c.bottom},b)}for(var g=c=0;g<f.layerstodisplay.length;g++)if(f.layerstodisplay[g].setSize(k,t),!1===f.layerstodisplay[g].hasError()){var q=
  f.layerstodisplay[g].getOpacity();m.globalAlpha=q;q=f.layerstodisplay[g].getElement()[0];if("legendbuffer"===d){var z=parseInt(q.width)+4,v=parseInt(q.height)+4;c+=z+4;var u=k-c+2,w=t-v-2;m.beginPath();m.fillStyle="#FFFFFF";m.lineWidth=.3;m.globalAlpha=.5;m.strokeStyle="#000000";m.rect(parseInt(u)+.5,parseInt(w)+.5,z,v);m.fill();m.stroke();m.globalAlpha=1;m.drawImage(q,u,w)}else b?(z=parseInt(l.x+.5),v=parseInt(l.y+.5),u=parseInt(n.x-l.x+.5),w=parseInt(n.y-l.y+.5),u===parseInt(m.canvas.width)&&w===
  parseInt(m.canvas.height)?m.drawImage(q,z,v):m.drawImage(q,z,v,u,w)):m.drawImage(q,0,0,k,t)}else e.push(f.layerstodisplay[g]);m.globalAlpha=1;"imagebuffer"===d&&0<e.length&&a.triggerEvent("canvasonerror",e);"imagebuffer"===d&&a.triggerEvent("beforecanvasdisplay",m);f.canvas.show();"imagebuffer"===d&&a.triggerEvent("aftercanvasdisplay",m)}};this.finishedLoading=function(){if(!f.ready){f.ready=!0;for(var a=0;a<f.layers.length;a++)f.layerstodisplay[a]=f.layers[a],f.layers[a].hasError()&&error("Unable to get image <a target='_blank' href='"+
  f.layerstodisplay[a].getSrc()+"'>"+f.layerstodisplay[a].getSrc()+"</a>",!1);try{if(isDefined(f.onLoadReadyFunction))f.onLoadReadyFunction(f)}catch(q){error("Exception in Divbuffer::finishedLoading: "+q)}}};this.setPosition=function(a,b){console.log("setPosition is deprecated")};this.setSize=function(a,b){console.log("setSize is deprecated")};this.resize=function(a,b){a=parseInt(a);b=parseInt(b);if(k!==a||t!==b)k=a,t=b,f.canvas.width(a),f.canvas.height(b),m.canvas.height=b,m.canvas.width=a};this.load=
  function(a){if(!1!==f.ready){f.ready=!1;f.layerstodisplay=[];a?this.onLoadReadyFunction=a:f.onLoadReadyFunction=function(){};for(a=f.nrLoading=0;a<this.layers.length;a++)f.layers[a].loadThisOne=!1,!1===f.layers[a].isLoaded()&&(f.layers[a].loadThisOne=!0,f.nrLoading++);if(0===this.nrLoading)e();else{"imagebuffer"===d&&debug("GetMap:");"legendbuffer"===d&&debug("GetLegendGraphic:");for(a=0;a<this.layers.length;a++)!0===this.layers[a].loadThisOne&&debug("<a target='_blank' href='"+this.layers[a].getSrc()+
  "'>"+this.layers[a].getSrc()+"</a>",!1);for(a=0;a<this.layers.length;a++)!0===this.layers[a].loadThisOne&&this.layers[a].load()}}};this.setSrc=function(a,b,d,e,k){if(isDefined(b)){for(;a>=this.layers.length;)this.layers.push(n);b=c.getImage(b);b.setZIndex(a);b.linkedInfo=k;this.layers[a]=b}else console.log("undefined")};var D=function(a,b){return{x:k*(a.x-b.left)/(b.right-b.left),y:t*(a.y-b.top)/(b.bottom-b.top)}},E,v;this.setBBOX=function(a,b){if(E!==b+""||v!==a+"")E=b+"",v=a+"",!1===f.hidden&&f.display(a,
  b)};this.setOpacity=function(a,b){a>=this.layers.length?error("setOpacity :invalid id"):(b=parseFloat(b),this.layers[a].getOpacity()!==b&&this.layers[a].setOpacity(b))};this.getBuffer=function(){return f.canvas}};function WMJSTimeSelector(a,d,c){var l=function(){this.values=[]};l.prototype.add=function(a){if(!0===this[a])return!1;this[a]=!0;this.values.push(a);return!0};var b=this;this.element=a;this.webmapjs=void 0;this.values=[];var f=24;isDefined(c)&&(f=c);var m=$('<div class="WMJSTimeSelector-controlElement WMJSTimeSelector-noselect"/>',{}),k=$('<div class="WMJSTimeSelector-timeChooserElement WMJSTimeSelector-noselect"/>',{}),t=$('<div class="WMJSTimeSelector-timeinfo WMJSTimeSelector-noselect"/>',{}),
  e=$('<div class=""WMJSTimeSelector-controlElementBottom WMJSTimeSelector-noselect"/>',{});this.element.append(t);this.element.append(m);this.element.append(k);this.element.append(e);a=$("<button>&lt;&lt;</button>").button().click(function(){var a=b.makeDateList(b.webmapjs,b.currentValue,f);N(a[0])});c=$("<button>&gt;&gt;</button>").button().click(function(){var a=b.makeDateList(b.webmapjs,b.currentValue,f);N(a[a.length-1])});var n=$("<button>&lt;</button>").button().click(function(){for(var a=b.makeDateList(b.webmapjs,
  b.currentValue,f),c=1;c<a.length;c++)if(a[c]==b.currentValue){N(a[c-1]);return}N(a[0])}),D=$("<button>&gt;</button>").button().click(function(){for(var a=b.makeDateList(b.webmapjs,b.currentValue,f),c=0;c<a.length-1;c++)if(a[c]==b.currentValue){N(a[c+1]);return}N(a[a.length-1])});m.append("<table class='WMJSTimeSelector-table'><tr><th>"+I18n.year.text+"</th><th>"+I18n.month.text+"</th><th>"+I18n.day.text+"</th><th>"+I18n.hour.text+"</th><th>"+I18n.min.text+"</th></tr><tr><td><input class='WMJSTimeSelector_yearspinner'/></td><td><input class='WMJSTimeSelector_monthspinner'/></td><td><input class='WMJSTimeSelector_dayspinner'/></td><td><input class='WMJSTimeSelector_hourspinner'/></td><td><input class='WMJSTimeSelector_minutespinner'/></td></tr>");
  var E=$("<button>"+I18n.load_all.text+"</button>").button().click(function(){for(var a=b.values,c=0;c<a.length;c++)A(a[c])}),v=$("<button>"+I18n.play_animation.text+"</button>").button().click(function(){for(var a=b.values,c=[],d=0;d<a.length;d++)A(a[d]),c.push({name:"time",value:a[d]});b.webmapjs.draw(c)}),z=$("<button>"+I18n.stop.text+"</button>").button().click(function(){b.webmapjs.stopAnimating()});e.append(E);e.append(v);e.append(z);var q=m.find(".WMJSTimeSelector_yearspinner"),I=m.find(".WMJSTimeSelector_monthspinner"),
  C=m.find(".WMJSTimeSelector_dayspinner"),T=m.find(".WMJSTimeSelector_hourspinner"),g=m.find(".WMJSTimeSelector_minutespinner"),da=m.find(".WMJSTimeSelector_secondspinner"),e=$('<div class="WMJSTimeSelector_timebuttons"/>',{});e.append(a);e.append(n);e.append(D);e.append(c);m.append(e);var ka="",F=function(a,b){for(a=""+a;a.length<b;)a="0"+a;return a},u=function(a,c){var d=ka;"year"==a&&(d=[F(c,4),d.slice(4)].join(""));"month"==a&&(d=[d.slice(0,5),F(c,2),d.slice(7)].join(""));"day"==a&&(d=[d.slice(0,
  8),F(c,2),d.slice(10)].join(""));"hour"==a&&(d=[d.slice(0,11),F(c,2),d.slice(13)].join(""));"minute"==a&&(d=[d.slice(0,14),F(c,2),d.slice(16)].join(""));"second"==a&&(d=[d.slice(0,17),F(c,2),d.slice(19)].join(""));a=parseISO8601DateToDate(d);d=a.toISO8601();if(d!=b.currentValue&&(c=b.makeDateList(b.webmapjs,d,3),c[1]==b.currentValue)){var e=parseISO8601DateToDate(c[1]);a>e?d=c[2]:a<e&&(d=c[0])}d!=ka&&(w(d),N(d));return!1},w=function(a){isDefined(a)&&(ka=a,q.spinner("value",a.substring(0,4)),I.spinner("value",
  a.substring(5,7)),C.spinner("value",a.substring(8,10)),T.spinner("value",a.substring(11,13)),g.spinner("value",a.substring(14,16)),da.spinner("value",a.substring(17,19)))};q.spinner({spin:function(a,b){return u("year",b.value)},change:function(a,b){u("year",$(a.target).spinner("value"))},numberFormat:"d4"});I.spinner({spin:function(a,b){return u("month",b.value)},change:function(a,b){u("month",$(a.target).spinner("value"))},numberFormat:"d2"});C.spinner({spin:function(a,b){return u("day",b.value)},
  change:function(a,b){u("day",$(a.target).spinner("value"))},numberFormat:"d2"});T.spinner({spin:function(a,b){return u("hour",b.value)},change:function(a,b){u("hour",$(a.target).spinner("value"))},numberFormat:"d2"});g.spinner({spin:function(a,b){return u("minute",b.value)},change:function(a,b){u("minute",$(a.target).spinner("value"))},numberFormat:"d2"});da.spinner({spin:function(a,b){return u("second",b.value)},change:function(a,b){u("second",$(a.target).spinner("value"))},numberFormat:"d2"});q.spinner().keyup(function(a,
  b){13==(a.keyCode||a.which)&&u("year",$(event.target).spinner("value"))});I.spinner().keyup(function(a,b){13==(a.keyCode||a.which)&&u("month",$(event.target).spinner("value"))});C.spinner().keyup(function(a,b){13==(a.keyCode||a.which)&&u("day",$(event.target).spinner("value"))});T.spinner().keyup(function(a,b){13==(a.keyCode||a.which)&&u("hour",$(event.target).spinner("value"))});g.spinner().keyup(function(a,b){13==(a.keyCode||a.which)&&u("minute",$(event.target).spinner("value"))});da.spinner().keyup(function(a,
  b){13==(a.keyCode||a.which)&&u("second",$(event.target).spinner("value"))});this.loadingComplete=function(a){this.generate(a,!1,!0)};this.dimensionUpdate=function(a){this.generate(a,!0,!0)};this.dimensionChange=function(a){this.generate(a,!1,!1)};var K=function(a){w(a);a=parseISO8601DateToDate(a);$(t).html(I18n.local_time.text+":<br/><b>"+a.toString().replace(/GMT.*/g,"")+"</b>")},N=function(a){b.webmapjs.stopAnimating();K(a);d(a)};this.makeDateList=function(a,b,c){var d=[];a=a.getLayers();for(var e=
  0;e<a.length;e++)if(1==a[e].enabled){var k=a[e].getDimension("time");k&&d.push(k)}k=new l;for(e=0;e<c;e++)for(var f=0;f<d.length;f++){var g=d[f];a=g.getIndexForValue(b,!1);var m=e+a;0>m&&(m=0);m>g.size()-1&&(m=g.size()-1);0<=m&&m<g.size()&&k.add(g.getValueForIndex(m));m=-e+a;0>m&&(m=0);m>g.size()-1&&(m=g.size()-1);0<=m&&m<g.size()&&k.add(g.getValueForIndex(m))}k.values.sort();for(e=d=0;e<k.values.length;e++)if(b==k.values[e]){d=e;break}f=0;b=new l;for(e=0;e<c;e++){a=d+e;if(0<a&&a<k.values.length&&
  1==b.add(k.values[a])&&(f++,f>c))break;a=d-e;if(0<a&&a<k.values.length&&1==b.add(k.values[a])&&(f++,f>c))break}b.values.sort();c=[];for(e=0;e<b.values.length;e++)c.push(b.values[e]);return c};var r=function(a){if(!b.webmapjs)return!1;var c=b.webmapjs.getDimension("time");if(!isDefined(c))return!1;c=c.currentValue;b.webmapjs.suspendEvent("ondimchange");b.webmapjs.suspendEvent("ondimupdate");b.webmapjs.setDimension("time",a);a=function(){var a=b.webmapjs.getWMSRequests();if(0==a.length)return!1;for(var c=
  0;c<a.length;c++)if(0==b.webmapjs.isThisRequestLoaded(a[c]))return!1;return!0}();b.webmapjs.setDimension("time",c);b.webmapjs.resumeEvent("ondimchange");b.webmapjs.resumeEvent("ondimupdate");return a},A=function(a){if(!b.webmapjs)return!1;var c=b.webmapjs.getDimension("time");if(!isDefined(c))return!1;c=c.currentValue;b.webmapjs.suspendEvent("ondimchange");b.webmapjs.suspendEvent("ondimupdate");b.webmapjs.setDimension("time",a);a=[];var d=b.webmapjs.getWMSRequests();if(0==d.length)a=!1;else for(var e=
  0;e<d.length;e++)0==b.webmapjs.isThisRequestLoaded(d[e])&&a.push(d[e]);b.webmapjs.prefetch(a);b.webmapjs.setDimension("time",c);b.webmapjs.resumeEvent("ondimchange");b.webmapjs.resumeEvent("ondimupdate");return a};this.generate=function(a,c,d){this.webmapjs=a;if(a.getDimension("time")){m.show();t.show();var e=a.getDimension("time").currentValue;if("current"==e)for(var g=a.getLayers(),l=0;l<g.length;l++){var n=g[l].getDimension("time");n&&(e=n.getValueForIndex(n.getIndexForValue(e,!1)))}b.currentValue=
  e;K(b.currentValue);if(0==c){g=!1;if(isDefined(b.values))for($(b.element).find(".WMJSTimeSelector-tr").removeClass("WMJSTimeSelector-col-selected"),l=0;l<b.values.length;l++)c=!1,n=$(b.element).find(".WMJSTimeSelector-tr:eq("+l+")"),!0===d&&(c=!1,n.hasClass("WMJSTimeSelector-col-loaded")&&(c=!0),c||(c=1==r(b.values[l])),c?n.addClass("WMJSTimeSelector-col-loaded"):n.removeClass("WMJSTimeSelector-col-loaded")),b.currentValue==b.values[l]&&(b.currentValue=e,n.addClass("WMJSTimeSelector-col-selected"),
  g=!0);if(1==g)return}b.values=b.makeDateList(a,e,f);a="<table class='WMJSTimeSelector-table WMJSTimeSelector-noselect'>";d=function(a){var b="WMJSTimeSelector-tr";1==a.isLoaded&&(b+=" WMJSTimeSelector-col-loaded");a.value==e&&(b+=" WMJSTimeSelector-col-selected");return"<tr class='"+b+"'>"+("<td class='WMJSTimeSelector-colindex'>"+a.index+"</td><td class='WMJSTimeSelector-col'>"+a.textdate+"</td><td class='WMJSTimeSelector-colindex'>"+a.index+"</td><td class='WMJSTimeSelector-col'>"+a.texttime+"</td>")+
  "</tr>"};c={};for(l=0;l<b.values.length;l++)c.index=l,c.value=b.values[l],c.text=c.value.replace(/T/g," | "),c.text=c.text.replace(/Z/g," "),c.textdate=c.value.split("T")[0],c.texttime=c.value.split("T")[1],c.texttime=c.texttime.split(":")[0]+":"+c.texttime.split(":")[1]+"z",c.isLoaded=r(c.value),a+=d(c);l=""+(a+"</table>");$(k).html(l);var q=function(a){a=$(a.target).parent().find("td").first().html();N(b.values[a])};$(b.element).find(".WMJSTimeSelector-tr").mouseover(function(a){0!=O&&q(a)});$(b.element).find(".WMJSTimeSelector-tr").mousedown(q)}else $(k).html(I18n.no_dimensions_available.text),
  m.hide(),t.hide(),b.currentValue="",b.values=[]};var O=!1;$(document).mousedown(function(){O=!0}).mouseup(function(){O=!1});$(b.element).bind("mousewheel",function(a){var b=0;try{isDefined(a.originalEvent.deltaY)&&(b=a.originalEvent.deltaY)}catch(P){}0==b&&(b=0<a.originalEvent.wheelDelta/120?-1:1);0>b?n.click():D.click()})};var GFITimeElevationWindow=function(a){this.t=function(){return 123};this.setSize=function(d,b){d-=80;b-=70;a.width(d);a.height(b);var f=a.find(".timeaxis").get(0).getContext("2d");f.canvas.height=50;f.canvas.width=d;f=a.find(".heightaxis").get(0).getContext("2d");f.canvas.height=b;f.canvas.width=60;c.setSize(d,b);c.draw()};a.html('<table class="gfi_table"><tr class="gfi_table_tr"><td class="gfi_table_td"><canvas class="heightaxis" class="gfi_nomarginpadding"  ></canvas></td><td class="gfi_table_td"><div class="gfi_nomarginpadding gfi_mainmap" style="width:1200px;height:600px;"></div></td><td><div class="legend"></div></td></tr><tr class="gfi_table_tr"><td class="gfi_table_td"></td><td><canvas class="timeaxis"  class="gfi_nomarginpadding"   ></canvas><td class="gfi_table_td"></td></tr></table>');
  var d=a.find(".gfi_mainmap").get(0);var c=new WMJSMap(d);c.hideScaleBar();c.displayLegendInMap(!1);this.setSize(a.width(),a.height());this.updateBBOX=function(d){var b=a.find(".timeaxis").get(0).getContext("2d");b.fillStyle="#FFF";b.font="10px Arial";b.fillRect(0,0,c.getWidth(),50);var f=-1;for(var l=Math.round(d.left);l<Math.round(d.right);l+=1E4){var k=new Date(l);-1==f&&(f=k.getUTCHours());if(f!=k.getUTCHours()){b.fillStyle="#000000";var t=(l-d.left)/(d.right-d.left)*c.getWidth();b.beginPath();
  b.moveTo(t-1,0);b.lineTo(t-1,10);b.stroke();f=k.getUTCHours();b.fillText(f,t-b.measureText(f).width/2-1,20);f=k.getUTCHours()}}b.font="14px Arial";b.fillText("time UTC (h)",c.getWidth()/2-100,38);b=a.find(".heightaxis").get(0).getContext("2d");b.font="10px Arial";b.fillStyle="#FFF";b.fillRect(0,0,60,c.getHeight());b.textAlign="right";f=-1.1;if(!(100<Math.abs(Math.round(d.top)-Math.round(d.bottom))/1E3)){for(l=Math.round(d.bottom);l<Math.round(d.top);l+=1)k=Math.floor(l/1E3),-1.1==f&&(f=k),f!=k&&(b.fillStyle=
  "#000000",t=(l-d.top)/(d.bottom-d.top)*c.getHeight(),b.beginPath(),b.moveTo(50,t),b.lineTo(60,t),b.stroke(),f=l,b.fillText(f,48,t+3),f=k);b.save();b.translate(5,c.getHeight()/2-50);b.rotate(-Math.PI/2);b.font="14px Arial";b.fillText("height (m)",5,6);b.restore()}};this.drawLegend=function(){var d=c.getLayers()[0],d=c.getLegendGraphicURLForLayer(d);a.find(".legend").html('<img class="legendimg" src="'+d+'&TRANSPARENT=TRUE"/>')};c.addListener("onupdatebbox",this.updateBBOX,!0);c.setProjection("GFI:TIME_ELEVATION",
  [(new Date("2018-07-05T00:00:00Z")).getTime(),0,(new Date("2018-07-05T08:50:00Z")).getTime(),15270]);this.updateBBOX(c.getProjection().bbox);this.getWebMapJS=function(){return c}};var WMJSAnimate=function(a){a.animationDelay=100;var d=a.getListener(),c=a.getImageStore(),l=this,b=document.createElement("div");$(b).mouseout(function(){a.mouseHoverAnimationBox=!1});var f=0,m=function(){if(0==a.isAnimating)a.isAnimatingLoopRunning=!1;else if(a.animationTimer.init(50,m),l.checkAnimation(),f--,!(0<f)){var b=a.animationDelay;0==a.currentAnimationStep&&(b*=3);a.currentAnimationStep==a.animationList.length-1&&(b*=5);f=b/50;if(!1===a.mouseHoverAnimationBox){0!=a.isAnimating&&1!=a.animateBusy&&
  ((b=a.animationList[a.currentAnimationStep])?(a.setDimension(b.name,b.value,!1),d.triggerEvent("ondimchange"),d.triggerEvent("onnextanimationstep",a),a._pdraw(),a.animateBusy=!1):error("No animation step for "+a.currentAnimationStep));b=a.currentAnimationStep+1;b>=a.animationList.length&&(b=0);var c=!1,e=0,n=a.animationList[b];a.setDimension(n.name,n.value,!1);a.animationList[b].requests=a.getWMSRequests();n=a.animationList[a.currentAnimationStep];a.setDimension(n.name,n.value,!1);for(n=0;n<a.animationList[b].requests.length;n++){var D=
  a.animationList[b].requests[n];(D=a.getImageStore().getImageForSrc(D))&&D.isLoaded()?e++:f=0}e==a.animationList[b].requests.length&&(c=!0);c&&(a.currentAnimationStep=b)}}};a.isAnimatingLoopRunning=!1;l.checkAnimation=function(){if(0==a.isAnimating)a.isAnimatingLoopRunning=!1;else{a.animationTimer||(a.animationTimer=new WMJSTimer);if(!1===a.mouseHoverAnimationBox){var b=c.getNumImagesLoading();if(4>b){var d=a.animationList.length;if(0<a.animationList.length)for(var e=0;e<d;e++){for(var f=e+a.currentAnimationStep;0>
  f;)f+=a.animationList.length;for(;f>=a.animationList.length;)f-=a.animationList.length;0>f&&(f=0);if(0<=f){var l=a.animationList[f];a.setDimension(l.name,l.value,!1);a.animationList[f].requests=a.getWMSRequests();l=a.animationList[a.currentAnimationStep];a.setDimension(l.name,l.value,!1);a.animationList[f].imagesInPrefetch=a.prefetch(a.animationList[f].requests);b+=a.animationList[f].imagesInPrefetch.length;if(3<b)break}}}}0==a.isAnimatingLoopRunning&&(a.isAnimatingLoopRunning=!0,m())}};a.stopAnimating=
  function(){0!=a.isAnimating&&(b.style.display="none",a.isAnimating=!1,a.animateBusy=!1,a.rebuildMapDimensions(),d.triggerEvent("onstopanimation",a))};a.currentAnimationStep=0;a.animationList=void 0;a.isAnimating=!1;a.setAnimationDelay=function(b){1>b&&(b=1);a.animationDelay=b};b.style.zIndex=1E4;b.style.background="none";b.style.position="absolute";b.style.border="none";b.style.margin="0px";b.style.padding="0px";b.style.lineHeight="14px";b.style.fontFamily='"Courier New", "Lucida Console", Monospace';
  b.style.fontSize="10px";a.getBaseElement().append(b)};var WMJSDialog={},WMJSDialogsCreated=0;WMJSDialog.closeAllDialogs=function(a){for(var d=0;d<a.length;d++)a[d].remove()};
  WMJSDialog.createDialog=function(a,d,c){WMJSDialogsCreated++;var l=0,b=0,f=!0,m=!0;isDefined(a.id);isDefined(a.show)&&(f=a.show);isDefined(a.x)&&(l=a.x);isDefined(a.y)&&(b=a.y);isDefined(a.autoDestroy)&&(m=a.autoDestroy);var k=jQuery("<div />",{css:{minHeight:"20px",height:180,width:320,zIndex:1E3,border:"1px solid #01405e",borderRadius:"3px",position:"absolute",boxShadow:"0.06rem 0.125rem 0.125rem rgba(0, 0, 0, 0.3)",margin:0,padding:"0px",backgroundColor:"#01547d",display:"inline-block"},mousedown:function(a){a.stopPropagation();
  preventdefault_event(a)},mousewheel:function(a){a.stopPropagation()}});f&&k.appendTo(d);k.hasBeenDragged=!1;k.on("drag",function(a,b){k.hasBeenDragged=!0});k.resizable();k.draggable();k.closeDialog=function(){0==m?(k.hide(),k.trigger("hide")):(k.remove(),dialogClosed(k))};k.keyup(function(a){27==a.keyCode&&k.closeDialog()});jQuery("<div/>",{css:{color:"white",fontWeight:"bold",textColor:"white",width:"16px",height:"16px",lineHeight:"14px",margin:"1px",padding:"1px !important",zIndex:1200},click:function(){k.closeDialog()}}).appendTo(k).iconbutton({label:"X"}).addClass("wmjsdialog-closebutton");
  var t=jQuery("<div/>",{css:{position:"absolute",right:"0px",top:"18px",background:"#FFF",borderTop:"1px solid #01405e",width:"100%",height:"100%",overflow:"auto",fontSize:"10px",lineHeight:"12px"},mousedown:function(a){a.stopPropagation();preventdefault_event(a)}}).appendTo(k);k.resize(function(){t.css({width:k.width()+"px",height:k.height()-18+"px"})});k.resize();k.setLoading=function(){t.html('<img style="margin-left:10px;margin-top:10px;" src="'+loadingImageSrc+'"/>')};k.setXY=function(a,b){k.hasBeenDragged=
  !1;k.css({left:a+"px",top:b+"px"});var d=c.getGeoCoordFromPixelCoord({x:a,y:b});k.geoPosX=d.x;k.geoPosY=d.y;k.x=a;k.y=b};k.setXY(l,b);k.origX=l;k.origY=b;k.setLoading();k.setHTML=function(a){t.html(a)};isDefined(a.dataURL)&&(d=function(a){t.html(a)},MakeHTTPRequest(a.dataURL,d,d));return k};
  