UNPKG

nominatim-geocode

Version:
3 lines (2 loc) 7.16 kB
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.nominatim={})}(this,function(e){"use strict";function n(e,n){return e(n={exports:{}},n.exports),n.exports}var o=1e3,s=6e4,a=36e5,i=24*a,r=function(e,n){n=n||{};var r,t=typeof e;if("string"===t&&0<e.length)return function(e){if(100<(e=String(e)).length)return;var n=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!n)return;var r=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"days":case"day":case"d":return r*i;case"hours":case"hour":case"hrs":case"hr":case"h":return r*a;case"minutes":case"minute":case"mins":case"min":case"m":return r*s;case"seconds":case"second":case"secs":case"sec":case"s":return r*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===t&&!1===isNaN(e))return n.long?c(r=e,i,"day")||c(r,a,"hour")||c(r,s,"minute")||c(r,o,"second")||r+" ms":function(e){if(i<=e)return Math.round(e/i)+"d";if(a<=e)return Math.round(e/a)+"h";if(s<=e)return Math.round(e/s)+"m";if(o<=e)return Math.round(e/o)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function c(e,n,r){if(!(e<n))return e<1.5*n?Math.floor(e/n)+" "+r:Math.ceil(e/n)+" "+r+"s"}var t=n(function(e,c){var u;function n(e){function i(){var e=arguments;if(i.enabled){var o=i,n=+new Date,r=n-(u||n);o.diff=r,o.prev=u,o.curr=n,u=n;for(var s=new Array(arguments.length),t=0;t<s.length;t++)s[t]=e[t];s[0]=c.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var a=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(e,n){if("%%"===e)return e;a++;var r=c.formatters[n];if("function"==typeof r){var t=s[a];e=r.call(o,t),s.splice(a,1),a--}return e}),c.formatArgs.call(o,s),(i.log||c.log||console.log.bind(console)).apply(o,s)}}return i.namespace=e,i.enabled=c.enabled(e),i.useColors=c.useColors(),i.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return c.colors[Math.abs(r)%c.colors.length]}(e),"function"==typeof c.init&&c.init(i),i}(c=e.exports=n.debug=n.default=n).coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},c.disable=function(){c.enable("")},c.enable=function(e){c.save(e),c.names=[],c.skips=[];for(var n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length,t=0;t<r;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?c.skips.push(new RegExp("^"+e.substr(1)+"$")):c.names.push(new RegExp("^"+e+"$")))},c.enabled=function(e){var n,r;for(n=0,r=c.skips.length;n<r;n++)if(c.skips[n].test(e))return!1;for(n=0,r=c.names.length;n<r;n++)if(c.names[n].test(e))return!0;return!1},c.humanize=r,c.names=[],c.skips=[],c.formatters={}}),u=(t.coerce,t.disable,t.enable,t.enabled,t.humanize,t.names,t.skips,t.formatters,n(function(e,s){function n(){var e;try{e=s.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(s=e.exports=t).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},s.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+s.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var t=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(t++,"%c"===e&&(o=t))}),e.splice(o,0,r)},s.save=function(e){try{null==e?s.storage.removeItem("debug"):s.storage.debug=e}catch(e){}},s.load=n,s.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},s.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),s.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],s.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},s.enable(n())})),d=(u.log,u.formatArgs,u.save,u.load,u.useColors,u.storage,u.colors,u("jsonp")),l=function(e,n,r){"function"==typeof n&&(r=n,n={});n||(n={});var t,o,s=n.prefix||"__jp",a=n.name||s+p++,i=n.param||"callback",c=null!=n.timeout?n.timeout:6e4,u=encodeURIComponent,l=document.getElementsByTagName("script")[0]||document.head;c&&(o=setTimeout(function(){f(),r&&r(new Error("Timeout"))},c));function f(){t.parentNode&&t.parentNode.removeChild(t),window[a]=m,o&&clearTimeout(o)}return window[a]=function(e){d("jsonp got",e),f(),r&&r(null,e)},e=(e+=(~e.indexOf("?")?"&":"?")+i+"="+u(a)).replace("?&","?"),d('jsonp req "%s"',e),(t=document.createElement("script")).src=e,l.parentNode.insertBefore(t,l),function(){window[a]&&f()}},p=0;function m(){}var f=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})},g="%[a-f0-9]{2}";new RegExp(g,"gi"),new RegExp("("+g+")+","gi");function h(e,n){return n.encode?n.strict?f(e):encodeURIComponent(e):e}var v=function(a,i){!1===(i=Object.assign({encode:!0,strict:!0,arrayFormat:"none"},i)).sort&&(i.sort=function(){});var c=function(t){switch(t.arrayFormat){case"index":return function(e,n,r){return null===n?[h(e,t),"[",r,"]"].join(""):[h(e,t),"[",h(r,t),"]=",h(n,t)].join("")};case"bracket":return function(e,n){return null===n?[h(e,t),"[]"].join(""):[h(e,t),"[]=",h(n,t)].join("")};default:return function(e,n){return null===n?h(e,t):[h(e,t),"=",h(n,t)].join("")}}}(i);return a?Object.keys(a).sort(i.sort).map(function(e){var n=a[e];if(void 0===n)return"";if(null===n)return h(e,i);if(Array.isArray(n)){for(var r=[],t=0,o=n.slice();t<o.length;t+=1){var s=o[t];void 0!==s&&r.push(c(e,s,r.length))}return r.join("&")}return h(e,i)+"="+h(n,i)}).filter(function(e){return 0<e.length}).join("&"):""},y="nominatim_callback_",w="https://nominatim.openstreetmap.org/",b=0,x=function(){};e.geocode=function(e,r,t){void 0===e&&(e={q:""}),void 0===r&&(r=x),e.format="json",e.addressdetails=1;var n=w+"search?"+v(e),o=e.callback||y+b++;l(n,{prefix:y,param:"json_callback",name:o},function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];console.log(e),r.apply(t,e)})},e.reverse=function(e,r,t){void 0===e&&(e={}),void 0===r&&(r=x),e.format="json",e.addressdetails=1;var n=w+"reverse?"+v(e),o=e.callback||y+b++;l(n,{prefix:y,param:"json_callback",name:o},function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];r.apply(t,e)})},Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=nominatim.min.js.map