Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
1 righe
3.9 KiB
1 righe
3.9 KiB
!function(t){var o,i;if("function"==typeof define&&define.amd)define(["leaflet","proj4"],t);else if("object"==typeof module&&"object"==typeof module.exports)o=require("leaflet"),i=require("proj4"),module.exports=t(o,i);else{if(void 0===window.L||void 0===window.proj4)throw"Leaflet and proj4 must be loaded first";t(window.L,window.proj4)}}(function(t,o){return o.__esModule&&o.default&&(o=o.default),t.Proj={},t.Proj._isProj4Obj=function(t){return void 0!==t.inverse&&void 0!==t.forward},t.Proj.Projection=t.Class.extend({initialize:function(o,i,e){var s=t.Proj._isProj4Obj(o);this._proj=s?o:this._projFromCodeDef(o,i),this.bounds=s?i:e},project:function(o){var i=this._proj.forward([o.lng,o.lat]);return new t.Point(i[0],i[1])},unproject:function(o,i){var e=this._proj.inverse([o.x,o.y]);return new t.LatLng(e[1],e[0],i)},_projFromCodeDef:function(t,i){if(i)o.defs(t,i);else if(void 0===o.defs[t]){var e=t.split(":");if(e.length>3&&(t=e[e.length-3]+":"+e[e.length-1]),void 0===o.defs[t])throw"No projection definition for code "+t}return o(t)}}),t.Proj.CRS=t.Class.extend({includes:t.CRS,options:{transformation:new t.Transformation(1,0,-1,0)},initialize:function(o,i,e){var s,n,r,a;if(t.Proj._isProj4Obj(o)?(s=(n=o).srsCode,a=i||{},this.projection=new t.Proj.Projection(n,a.bounds)):(s=o,r=i,a=e||{},this.projection=new t.Proj.Projection(s,r,a.bounds)),t.Util.setOptions(this,a),this.code=s,this.transformation=this.options.transformation,this.options.origin&&(this.transformation=new t.Transformation(1,-this.options.origin[0],-1,this.options.origin[1])),this.options.scales)this._scales=this.options.scales;else if(this.options.resolutions){this._scales=[];for(var l=this.options.resolutions.length-1;l>=0;l--)this.options.resolutions[l]&&(this._scales[l]=1/this.options.resolutions[l])}this.infinite=!this.options.bounds},scale:function(t){var o,i,e,s,n=Math.floor(t);return t===n?this._scales[t]:(o=this._scales[n],i=this._scales[n+1],e=i-o,s=t-n,o+e*s)},zoom:function(t){var o,i,e,s=this._closestElement(this._scales,t),n=this._scales.indexOf(s);return t===s?n:void 0===s?-1/0:(i=n+1,void 0===(o=this._scales[i])?1/0:(e=o-s,(t-s)/e+n))},distance:t.CRS.Earth.distance,R:t.CRS.Earth.R,_closestElement:function(t,o){for(var i,e=t.length;e--;)t[e]<=o&&(void 0===i||i<t[e])&&(i=t[e]);return i}}),t.Proj.GeoJSON=t.GeoJSON.extend({initialize:function(o,i){this._callLevel=0,t.GeoJSON.prototype.initialize.call(this,o,i)},addData:function(o){var i;o&&(o.crs&&"name"===o.crs.type?i=new t.Proj.CRS(o.crs.properties.name):o.crs&&o.crs.type&&(i=new t.Proj.CRS(o.crs.type+":"+o.crs.properties.code)),void 0!==i&&(this.options.coordsToLatLng=function(o){var e=t.point(o[0],o[1]);return i.projection.unproject(e)})),this._callLevel++;try{t.GeoJSON.prototype.addData.call(this,o)}finally{0===--this._callLevel&&delete this.options.coordsToLatLng}}}),t.Proj.geoJson=function(o,i){return new t.Proj.GeoJSON(o,i)},t.Proj.ImageOverlay=t.ImageOverlay.extend({initialize:function(o,i,e){t.ImageOverlay.prototype.initialize.call(this,o,null,e),this._projectedBounds=i},_animateZoom:function(o){var i=this._map.getZoomScale(o.zoom),e=t.point(this._projectedBounds.min.x,this._projectedBounds.max.y),s=this._projectedToNewLayerPoint(e,o.zoom,o.center);t.DomUtil.setTransform(this._image,s,i)},_reset:function(){var o=this._map.getZoom(),i=this._map.getPixelOrigin(),e=t.bounds(this._transform(this._projectedBounds.min,o)._subtract(i),this._transform(this._projectedBounds.max,o)._subtract(i)),s=e.getSize();t.DomUtil.setPosition(this._image,e.min),this._image.style.width=s.x+"px",this._image.style.height=s.y+"px"},_projectedToNewLayerPoint:function(t,o,i){var e=this._map.getSize()._divideBy(2),s=this._map.project(i,o)._subtract(e)._round().add(this._map._getMapPanePos());return this._transform(t,o)._subtract(s)},_transform:function(t,o){var i=this._map.options.crs,e=i.transformation,s=i.scale(o);return e.transform(t,s)}}),t.Proj.imageOverlay=function(o,i,e){return new t.Proj.ImageOverlay(o,i,e)},t.Proj}); |