tileserver-gl-light 4.6.5 → 4.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/public/resources/maplibre-gl-inspect.min.js +1 -1
- package/src/main.js +17 -4
- package/src/serve_rendered.js +29 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tileserver-gl-light",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.6",
|
|
4
4
|
"description": "Map tile server for JSON GL styles - serving vector tiles",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"bin": "src/main.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@maplibre/maplibre-gl-style-spec": "18.0.0",
|
|
26
26
|
"@sindresorhus/fnv1a": "3.0.0",
|
|
27
27
|
"advanced-pool": "0.3.3",
|
|
28
|
+
"axios": "^1.6.1",
|
|
28
29
|
"chokidar": "3.5.3",
|
|
29
30
|
"clone": "2.1.2",
|
|
30
31
|
"color": "4.2.3",
|
|
@@ -37,7 +38,6 @@
|
|
|
37
38
|
"pbf": "3.2.1",
|
|
38
39
|
"pmtiles": "2.11.0",
|
|
39
40
|
"proj4": "2.9.2",
|
|
40
|
-
"request": "2.88.2",
|
|
41
41
|
"sanitize-filename": "1.6.3",
|
|
42
42
|
"tileserver-gl-styles": "2.0.0"
|
|
43
43
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MaplibreInspect=t()}(function(){return function o(r,i,s){function a(e,t){if(!i[e]){if(!r[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(c)return c(e,!0);throw(t=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",t}n=i[e]={exports:{}},r[e][0].call(n.exports,function(t){return a(r[e][1][t]||t)},n,n.exports,o,r,i,s)}return i[e].exports}for(var c="function"==typeof require&&require,t=0;t<s.length;t++)a(s[t]);return a}({1:[function(t,e,n){t=t("./lib/MaplibreInspect");e.exports=t},{"./lib/MaplibreInspect":3}],2:[function(t,e,n){function o(t){var e,n;t=Object.assign({show:!0,onToggle(){}},t),this._btn=((e=document.createElement("button")).className="maplibregl-ctrl-icon maplibregl-ctrl-inspect",e.type="button",e["aria-label"]="Inspect",e),this._btn.onclick=t.onToggle,this.elem=(e=this._btn,t=t.show,(n=document.createElement("div")).className="maplibregl-ctrl maplibregl-ctrl-group",n.appendChild(e),t||(n.style.display="none"),n)}o.prototype.setInspectIcon=function(){this._btn.className="maplibregl-ctrl-icon maplibregl-ctrl-inspect"},o.prototype.setMapIcon=function(){this._btn.className="maplibregl-ctrl-icon maplibregl-ctrl-map"},e.exports=o},{}],3:[function(t,e,n){const o=t("./stylegen"),r=t("./InspectButton"),i=t("lodash.isequal"),s=t("./renderPopup"),a=t("./colors");function c(t){if(!(this instanceof c))throw new Error("MaplibreInspect needs to be called with the new keyword");let e=null;window.maplibregl?e=new window.maplibregl.Popup({closeButton:!1,closeOnClick:!1}):t.popup||console.error("Maplibre GL JS can not be found. Make sure to include it or pass an initialized MaplibreGL Popup to MaplibreInspect if you are using moduleis."),this.options=Object.assign({showInspectMap:!1,showInspectButton:!0,showInspectMapPopup:!0,showMapPopup:!1,showMapPopupOnHover:!0,showInspectMapPopupOnHover:!0,blockHoverPopupOnClick:!1,backgroundColor:"#fff",assignLayerColor:a.brightColor,buildInspectStyle:o.generateInspectStyle,renderPopup:s,popup:e,selectThreshold:5,useInspectStyle:!0,queryParameters:{},sources:{},toggleCallback(){}},t),this.sources=this.options.sources,this.assignLayerColor=this.options.assignLayerColor,this.toggleInspector=this.toggleInspector.bind(this),this._popup=this.options.popup,this._popupBlocked=!1,this._showInspectMap=this.options.showInspectMap,this._onSourceChange=this._onSourceChange.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onRightClick=this._onRightClick.bind(this),this._onStyleChange=this._onStyleChange.bind(this),this._originalStyle=null,this._toggle=new r({show:this.options.showInspectButton,onToggle:this.toggleInspector.bind(this)})}c.prototype.toggleInspector=function(){this._showInspectMap=!this._showInspectMap,this.options.toggleCallback(this._showInspectMap),this.render()},c.prototype._inspectStyle=function(){var t=o.generateColoredLayers(this.sources,this.assignLayerColor);return this.options.buildInspectStyle(this._map.getStyle(),t,{backgroundColor:this.options.backgroundColor})},c.prototype.render=function(){var t;this._showInspectMap?(this.options.useInspectStyle&&this._map.setStyle((t=this._inspectStyle(),Object.assign(t,{metadata:Object.assign({},t.metadata,{"maplibregl-inspect:inspect":!0})}))),this._toggle.setMapIcon()):this._originalStyle&&(this._popup&&this._popup.remove(),this.options.useInspectStyle&&this._map.setStyle(this._originalStyle),this._toggle.setInspectIcon())},c.prototype._onSourceChange=function(t){const o=this.sources,r=this._map;var e=r.getStyle();const n=Object.keys(e.sources);e=Object.assign({},o);"visibility"!==t.sourceDataType&&t.isSourceLoaded&&(Object.keys(r.style.sourceCaches).forEach(t=>{var e=r.style.sourceCaches[t]||{_source:{}},n=e._source.vectorLayerIds;n?o[t]=n:"geojson"===e._source.type&&(o[t]=[])}),Object.keys(o).forEach(t=>{-1===n.indexOf(t)&&delete o[t]}),!i(e,o))&&0<Object.keys(o).length&&this.render()},c.prototype._onStyleChange=function(){var t,e=this._map.getStyle();(t=e).metadata&&t.metadata["maplibregl-inspect:inspect"]||(this._originalStyle=e)},c.prototype._onRightClick=function(){this.options.showMapPopupOnHover||this.options.showInspectMapPopupOnHover||this.options.blockHoverPopupOnClick||this._popup&&this._popup.remove()},c.prototype._onMousemove=function(e){if(this._showInspectMap){if(!this.options.showInspectMapPopup)return;if("mousemove"===e.type&&!this.options.showInspectMapPopupOnHover)return;"click"===e.type&&this.options.showInspectMapPopupOnHover&&this.options.blockHoverPopupOnClick&&(this._popupBlocked=!this._popupBlocked)}else{if(!this.options.showMapPopup)return;if("mousemove"===e.type&&!this.options.showMapPopupOnHover)return;"click"===e.type&&this.options.showMapPopupOnHover&&this.options.blockHoverPopupOnClick&&(this._popupBlocked=!this._popupBlocked)}if(!this._popupBlocked&&this._popup){let t;t=0===this.options.selectThreshold?e.point:[[e.point.x-this.options.selectThreshold,e.point.y+this.options.selectThreshold],[e.point.x+this.options.selectThreshold,e.point.y-this.options.selectThreshold]];var n=this._map.queryRenderedFeatures(t,this.options.queryParameters)||[];this._map.getCanvas().style.cursor=n.length?"pointer":"",n.length?(this._popup.setLngLat(e.lngLat),"string"==typeof(e=this.options.renderPopup(n))?this._popup.setHTML(e):this._popup.setDOMContent(e),this._popup.addTo(this._map)):this._popup.remove()}},c.prototype.onAdd=function(t){return this._map=t,0===Object.keys(this.sources).length&&(t.on("tiledata",this._onSourceChange),t.on("sourcedata",this._onSourceChange)),t.on("styledata",this._onStyleChange),t.on("load",this._onStyleChange),t.on("mousemove",this._onMousemove),t.on("click",this._onMousemove),t.on("contextmenu",this._onRightClick),this._toggle.elem},c.prototype.onRemove=function(){this._map.off("styledata",this._onStyleChange),this._map.off("load",this._onStyleChange),this._map.off("tiledata",this._onSourceChange),this._map.off("sourcedata",this._onSourceChange),this._map.off("mousemove",this._onMousemove),this._map.off("click",this._onMousemove),this._map.off("contextmenu",this._onRightClick);var t=this._toggle.elem;t.parentNode.removeChild(t),this._map=void 0},e.exports=c},{"./InspectButton":2,"./colors":4,"./renderPopup":5,"./stylegen":6,"lodash.isequal":7}],4:[function(t,e,n){const r=t("randomcolor");n.brightColor=function(t,e){let n="bright",o=null;return/water|ocean|lake|sea|river/.test(t)&&(o="blue"),/state|country|place/.test(t)&&(o="pink"),/road|highway|transport|streets/.test(t)&&(o="orange"),/contour|building/.test(t)&&(o="monochrome"),/building/.test(t)&&(n="dark"),/contour|landuse/.test(t)&&(o="yellow"),/wood|forest|park|landcover|land/.test(t)&&(o="green"),`rgba(${r({luminosity:n,hue:o,seed:t,format:"rgbArray"}).concat([e||1]).join(", ")})`}},{randomcolor:8}],5:[function(t,e,n){function r(t,e){return`<div class="maplibregl-inspect_property"><div class="maplibregl-inspect_property-name">${t}</div>`+`<div class="maplibregl-inspect_property-value">${t=e,null==t?t:t instanceof Date?t.toLocaleString():"object"==typeof t||"number"==typeof t||"string"==typeof t?t.toString():t}</div>`+"</div>"}function o(t){return t.map(t=>{return`<div class="maplibregl-inspect_feature">${e=t,t=`<div class="maplibregl-inspect_layer">${e.layer["source-layer"]||e.layer.source}</div>`,n=r("$type",e.geometry.type),o=Object.keys(e.properties).map(t=>r(t,e.properties[t])),[t,n].concat(o).join("")}</div>`;var e,n,o}).join("")}e.exports=function(t){return`<div class="maplibregl-inspect_popup">${o(t)}</div>`}},{}],6:[function(t,e,n){function a(t,e,n){e={id:[e,n,"circle"].join("_"),source:e,type:"circle",paint:{"circle-color":t,"circle-radius":2},filter:["==","$type","Point"]};return n&&(e["source-layer"]=n),e}function c(t,e,n,o){n={id:[n,o,"polygon"].join("_"),source:n,type:"fill",paint:{"fill-color":t,"fill-antialias":!0,"fill-outline-color":t},filter:["==","$type","Polygon"]};return o&&(n["source-layer"]=o),n}function u(t,e,n){e={id:[e,n,"line"].join("_"),source:e,layout:{"line-join":"round","line-cap":"round"},type:"line",paint:{"line-color":t},filter:["==","$type","LineString"]};return n&&(e["source-layer"]=n),e}n.polygonLayer=c,n.lineLayer=u,n.circleLayer=a,n.generateInspectStyle=function(n,t,e){e={id:"background",type:"background",paint:{"background-color":(e=Object.assign({backgroundColor:"#fff"},e)).backgroundColor}};const o={};return Object.keys(n.sources).forEach(t=>{var e=n.sources[t];"vector"!==e.type&&"geojson"!==e.type||(o[t]=e)}),Object.assign(n,{layers:[e].concat(t),sources:o})},n.generateColoredLayers=function(e,n){const o=[],r=[],i=[];function s(t){t=n.bind(null,t);return{circle:t(.8),line:t(.6),polygon:t(.3),polygonOutline:t(.6),default:t(1)}}return Object.keys(e).forEach(n=>{var t=e[n];t&&0!==t.length?t.forEach(t=>{var e=s(t);r.push(a(e.circle,n,t)),i.push(u(e.line,n,t)),o.push(c(e.polygon,e.polygonOutline,n,t))}):(t=s(n),r.push(a(t.circle,n)),i.push(u(t.line,n)),o.push(c(t.polygon,t.polygonOutline,n)))}),o.concat(i).concat(r)}},{}],7:[function(t,Bt,Ft){!function($t){!function(){var o="__lodash_hash_undefined__",T=1,J=2,O=9007199254740991,$="[object Arguments]",B="[object Array]",M="[object AsyncFunction]",X="[object Boolean]",K="[object Date]",Q="[object Error]",I="[object Function]",C="[object GeneratorFunction]",F="[object Map]",Y="[object Number]",S="[object Null]",H="[object Object]",A="[object Promise]",P="[object Proxy]",Z="[object RegExp]",N="[object Set]",tt="[object String]",et="[object Symbol]",z="[object Undefined]",n="[object WeakMap]",nt="[object ArrayBuffer]",q="[object DataView]",L=/^\[object .+?Constructor\]$/,x=/^(?:0|[1-9]\d*)$/,e={},t=(e["[object Float32Array]"]=e["[object Float64Array]"]=e["[object Int8Array]"]=e["[object Int16Array]"]=e["[object Int32Array]"]=e["[object Uint8Array]"]=e["[object Uint8ClampedArray]"]=e["[object Uint16Array]"]=e["[object Uint32Array]"]=!0,e[$]=e[B]=e[nt]=e[X]=e[q]=e[K]=e[Q]=e[I]=e[F]=e[Y]=e[H]=e[Z]=e[N]=e[tt]=e[n]=!1,"object"==typeof $t&&$t&&$t.Object===Object&&$t),r="object"==typeof self&&self&&self.Object===Object&&self,r=t||r||Function("return this")(),i="object"==typeof Ft&&Ft&&!Ft.nodeType&&Ft,s=i&&"object"==typeof Bt&&Bt&&!Bt.nodeType&&Bt,s=s&&s.exports===i,a=s&&t.process,i=function(){try{return a&&a.binding&&a.binding("util")}catch(t){}}(),t=i&&i.isTypedArray;function ot(t){var n=-1,o=Array(t.size);return t.forEach(function(t,e){o[++n]=[e,t]}),o}function rt(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var R,E,i=Array.prototype,c=Function.prototype,u=Object.prototype,l=r["__core-js_shared__"],it=c.toString,D=u.hasOwnProperty,st=(c=/[^.]+$/.exec(l&&l.keys&&l.keys.IE_PROTO||""))?"Symbol(src)_1."+c:"",at=u.toString,ct=RegExp("^"+it.call(D).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),l=s?r.Buffer:void 0,c=r.Symbol,ut=r.Uint8Array,lt=u.propertyIsEnumerable,pt=i.splice,p=c?c.toStringTag:void 0,ht=Object.getOwnPropertySymbols,s=l?l.isBuffer:void 0,ft=(R=Object.keys,E=Object,function(t){return R(E(t))}),i=j(r,"DataView"),h=j(r,"Map"),l=j(r,"Promise"),f=j(r,"Set"),r=j(r,"WeakMap"),d=j(Object,"create"),dt=k(i),gt=k(h),yt=k(l),_t=k(f),bt=k(r),c=c?c.prototype:void 0,vt=c?c.valueOf:void 0;function g(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function y(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function _(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function b(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new _;++e<n;)this.add(t[e])}function U(t){t=this.__data__=new y(t);this.size=t.size}function mt(t,e){var n,o,r,i=V(t),s=!i&&At(t),a=!i&&!s&&Pt(t),c=!i&&!s&&!a&&Et(t),u=i||s||a||c,l=u?function(t,e){for(var n=-1,o=Array(t);++n<t;)o[n]=e(n);return o}(t.length,String):[],p=l.length;for(n in t)!e&&!D.call(t,n)||u&&("length"==n||a&&("offset"==n||"parent"==n)||c&&("buffer"==n||"byteLength"==n||"byteOffset"==n)||(o=n,(r=null==(r=p)?O:r)&&("number"==typeof o||x.test(o))&&-1<o&&o%1==0&&o<r))||l.push(n);return l}function v(t,e){for(var n=t.length;n--;)if(St(t[n][0],e))return n;return-1}function m(t){if(null==t)return void 0===t?z:S;if(p&&p in Object(t)){var e=t,n=D.call(e,p),o=e[p];try{var r=!(e[p]=void 0)}catch(t){}var i=at.call(e);return r&&(n?e[p]=o:delete e[p]),i}return at.call(t)}function wt(t){return W(t)&&m(t)==$}function jt(t,e,n,o,r){if(t===e)return!0;if(null==t||null==e||!W(t)&&!W(e))return t!=t&&e!=e;var i=jt,s=V(t),a=V(e),c=s?B:G(t),a=a?B:G(e),u=(c=c==$?H:c)==H,l=(a=a==$?H:a)==H;if((a=c==a)&&Pt(t)){if(!Pt(e))return!1;u=!(s=!0)}if(a&&!u){r=r||new U;if(s||Et(t))return Mt(t,e,n,o,i,r);else{var p=t;var h=e;var f=c;var d=n;var g=o;var y=i;var _=r;switch(f){case q:if(p.byteLength!=h.byteLength||p.byteOffset!=h.byteOffset)return!1;p=p.buffer,h=h.buffer;case nt:return p.byteLength==h.byteLength&&y(new ut(p),new ut(h))?!0:!1;case X:case K:case Y:return St(+p,+h);case Q:return p.name==h.name&&p.message==h.message;case Z:case tt:return p==h+"";case F:var b=ot;case N:var v=d&T;if(b=b||rt,p.size!=h.size&&!v)return!1;v=_.get(p);if(v)return v==h;d|=J,_.set(p,h);v=Mt(b(p),b(h),d,g,y,_);return _.delete(p),v;case et:if(vt)return vt.call(p)==vt.call(h)}return!1;return}}if(!(n&T)){var s=u&&D.call(t,"__wrapped__"),c=l&&D.call(e,"__wrapped__");if(s||c)return u=s?t.value():t,l=c?e.value():e,r=r||new U,i(u,l,n,o,r)}if(a){r=r||new U;var m=t,w=e,j=n,k=o,O=i,M=r,I=j&T,C=It(m),S=C.length,s=It(w).length;if(S!=s&&!I)return!1;for(var A=S;A--;){var P=C[A];if(!(I?P in w:D.call(w,P)))return!1}if((s=M.get(m))&&M.get(w))return s==w;for(var z=!0,L=(M.set(m,w),M.set(w,m),I);++A<S;){P=C[A];var x,R=m[P],E=w[P];if(!(void 0===(x=k?I?k(E,R,P,w,m,M):k(R,E,P,m,w,M):x)?R===E||O(R,E,j,k,M):x)){z=!1;break}L=L||"constructor"==P}return z&&!L&&(s=m.constructor,c=w.constructor,s!=c)&&"constructor"in m&&"constructor"in w&&!("function"==typeof s&&s instanceof s&&"function"==typeof c&&c instanceof c)&&(z=!1),M.delete(m),M.delete(w),z}return!1}function kt(t){var e;return xt(t)&&(e=t,!(st&&st in e))&&(zt(t)?ct:L).test(k(t))}function Ot(t){if(n="function"==typeof(n=(e=t)&&e.constructor)&&n.prototype||u,e!==n)return ft(t);var e,n,o,r=[];for(o in Object(t))D.call(t,o)&&"constructor"!=o&&r.push(o);return r}function Mt(t,e,n,o,r,i){var s=n&T,a=t.length,c=e.length;if(a!=c&&!(s&&a<c))return!1;c=i.get(t);if(c&&i.get(e))return c==e;var u=-1,l=!0,p=n&J?new b:void 0;for(i.set(t,e),i.set(e,t);++u<a;){var h,f=t[u],d=e[u];if(void 0!==(h=o?s?o(d,f,u,e,t,i):o(f,d,u,t,e,i):h)){if(h)continue;l=!1;break}if(p){if(!function(t,e){for(var n=-1,o=null==t?0:t.length;++n<o;)if(e(t[n],n,t))return 1}(e,function(t,e){return!p.has(e)&&(f===t||r(f,t,n,o,i))&&p.push(e)})){l=!1;break}}else if(f!==d&&!r(f,d,n,o,i)){l=!1;break}}return i.delete(t),i.delete(e),l}function It(t){var e=Tt,n=Ct;if(e=e(t),V(t))return e;for(var o=e,r=n(t),i=-1,s=r.length,a=o.length;++i<s;)o[a+i]=r[i];return o}function w(t,e){var n,o,t=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?t["string"==typeof e?"string":"hash"]:t.map}function j(t,e){e=e;t=null==(t=t)?void 0:t[e];return kt(t)?t:void 0}g.prototype.clear=function(){this.__data__=d?d(null):{},this.size=0},g.prototype.delete=function(t){return t=this.has(t)&&delete this.__data__[t],this.size-=t?1:0,t},g.prototype.get=function(t){var e,n=this.__data__;return d?(e=n[t])===o?void 0:e:D.call(n,t)?n[t]:void 0},g.prototype.has=function(t){var e=this.__data__;return d?void 0!==e[t]:D.call(e,t)},g.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=d&&void 0===e?o:e,this},y.prototype.clear=function(){this.__data__=[],this.size=0},y.prototype.delete=function(t){var e=this.__data__;return!((t=v(e,t))<0||(t==e.length-1?e.pop():pt.call(e,t,1),--this.size,0))},y.prototype.get=function(t){var e=this.__data__;return(t=v(e,t))<0?void 0:e[t][1]},y.prototype.has=function(t){return-1<v(this.__data__,t)},y.prototype.set=function(t,e){var n=this.__data__,o=v(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this},_.prototype.clear=function(){this.size=0,this.__data__={hash:new g,map:new(h||y),string:new g}},_.prototype.delete=function(t){return t=w(this,t).delete(t),this.size-=t?1:0,t},_.prototype.get=function(t){return w(this,t).get(t)},_.prototype.has=function(t){return w(this,t).has(t)},_.prototype.set=function(t,e){var n=w(this,t),o=n.size;return n.set(t,e),this.size+=n.size==o?0:1,this},b.prototype.add=b.prototype.push=function(t){return this.__data__.set(t,o),this},b.prototype.has=function(t){return this.__data__.has(t)},U.prototype.clear=function(){this.__data__=new y,this.size=0},U.prototype.delete=function(t){var e=this.__data__,t=e.delete(t);return this.size=e.size,t},U.prototype.get=function(t){return this.__data__.get(t)},U.prototype.has=function(t){return this.__data__.has(t)},U.prototype.set=function(t,e){var n=this.__data__;if(n instanceof y){var o=n.__data__;if(!h||o.length<199)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new _(o)}return n.set(t,e),this.size=n.size,this};var Ct=ht?function(e){if(null==e)return[];e=Object(e);for(var t=ht(e),n=function(t){return lt.call(e,t)},o=-1,r=null==t?0:t.length,i=0,s=[];++o<r;){var a=t[o];n(a,o,t)&&(s[i++]=a)}return s}:function(){return[]},G=m;function k(t){if(null!=t){try{return it.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function St(t,e){return t===e||t!=t&&e!=e}(i&&G(new i(new ArrayBuffer(1)))!=q||h&&G(new h)!=F||l&&G(l.resolve())!=A||f&&G(new f)!=N||r&&G(new r)!=n)&&(G=function(t){var e=m(t),t=e==H?t.constructor:void 0,t=t?k(t):"";if(t)switch(t){case dt:return q;case gt:return F;case yt:return A;case _t:return N;case bt:return n}return e});var At=wt(function(){return arguments}())?wt:function(t){return W(t)&&D.call(t,"callee")&&!lt.call(t,"callee")},V=Array.isArray;var Pt=s||function(){return!1};function zt(t){if(xt(t))return(t=m(t))==I||t==C||t==M||t==P}function Lt(t){return"number"==typeof t&&-1<t&&t%1==0&&t<=O}function xt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function W(t){return null!=t&&"object"==typeof t}var Rt,Et=t?(Rt=t,function(t){return Rt(t)}):function(t){return W(t)&&Lt(t.length)&&!!e[m(t)]};function Tt(t){return(null!=(e=t)&&Lt(e.length)&&!zt(e)?mt:Ot)(t);var e}Bt.exports=function(t,e){return jt(t,e)}}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(t,e,n){var o,r,i;o=this,r=function(){function h(t){if(void 0!==(t=t||{}).seed&&null!==t.seed&&t.seed===parseInt(t.seed,10))f=t.seed;else if("string"==typeof t.seed)f=function(t){for(var e=0,n=0;n!==t.length&&!(e>=Number.MAX_SAFE_INTEGER);n++)e+=t.charCodeAt(n);return e}(t.seed);else{if(void 0!==t.seed&&null!==t.seed)throw new TypeError("The seed value must be an integer or string");f=null}var e,n;if(null!==t.count&&void 0!==t.count){for(var o=t.count,r=[],i=0;i<t.count;i++)g.push(!1);for(t.count=null;r.length<o;){var s=h(t);null!==f&&(t.seed=f),r.push(s)}return t.count=o,r}var a=function(t,e,n){var o=function(t,e){for(var n=y(t).lowerBounds,o=0;o<n.length-1;o++){var r=n[o][0],i=n[o][1],s=n[o+1][0],a=n[o+1][1];if(r<=e&&e<=s)return(a=(a-i)/(s-r))*e+(i-a*r)}return 0}(t,e),r=100;switch(n.luminosity){case"dark":r=o+20;break;case"light":o=(r+o)/2;break;case"random":o=0,r=100}return _([o,r])}(e=function(t){{var e,n,o,r,i;return e=0<g.length?(e=_(i=function(t){if(isNaN(t)){if("string"==typeof t)if(d[t]){var e=d[t];if(e.hueRange)return e.hueRange}else if(t.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return y(v(t)[0]).hueRange}else{e=parseInt(t);if(e<360&&0<e)return y(t).hueRange}return[0,360]}(t.hue)),n=(i[1]-i[0])/g.length,r=parseInt((e-i[0])/n),!0===g[r]?r=(r+2)%g.length:g[r]=!0,o=(i[0]+r*n)%359,r=(i[0]+(r+1)*n)%359,(e=_(i=[o,r]))<0?360+e:e):(i=function(t){if("number"==typeof parseInt(t)){var e=parseInt(t);if(e<360&&0<e)return[e,e]}if("string"==typeof t)if(d[t]){e=d[t];if(e.hueRange)return e.hueRange}else if(t.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return[e=v(t)[0],e];return[0,360]}(t.hue),(e=_(i))<0?360+e:e)}}(t),n=function(t,e){if("monochrome"===e.hue)return 0;if("random"===e.luminosity)return _([0,100]);var t=function(t){return y(t).saturationRange}(t),n=t[0],o=t[1];switch(e.luminosity){case"bright":n=55;break;case"dark":n=o-10;break;case"light":o=55}return _([n,o])}(e,t),t),c=[e,n,a],u=t;switch(u.format){case"hsvArray":return c;case"hslArray":return m(c);case"hsl":var l=m(c);return"hsl("+l[0]+", "+l[1]+"%, "+l[2]+"%)";case"hsla":var l=m(c),p=u.alpha||Math.random();return"hsla("+l[0]+", "+l[1]+"%, "+l[2]+"%, "+p+")";case"rgbArray":return b(c);case"rgb":return"rgb("+b(c).join(", ")+")";case"rgba":l=b(c),p=u.alpha||Math.random();return"rgba("+l.join(", ")+", "+p+")";default:return function(t){t=b(t);function e(t){t=t.toString(16);return 1==t.length?"0"+t:t}return"#"+e(t[0])+e(t[1])+e(t[2])}(c)}}var f=null,d={},g=(t("monochrome",null,[[0,0],[100,0]]),t("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),t("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),t("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),t("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),t("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),t("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),t("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]),[]);function y(t){for(var e in 334<=t&&t<=360&&(t-=360),d){var n=d[e];if(n.hueRange&&t>=n.hueRange[0]&&t<=n.hueRange[1])return d[e]}return"Color not found"}function _(t){var e,n;return null===f?(e=(Math.random()+.618033988749895)%1,Math.floor(t[0]+e*(t[1]+1-t[0]))):(e=t[1]||1,t=t[0]||0,n=(f=(9301*f+49297)%233280)/233280,Math.floor(t+n*(e-t)))}function t(t,e,n){var o=n[0][0],r=n[n.length-1][0],i=n[n.length-1][1],s=n[0][1];d[t]={hueRange:e,lowerBounds:n,saturationRange:[o,r],brightnessRange:[i,s]}}function b(t){var e=t[0],n=(360===(e=0===e?1:e)&&(e=359),e/=360,t[1]/100),o=t[2]/100,t=Math.floor(6*e),e=6*e-t,r=o*(1-n),i=o*(1-e*n),s=o*(1-(1-e)*n),a=256,c=256,u=256;switch(t){case 0:a=o,c=s,u=r;break;case 1:a=i,c=o,u=r;break;case 2:a=r,c=o,u=s;break;case 3:a=r,c=i,u=o;break;case 4:a=s,c=r,u=o;break;case 5:a=o,c=r,u=i}return[Math.floor(255*a),Math.floor(255*c),Math.floor(255*u)]}function v(t){t=3===(t=t.replace(/^#/,"")).length?t.replace(/(.)/g,"$1$1"):t;var e=parseInt(t.substr(0,2),16)/255,n=parseInt(t.substr(2,2),16)/255,o=parseInt(t.substr(4,2),16)/255,r=Math.max(e,n,o),i=r-Math.min(e,n,o),s=r?i/r:0;switch(r){case e:return[(n-o)/i%6*60||0,s,r];case n:return[60*((o-e)/i+2)||0,s,r];case o:return[60*((e-n)/i+4)||0,s,r]}}function m(t){var e=t[0],n=t[1]/100,t=t[2]/100,o=(2-n)*t;return[e,Math.round(n*t/(o<1?o:2-o)*1e4)/100,o/2*100]}return h},"object"==typeof n?(i=r(),(n="object"==typeof e&&e&&e.exports?e.exports=i:n).randomColor=i):o.randomColor=r()},{}]},{},[1])(1)});
|
|
1
|
+
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MaplibreInspect=t()}(function(){return function r(o,i,s){function a(e,t){if(!i[e]){if(!o[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(c)return c(e,!0);throw(t=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",t}n=i[e]={exports:{}},o[e][0].call(n.exports,function(t){return a(o[e][1][t]||t)},n,n.exports,r,o,i,s)}return i[e].exports}for(var c="function"==typeof require&&require,t=0;t<s.length;t++)a(s[t]);return a}({1:[function(t,e,n){t=t("./lib/MaplibreInspect");e.exports=t},{"./lib/MaplibreInspect":3}],2:[function(t,e,n){function r(t){var e,n;t=Object.assign({show:!0,onToggle(){}},t),this._btn=((e=document.createElement("button")).className="maplibregl-ctrl-icon maplibregl-ctrl-inspect",e.type="button",e["aria-label"]="Inspect",e),this._btn.onclick=t.onToggle,this.elem=(e=this._btn,t=t.show,(n=document.createElement("div")).className="maplibregl-ctrl maplibregl-ctrl-group",n.appendChild(e),t||(n.style.display="none"),n)}r.prototype.setInspectIcon=function(){this._btn.className="maplibregl-ctrl-icon maplibregl-ctrl-inspect"},r.prototype.setMapIcon=function(){this._btn.className="maplibregl-ctrl-icon maplibregl-ctrl-map"},e.exports=r},{}],3:[function(t,e,n){const r=t("./stylegen"),o=t("./InspectButton"),i=t("lodash.isequal"),s=t("./renderPopup"),a=t("./colors");function c(t){if(!(this instanceof c))throw new Error("MaplibreInspect needs to be called with the new keyword");let e=null;window.maplibregl?e=new window.maplibregl.Popup({closeButton:!1,closeOnClick:!1}):t.popup||console.error("Maplibre GL JS can not be found. Make sure to include it or pass an initialized MaplibreGL Popup to MaplibreInspect if you are using moduleis."),this.options=Object.assign({showInspectMap:!1,showInspectButton:!0,showInspectMapPopup:!0,showMapPopup:!1,showMapPopupOnHover:!0,showInspectMapPopupOnHover:!0,blockHoverPopupOnClick:!1,backgroundColor:"#fff",assignLayerColor:a.brightColor,buildInspectStyle:r.generateInspectStyle,renderPopup:s,popup:e,selectThreshold:5,useInspectStyle:!0,queryParameters:{},sources:{},toggleCallback(){}},t),this.sources=this.options.sources,this.assignLayerColor=this.options.assignLayerColor,this.toggleInspector=this.toggleInspector.bind(this),this._popup=this.options.popup,this._popupBlocked=!1,this._showInspectMap=this.options.showInspectMap,this._onSourceChange=this._onSourceChange.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onRightClick=this._onRightClick.bind(this),this._onStyleChange=this._onStyleChange.bind(this),this._originalStyle=null,this._toggle=new o({show:this.options.showInspectButton,onToggle:this.toggleInspector.bind(this)})}c.prototype.toggleInspector=function(){this._showInspectMap=!this._showInspectMap,this.options.toggleCallback(this._showInspectMap),this.render()},c.prototype._inspectStyle=function(){var t=r.generateColoredLayers(this.sources,this.assignLayerColor);return this.options.buildInspectStyle(this._map.getStyle(),t,{backgroundColor:this.options.backgroundColor})},c.prototype.render=function(){var t;this._showInspectMap?(this.options.useInspectStyle&&this._map.setStyle((t=this._inspectStyle(),Object.assign(t,{metadata:Object.assign({},t.metadata,{"maplibregl-inspect:inspect":!0})}))),this._toggle.setMapIcon()):this._originalStyle&&(this._popup&&this._popup.remove(),this.options.useInspectStyle&&this._map.setStyle(this._originalStyle),this._toggle.setInspectIcon())},c.prototype._onSourceChange=function(t){const r=this.sources,o=this._map;var e=o.getStyle();const n=Object.keys(e.sources);e=Object.assign({},r);"visibility"!==t.sourceDataType&&t.isSourceLoaded&&(Object.keys(o.style.sourceCaches).forEach(t=>{var e=o.style.sourceCaches[t]||{_source:{}},n=e._source.vectorLayerIds;n?r[t]=n:"geojson"===e._source.type&&(r[t]=[])}),Object.keys(r).forEach(t=>{-1===n.indexOf(t)&&delete r[t]}),!i(e,r))&&0<Object.keys(r).length&&this.render()},c.prototype._onStyleChange=function(){var t,e=this._map.getStyle();(t=e).metadata&&t.metadata["maplibregl-inspect:inspect"]||(this._originalStyle=e)},c.prototype._onRightClick=function(){this.options.showMapPopupOnHover||this.options.showInspectMapPopupOnHover||this.options.blockHoverPopupOnClick||this._popup&&this._popup.remove()},c.prototype._onMousemove=function(e){if(this._showInspectMap){if(!this.options.showInspectMapPopup)return;if("mousemove"===e.type&&!this.options.showInspectMapPopupOnHover)return;"click"===e.type&&this.options.showInspectMapPopupOnHover&&this.options.blockHoverPopupOnClick&&(this._popupBlocked=!this._popupBlocked)}else{if(!this.options.showMapPopup)return;if("mousemove"===e.type&&!this.options.showMapPopupOnHover)return;"click"===e.type&&this.options.showMapPopupOnHover&&this.options.blockHoverPopupOnClick&&(this._popupBlocked=!this._popupBlocked)}if(!this._popupBlocked&&this._popup){let t;t=0===this.options.selectThreshold?e.point:[[e.point.x-this.options.selectThreshold,e.point.y+this.options.selectThreshold],[e.point.x+this.options.selectThreshold,e.point.y-this.options.selectThreshold]];var n=this._map.queryRenderedFeatures(t,this.options.queryParameters)||[];this._map.getCanvas().style.cursor=n.length?"pointer":"",n.length?(this._popup.setLngLat(e.lngLat),"string"==typeof(e=this.options.renderPopup(n))?this._popup.setHTML(e):this._popup.setDOMContent(e),this._popup.addTo(this._map)):this._popup.remove()}},c.prototype.onAdd=function(t){return this._map=t,0===Object.keys(this.sources).length&&(t.on("tiledata",this._onSourceChange),t.on("sourcedata",this._onSourceChange)),t.on("styledata",this._onStyleChange),t.on("load",this._onStyleChange),t.on("mousemove",this._onMousemove),t.on("click",this._onMousemove),t.on("contextmenu",this._onRightClick),this._toggle.elem},c.prototype.onRemove=function(){this._map.off("styledata",this._onStyleChange),this._map.off("load",this._onStyleChange),this._map.off("tiledata",this._onSourceChange),this._map.off("sourcedata",this._onSourceChange),this._map.off("mousemove",this._onMousemove),this._map.off("click",this._onMousemove),this._map.off("contextmenu",this._onRightClick);var t=this._toggle.elem;t.parentNode.removeChild(t),this._map=void 0},e.exports=c},{"./InspectButton":2,"./colors":4,"./renderPopup":5,"./stylegen":6,"lodash.isequal":7}],4:[function(t,e,n){const o=t("randomcolor");n.brightColor=function(t,e){let n="bright",r=null;return/water|ocean|lake|sea|river/.test(t)&&(r="blue"),/state|country|place/.test(t)&&(r="pink"),/road|highway|transport|streets/.test(t)&&(r="orange"),/contour|building|earth/.test(t)&&(r="monochrome"),/building/.test(t)&&(n="dark"),/earth/.test(t)&&(n="light"),/contour|landuse/.test(t)&&(r="yellow"),/wood|forest|park|landcover|land|natural/.test(t)&&(r="green"),`rgba(${o({luminosity:n,hue:r,seed:t,format:"rgbArray"}).concat([e||1]).join(", ")})`}},{randomcolor:8}],5:[function(t,e,n){function o(t,e){return`<div class="maplibregl-inspect_property"><div class="maplibregl-inspect_property-name">${t}</div>`+`<div class="maplibregl-inspect_property-value">${t=e,null==t?t:t instanceof Date?t.toLocaleString():"object"==typeof t||"number"==typeof t||"string"==typeof t?t.toString():t}</div>`+"</div>"}function r(t){return t.map(t=>{return`<div class="maplibregl-inspect_feature">${e=t,t=`<div class="maplibregl-inspect_layer">${e.layer["source-layer"]||e.layer.source}</div>`,n=o("$type",e.geometry.type),r=Object.keys(e.properties).map(t=>o(t,e.properties[t])),[t,n].concat(r).join("")}</div>`;var e,n,r}).join("")}e.exports=function(t){return`<div class="maplibregl-inspect_popup">${r(t)}</div>`}},{}],6:[function(t,e,n){function a(t,e,n){e={id:[e,n,"circle"].join("_"),source:e,type:"circle",paint:{"circle-color":t,"circle-radius":2},filter:["==","$type","Point"]};return n&&(e["source-layer"]=n),e}function c(t,e,n,r){n={id:[n,r,"polygon"].join("_"),source:n,type:"fill",paint:{"fill-color":t,"fill-antialias":!0,"fill-outline-color":t},filter:["==","$type","Polygon"]};return r&&(n["source-layer"]=r),n}function u(t,e,n){e={id:[e,n,"line"].join("_"),source:e,layout:{"line-join":"round","line-cap":"round"},type:"line",paint:{"line-color":t},filter:["==","$type","LineString"]};return n&&(e["source-layer"]=n),e}n.polygonLayer=c,n.lineLayer=u,n.circleLayer=a,n.generateInspectStyle=function(n,t,e){e={id:"background",type:"background",paint:{"background-color":(e=Object.assign({backgroundColor:"#fff"},e)).backgroundColor}};const r={};return Object.keys(n.sources).forEach(t=>{var e=n.sources[t];"vector"!==e.type&&"geojson"!==e.type||(r[t]=e)}),Object.assign(n,{layers:[e].concat(t),sources:r})},n.generateColoredLayers=function(e,n){const r=[],o=[],i=[];function s(t){t=n.bind(null,t);return{circle:t(.8),line:t(.6),polygon:t(.3),polygonOutline:t(.6),default:t(1)}}return Object.keys(e).forEach(n=>{var t=e[n];t&&0!==t.length?t.forEach(t=>{var e=s(t);o.push(a(e.circle,n,t)),i.push(u(e.line,n,t)),r.push(c(e.polygon,e.polygonOutline,n,t))}):(t=s(n),o.push(a(t.circle,n)),i.push(u(t.line,n)),r.push(c(t.polygon,t.polygonOutline,n)))}),r.concat(i).concat(o)}},{}],7:[function(t,Bt,Ft){!function($t){!function(){var r="__lodash_hash_undefined__",T=1,J=2,O=9007199254740991,$="[object Arguments]",B="[object Array]",M="[object AsyncFunction]",X="[object Boolean]",K="[object Date]",Q="[object Error]",I="[object Function]",C="[object GeneratorFunction]",F="[object Map]",Y="[object Number]",S="[object Null]",H="[object Object]",A="[object Promise]",P="[object Proxy]",Z="[object RegExp]",N="[object Set]",tt="[object String]",et="[object Symbol]",z="[object Undefined]",n="[object WeakMap]",nt="[object ArrayBuffer]",q="[object DataView]",L=/^\[object .+?Constructor\]$/,x=/^(?:0|[1-9]\d*)$/,e={},t=(e["[object Float32Array]"]=e["[object Float64Array]"]=e["[object Int8Array]"]=e["[object Int16Array]"]=e["[object Int32Array]"]=e["[object Uint8Array]"]=e["[object Uint8ClampedArray]"]=e["[object Uint16Array]"]=e["[object Uint32Array]"]=!0,e[$]=e[B]=e[nt]=e[X]=e[q]=e[K]=e[Q]=e[I]=e[F]=e[Y]=e[H]=e[Z]=e[N]=e[tt]=e[n]=!1,"object"==typeof $t&&$t&&$t.Object===Object&&$t),o="object"==typeof self&&self&&self.Object===Object&&self,o=t||o||Function("return this")(),i="object"==typeof Ft&&Ft&&!Ft.nodeType&&Ft,s=i&&"object"==typeof Bt&&Bt&&!Bt.nodeType&&Bt,s=s&&s.exports===i,a=s&&t.process,i=function(){try{return a&&a.binding&&a.binding("util")}catch(t){}}(),t=i&&i.isTypedArray;function rt(t){var n=-1,r=Array(t.size);return t.forEach(function(t,e){r[++n]=[e,t]}),r}function ot(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var R,E,i=Array.prototype,c=Function.prototype,u=Object.prototype,l=o["__core-js_shared__"],it=c.toString,D=u.hasOwnProperty,st=(c=/[^.]+$/.exec(l&&l.keys&&l.keys.IE_PROTO||""))?"Symbol(src)_1."+c:"",at=u.toString,ct=RegExp("^"+it.call(D).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),l=s?o.Buffer:void 0,c=o.Symbol,ut=o.Uint8Array,lt=u.propertyIsEnumerable,pt=i.splice,p=c?c.toStringTag:void 0,ht=Object.getOwnPropertySymbols,s=l?l.isBuffer:void 0,ft=(R=Object.keys,E=Object,function(t){return R(E(t))}),i=j(o,"DataView"),h=j(o,"Map"),l=j(o,"Promise"),f=j(o,"Set"),o=j(o,"WeakMap"),d=j(Object,"create"),dt=k(i),gt=k(h),yt=k(l),_t=k(f),bt=k(o),c=c?c.prototype:void 0,vt=c?c.valueOf:void 0;function g(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function y(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function _(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function b(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new _;++e<n;)this.add(t[e])}function U(t){t=this.__data__=new y(t);this.size=t.size}function mt(t,e){var n,r,o,i=V(t),s=!i&&At(t),a=!i&&!s&&Pt(t),c=!i&&!s&&!a&&Et(t),u=i||s||a||c,l=u?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],p=l.length;for(n in t)!e&&!D.call(t,n)||u&&("length"==n||a&&("offset"==n||"parent"==n)||c&&("buffer"==n||"byteLength"==n||"byteOffset"==n)||(r=n,(o=null==(o=p)?O:o)&&("number"==typeof r||x.test(r))&&-1<r&&r%1==0&&r<o))||l.push(n);return l}function v(t,e){for(var n=t.length;n--;)if(St(t[n][0],e))return n;return-1}function m(t){if(null==t)return void 0===t?z:S;if(p&&p in Object(t)){var e=t,n=D.call(e,p),r=e[p];try{var o=!(e[p]=void 0)}catch(t){}var i=at.call(e);return o&&(n?e[p]=r:delete e[p]),i}return at.call(t)}function wt(t){return W(t)&&m(t)==$}function jt(t,e,n,r,o){if(t===e)return!0;if(null==t||null==e||!W(t)&&!W(e))return t!=t&&e!=e;var i=jt,s=V(t),a=V(e),c=s?B:G(t),a=a?B:G(e),u=(c=c==$?H:c)==H,l=(a=a==$?H:a)==H;if((a=c==a)&&Pt(t)){if(!Pt(e))return!1;u=!(s=!0)}if(a&&!u){o=o||new U;if(s||Et(t))return Mt(t,e,n,r,i,o);else{var p=t;var h=e;var f=c;var d=n;var g=r;var y=i;var _=o;switch(f){case q:if(p.byteLength!=h.byteLength||p.byteOffset!=h.byteOffset)return!1;p=p.buffer,h=h.buffer;case nt:return p.byteLength==h.byteLength&&y(new ut(p),new ut(h))?!0:!1;case X:case K:case Y:return St(+p,+h);case Q:return p.name==h.name&&p.message==h.message;case Z:case tt:return p==h+"";case F:var b=rt;case N:var v=d&T;if(b=b||ot,p.size!=h.size&&!v)return!1;v=_.get(p);if(v)return v==h;d|=J,_.set(p,h);v=Mt(b(p),b(h),d,g,y,_);return _.delete(p),v;case et:if(vt)return vt.call(p)==vt.call(h)}return!1;return}}if(!(n&T)){var s=u&&D.call(t,"__wrapped__"),c=l&&D.call(e,"__wrapped__");if(s||c)return u=s?t.value():t,l=c?e.value():e,o=o||new U,i(u,l,n,r,o)}if(a){o=o||new U;var m=t,w=e,j=n,k=r,O=i,M=o,I=j&T,C=It(m),S=C.length,s=It(w).length;if(S!=s&&!I)return!1;for(var A=S;A--;){var P=C[A];if(!(I?P in w:D.call(w,P)))return!1}if((s=M.get(m))&&M.get(w))return s==w;for(var z=!0,L=(M.set(m,w),M.set(w,m),I);++A<S;){P=C[A];var x,R=m[P],E=w[P];if(!(void 0===(x=k?I?k(E,R,P,w,m,M):k(R,E,P,m,w,M):x)?R===E||O(R,E,j,k,M):x)){z=!1;break}L=L||"constructor"==P}return z&&!L&&(s=m.constructor,c=w.constructor,s!=c)&&"constructor"in m&&"constructor"in w&&!("function"==typeof s&&s instanceof s&&"function"==typeof c&&c instanceof c)&&(z=!1),M.delete(m),M.delete(w),z}return!1}function kt(t){var e;return xt(t)&&(e=t,!(st&&st in e))&&(zt(t)?ct:L).test(k(t))}function Ot(t){if(n="function"==typeof(n=(e=t)&&e.constructor)&&n.prototype||u,e!==n)return ft(t);var e,n,r,o=[];for(r in Object(t))D.call(t,r)&&"constructor"!=r&&o.push(r);return o}function Mt(t,e,n,r,o,i){var s=n&T,a=t.length,c=e.length;if(a!=c&&!(s&&a<c))return!1;c=i.get(t);if(c&&i.get(e))return c==e;var u=-1,l=!0,p=n&J?new b:void 0;for(i.set(t,e),i.set(e,t);++u<a;){var h,f=t[u],d=e[u];if(void 0!==(h=r?s?r(d,f,u,e,t,i):r(f,d,u,t,e,i):h)){if(h)continue;l=!1;break}if(p){if(!function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return 1}(e,function(t,e){return!p.has(e)&&(f===t||o(f,t,n,r,i))&&p.push(e)})){l=!1;break}}else if(f!==d&&!o(f,d,n,r,i)){l=!1;break}}return i.delete(t),i.delete(e),l}function It(t){var e=Tt,n=Ct;if(e=e(t),V(t))return e;for(var r=e,o=n(t),i=-1,s=o.length,a=r.length;++i<s;)r[a+i]=o[i];return r}function w(t,e){var n,r,t=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?t["string"==typeof e?"string":"hash"]:t.map}function j(t,e){e=e;t=null==(t=t)?void 0:t[e];return kt(t)?t:void 0}g.prototype.clear=function(){this.__data__=d?d(null):{},this.size=0},g.prototype.delete=function(t){return t=this.has(t)&&delete this.__data__[t],this.size-=t?1:0,t},g.prototype.get=function(t){var e,n=this.__data__;return d?(e=n[t])===r?void 0:e:D.call(n,t)?n[t]:void 0},g.prototype.has=function(t){var e=this.__data__;return d?void 0!==e[t]:D.call(e,t)},g.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=d&&void 0===e?r:e,this},y.prototype.clear=function(){this.__data__=[],this.size=0},y.prototype.delete=function(t){var e=this.__data__;return!((t=v(e,t))<0||(t==e.length-1?e.pop():pt.call(e,t,1),--this.size,0))},y.prototype.get=function(t){var e=this.__data__;return(t=v(e,t))<0?void 0:e[t][1]},y.prototype.has=function(t){return-1<v(this.__data__,t)},y.prototype.set=function(t,e){var n=this.__data__,r=v(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},_.prototype.clear=function(){this.size=0,this.__data__={hash:new g,map:new(h||y),string:new g}},_.prototype.delete=function(t){return t=w(this,t).delete(t),this.size-=t?1:0,t},_.prototype.get=function(t){return w(this,t).get(t)},_.prototype.has=function(t){return w(this,t).has(t)},_.prototype.set=function(t,e){var n=w(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},b.prototype.add=b.prototype.push=function(t){return this.__data__.set(t,r),this},b.prototype.has=function(t){return this.__data__.has(t)},U.prototype.clear=function(){this.__data__=new y,this.size=0},U.prototype.delete=function(t){var e=this.__data__,t=e.delete(t);return this.size=e.size,t},U.prototype.get=function(t){return this.__data__.get(t)},U.prototype.has=function(t){return this.__data__.has(t)},U.prototype.set=function(t,e){var n=this.__data__;if(n instanceof y){var r=n.__data__;if(!h||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new _(r)}return n.set(t,e),this.size=n.size,this};var Ct=ht?function(e){if(null==e)return[];e=Object(e);for(var t=ht(e),n=function(t){return lt.call(e,t)},r=-1,o=null==t?0:t.length,i=0,s=[];++r<o;){var a=t[r];n(a,r,t)&&(s[i++]=a)}return s}:function(){return[]},G=m;function k(t){if(null!=t){try{return it.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function St(t,e){return t===e||t!=t&&e!=e}(i&&G(new i(new ArrayBuffer(1)))!=q||h&&G(new h)!=F||l&&G(l.resolve())!=A||f&&G(new f)!=N||o&&G(new o)!=n)&&(G=function(t){var e=m(t),t=e==H?t.constructor:void 0,t=t?k(t):"";if(t)switch(t){case dt:return q;case gt:return F;case yt:return A;case _t:return N;case bt:return n}return e});var At=wt(function(){return arguments}())?wt:function(t){return W(t)&&D.call(t,"callee")&&!lt.call(t,"callee")},V=Array.isArray;var Pt=s||function(){return!1};function zt(t){if(xt(t))return(t=m(t))==I||t==C||t==M||t==P}function Lt(t){return"number"==typeof t&&-1<t&&t%1==0&&t<=O}function xt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function W(t){return null!=t&&"object"==typeof t}var Rt,Et=t?(Rt=t,function(t){return Rt(t)}):function(t){return W(t)&&Lt(t.length)&&!!e[m(t)]};function Tt(t){return(null!=(e=t)&&Lt(e.length)&&!zt(e)?mt:Ot)(t);var e}Bt.exports=function(t,e){return jt(t,e)}}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(t,e,n){var r,o,i;r=this,o=function(){function h(t){if(void 0!==(t=t||{}).seed&&null!==t.seed&&t.seed===parseInt(t.seed,10))f=t.seed;else if("string"==typeof t.seed)f=function(t){for(var e=0,n=0;n!==t.length&&!(e>=Number.MAX_SAFE_INTEGER);n++)e+=t.charCodeAt(n);return e}(t.seed);else{if(void 0!==t.seed&&null!==t.seed)throw new TypeError("The seed value must be an integer or string");f=null}var e,n;if(null!==t.count&&void 0!==t.count){for(var r=t.count,o=[],i=0;i<t.count;i++)g.push(!1);for(t.count=null;o.length<r;){var s=h(t);null!==f&&(t.seed=f),o.push(s)}return t.count=r,o}var a=function(t,e,n){var r=function(t,e){for(var n=y(t).lowerBounds,r=0;r<n.length-1;r++){var o=n[r][0],i=n[r][1],s=n[r+1][0],a=n[r+1][1];if(o<=e&&e<=s)return(a=(a-i)/(s-o))*e+(i-a*o)}return 0}(t,e),o=100;switch(n.luminosity){case"dark":o=r+20;break;case"light":r=(o+r)/2;break;case"random":r=0,o=100}return _([r,o])}(e=function(t){{var e,n,r,o,i;return e=0<g.length?(e=_(i=function(t){if(isNaN(t)){if("string"==typeof t)if(d[t]){var e=d[t];if(e.hueRange)return e.hueRange}else if(t.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return y(v(t)[0]).hueRange}else{e=parseInt(t);if(e<360&&0<e)return y(t).hueRange}return[0,360]}(t.hue)),n=(i[1]-i[0])/g.length,o=parseInt((e-i[0])/n),!0===g[o]?o=(o+2)%g.length:g[o]=!0,r=(i[0]+o*n)%359,o=(i[0]+(o+1)*n)%359,(e=_(i=[r,o]))<0?360+e:e):(i=function(t){if("number"==typeof parseInt(t)){var e=parseInt(t);if(e<360&&0<e)return[e,e]}if("string"==typeof t)if(d[t]){e=d[t];if(e.hueRange)return e.hueRange}else if(t.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return[e=v(t)[0],e];return[0,360]}(t.hue),(e=_(i))<0?360+e:e)}}(t),n=function(t,e){if("monochrome"===e.hue)return 0;if("random"===e.luminosity)return _([0,100]);var t=function(t){return y(t).saturationRange}(t),n=t[0],r=t[1];switch(e.luminosity){case"bright":n=55;break;case"dark":n=r-10;break;case"light":r=55}return _([n,r])}(e,t),t),c=[e,n,a],u=t;switch(u.format){case"hsvArray":return c;case"hslArray":return m(c);case"hsl":var l=m(c);return"hsl("+l[0]+", "+l[1]+"%, "+l[2]+"%)";case"hsla":var l=m(c),p=u.alpha||Math.random();return"hsla("+l[0]+", "+l[1]+"%, "+l[2]+"%, "+p+")";case"rgbArray":return b(c);case"rgb":return"rgb("+b(c).join(", ")+")";case"rgba":l=b(c),p=u.alpha||Math.random();return"rgba("+l.join(", ")+", "+p+")";default:return function(t){t=b(t);function e(t){t=t.toString(16);return 1==t.length?"0"+t:t}return"#"+e(t[0])+e(t[1])+e(t[2])}(c)}}var f=null,d={},g=(t("monochrome",null,[[0,0],[100,0]]),t("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),t("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),t("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),t("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),t("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),t("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),t("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]),[]);function y(t){for(var e in 334<=t&&t<=360&&(t-=360),d){var n=d[e];if(n.hueRange&&t>=n.hueRange[0]&&t<=n.hueRange[1])return d[e]}return"Color not found"}function _(t){var e,n;return null===f?(e=(Math.random()+.618033988749895)%1,Math.floor(t[0]+e*(t[1]+1-t[0]))):(e=t[1]||1,t=t[0]||0,n=(f=(9301*f+49297)%233280)/233280,Math.floor(t+n*(e-t)))}function t(t,e,n){var r=n[0][0],o=n[n.length-1][0],i=n[n.length-1][1],s=n[0][1];d[t]={hueRange:e,lowerBounds:n,saturationRange:[r,o],brightnessRange:[i,s]}}function b(t){var e=t[0],n=(360===(e=0===e?1:e)&&(e=359),e/=360,t[1]/100),r=t[2]/100,t=Math.floor(6*e),e=6*e-t,o=r*(1-n),i=r*(1-e*n),s=r*(1-(1-e)*n),a=256,c=256,u=256;switch(t){case 0:a=r,c=s,u=o;break;case 1:a=i,c=r,u=o;break;case 2:a=o,c=r,u=s;break;case 3:a=o,c=i,u=r;break;case 4:a=s,c=o,u=r;break;case 5:a=r,c=o,u=i}return[Math.floor(255*a),Math.floor(255*c),Math.floor(255*u)]}function v(t){t=3===(t=t.replace(/^#/,"")).length?t.replace(/(.)/g,"$1$1"):t;var e=parseInt(t.substr(0,2),16)/255,n=parseInt(t.substr(2,2),16)/255,r=parseInt(t.substr(4,2),16)/255,o=Math.max(e,n,r),i=o-Math.min(e,n,r),s=o?i/o:0;switch(o){case e:return[(n-r)/i%6*60||0,s,o];case n:return[60*((r-e)/i+2)||0,s,o];case r:return[60*((e-n)/i+4)||0,s,o]}}function m(t){var e=t[0],n=t[1]/100,t=t[2]/100,r=(2-n)*t;return[e,Math.round(n*t/(r<1?r:2-r)*1e4)/100,r/2*100]}return h},"object"==typeof n?(i=o(),(n="object"==typeof e&&e&&e.exports?e.exports=i:n).randomColor=i):r.randomColor=o()},{}]},{},[1])(1)});
|
package/src/main.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
-
import
|
|
8
|
+
import axios from 'axios';
|
|
9
9
|
import { server } from './server.js';
|
|
10
10
|
import MBTiles from '@mapbox/mbtiles';
|
|
11
11
|
import { isValidHttpUrl } from './utils.js';
|
|
@@ -271,11 +271,24 @@ fs.stat(path.resolve(opts.config), (err, stats) => {
|
|
|
271
271
|
const url =
|
|
272
272
|
'https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles';
|
|
273
273
|
const filename = 'zurich_switzerland.mbtiles';
|
|
274
|
-
const
|
|
274
|
+
const writer = fs.createWriteStream(filename);
|
|
275
275
|
console.log(`No input file found`);
|
|
276
276
|
console.log(`[DEMO] Downloading sample data (${filename}) from ${url}`);
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
axios({
|
|
278
|
+
url,
|
|
279
|
+
method: 'GET',
|
|
280
|
+
responseType: 'stream',
|
|
281
|
+
})
|
|
282
|
+
.then((response) => {
|
|
283
|
+
response.data.pipe(writer);
|
|
284
|
+
writer.on('finish', () => StartWithInputFile(filename));
|
|
285
|
+
writer.on('error', (err) =>
|
|
286
|
+
console.error(`Error writing file: ${err}`),
|
|
287
|
+
);
|
|
288
|
+
})
|
|
289
|
+
.catch((error) => {
|
|
290
|
+
console.error(`Error downloading file: ${error}`);
|
|
291
|
+
});
|
|
279
292
|
}
|
|
280
293
|
}
|
|
281
294
|
} else {
|
package/src/serve_rendered.js
CHANGED
|
@@ -17,7 +17,7 @@ import mlgl from '@maplibre/maplibre-gl-native';
|
|
|
17
17
|
import MBTiles from '@mapbox/mbtiles';
|
|
18
18
|
import polyline from '@mapbox/polyline';
|
|
19
19
|
import proj4 from 'proj4';
|
|
20
|
-
import
|
|
20
|
+
import axios from 'axios';
|
|
21
21
|
import {
|
|
22
22
|
getFontsPbf,
|
|
23
23
|
getTileUrls,
|
|
@@ -1353,37 +1353,36 @@ export const serve_rendered = {
|
|
|
1353
1353
|
});
|
|
1354
1354
|
}
|
|
1355
1355
|
} else if (protocol === 'http' || protocol === 'https') {
|
|
1356
|
-
|
|
1357
|
-
{
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
},
|
|
1362
|
-
(err, res, body) => {
|
|
1363
|
-
const parts = url.parse(req.url);
|
|
1364
|
-
const extension = path.extname(parts.pathname).toLowerCase();
|
|
1365
|
-
const format = extensionToFormat[extension] || '';
|
|
1366
|
-
if (err || res.statusCode < 200 || res.statusCode >= 300) {
|
|
1367
|
-
// console.log('HTTP error', err || res.statusCode);
|
|
1368
|
-
createEmptyResponse(format, '', callback);
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1356
|
+
try {
|
|
1357
|
+
const response = await axios.get(req.url, {
|
|
1358
|
+
responseType: 'arraybuffer', // Get the response as raw buffer
|
|
1359
|
+
// Axios handles gzip by default, so no need for a gzip flag
|
|
1360
|
+
});
|
|
1371
1361
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
response.modified = new Date(res.headers.modified);
|
|
1375
|
-
}
|
|
1376
|
-
if (res.headers.expires) {
|
|
1377
|
-
response.expires = new Date(res.headers.expires);
|
|
1378
|
-
}
|
|
1379
|
-
if (res.headers.etag) {
|
|
1380
|
-
response.etag = res.headers.etag;
|
|
1381
|
-
}
|
|
1362
|
+
const responseHeaders = response.headers;
|
|
1363
|
+
const responseData = response.data;
|
|
1382
1364
|
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1365
|
+
const parsedResponse = {};
|
|
1366
|
+
if (responseHeaders['last-modified']) {
|
|
1367
|
+
parsedResponse.modified = new Date(
|
|
1368
|
+
responseHeaders['last-modified'],
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
if (responseHeaders.expires) {
|
|
1372
|
+
parsedResponse.expires = new Date(responseHeaders.expires);
|
|
1373
|
+
}
|
|
1374
|
+
if (responseHeaders.etag) {
|
|
1375
|
+
parsedResponse.etag = responseHeaders.etag;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
parsedResponse.data = responseData;
|
|
1379
|
+
callback(null, parsedResponse);
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
const parts = url.parse(req.url);
|
|
1382
|
+
const extension = path.extname(parts.pathname).toLowerCase();
|
|
1383
|
+
const format = extensionToFormat[extension] || '';
|
|
1384
|
+
createEmptyResponse(format, '', callback);
|
|
1385
|
+
}
|
|
1387
1386
|
}
|
|
1388
1387
|
},
|
|
1389
1388
|
});
|