Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

14 lines
5.3 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define(["../../../geometry/support/spatialReferenceUtils","./LODInfo","./TileCoverage","./TileKey","./TileSpan"],function(u,v,w,x,r){const f=new x("0/0/0/0");class t{static create(a,b){a[1]>b[1]&&([a,b]=[b,a]);const [c,e]=a,[k,g]=b;a=k-c;b=g-e;b=0!==b?a/b:0;const h=(Math.ceil(e)-e)*b,n=(Math.floor(e)-e)*b;return new t(c,Math.floor(e),Math.ceil(g),b,0>a?h:n,0>a?n:h,0>a?k:c,0>a?c:k)}constructor(a,b,c,e,k,g,h,n){this.x=a;this.ymin=b;this.ymax=c;this.invM=e;this.leftAdjust=k;this.rightAdjust=g;this.leftBound=
h;this.rightBound=n}incrRow(){this.x+=this.invM}getLeftCol(){return Math.max(this.x+this.leftAdjust,this.leftBound)}getRightCol(){return Math.min(this.x+this.rightAdjust,this.rightBound)}}const p=[[0,0],[0,0],[0,0],[0,0]];class y{constructor(a,b=null,c=a.lods[0].level,e=a.lods[a.lods.length-1].level){this.tileInfo=a;this.fullExtent=b;this.scales=[];this._infoByScale={};this._infoByLevel={};const k=a.lods.filter(h=>h.level>=c&&h.level<=e);this.minScale=k[0].scale;this.maxScale=k[k.length-1].scale;
const g=this._lodInfos=k.map(h=>v.create(a,h,b));k.forEach((h,n)=>{this._infoByLevel[h.level]=g[n];this._infoByScale[h.scale]=g[n];this.scales[n]=h.scale},this);this._wrap=a.isWrappable}get spatialReference(){return this.tileInfo.spatialReference}getLODInfoAt(a){return this._infoByLevel["number"===typeof a?a:a.level]}getTileBounds(a,b,c=!1){f.set(b);return(b=this._infoByLevel[f.level])?b.getTileBounds(a,f,c):a}getTileCoords(a,b,c=!1){f.set(b);return(b=this._infoByLevel[f.level])?b.getTileCoords(a,
f,c):a}getTileCoverage(a,b=192,c=!0,e="closest"){if(!c&&(a.scale>this.minScale||a.scale<this.maxScale))return null;c="closest"===e?this.getClosestInfoForScale(a.scale):this.getSmallestInfoForScale(a.scale);e=w.pool.acquire(c);const k=this._wrap;var g=Infinity;let h=-Infinity;const n=e.spans;p[0][0]=p[0][1]=p[1][1]=p[3][0]=-b;p[1][0]=p[2][0]=a.size[0]+b;p[2][1]=p[3][1]=a.size[1]+b;for(d of p)a.toMap(d,d),d[0]=c.getColumnForX(d[0]),d[1]=c.getRowForY(d[1]);a=[];var d=3;for(b=0;4>b;b++)p[b][1]===p[d][1]?
d=b:(d=t.create(p[b],p[d]),g=Math.min(d.ymin,g),h=Math.max(d.ymax,h),void 0===a[d.ymin]&&(a[d.ymin]=[]),a[d.ymin].push(d),d=b);if(null==g||null==h||100<h-g)return null;for(b=[];g<h;){null!=a[g]&&(b=b.concat(a[g]));d=Infinity;var l=-Infinity;for(var m=b.length-1;0<=m;m--){var q=b[m];d=Math.min(d,q.getLeftCol());l=Math.max(l,q.getRightCol())}d=Math.floor(d);l=Math.floor(l);if(g>=c.first[1]&&g<=c.last[1])if(k)if(c.size[0]<c.worldSize[0])for(m=Math.floor(l/c.worldSize[0]),q=Math.floor(d/c.worldSize[0]);q<=
m;q++)n.push(new r(g,Math.max(c.getFirstColumnForWorld(q),d),Math.min(c.getLastColumnForWorld(q),l)));else n.push(new r(g,d,l));else d>c.last[0]||l<c.first[0]||(d=Math.max(d,c.first[0]),l=Math.min(l,c.last[0]),n.push(new r(g,d,l)));g+=1;for(d=b.length-1;0<=d;d--)l=b[d],l.ymax>=g?l.incrRow():b.splice(d,1)}return e}getTileParentId(a){f.set(a);a=this._lodInfos.indexOf(this._infoByLevel[f.level])-1;if(0>a)return null;this._getTileIdAtLOD(f,this._lodInfos[a],f);return f.id}getTileResolution(a){return(a=
this._infoByLevel["object"===typeof a?a.level:a])?a.resolution:-1}getTileScale(a){return(a=this._infoByLevel[a.level])?a.scale:-1}intersects(a,b){f.set(b);b=this._infoByLevel[f.level];const c=a.lodInfo;if(c.resolution>b.resolution){this._getTileIdAtLOD(f,c,f);var e=c.denormalizeCol(f.col,f.world);for(var k of a.spans)if(k.row===f.row&&k.colFrom<=e&&k.colTo>=e)return!0}if(c.resolution<b.resolution){const [h,n,d,l]=a.spans.reduce((m,q)=>{m[0]=Math.min(m[0],q.row);m[1]=Math.max(m[1],q.row);m[2]=Math.min(m[2],
q.colFrom);m[3]=Math.max(m[3],q.colTo);return m},[Infinity,-Infinity,Infinity,-Infinity]);e=b.denormalizeCol(f.col,f.world);a=c.getColumnForX(b.getXForColumn(e));k=c.getRowForY(b.getYForRow(f.row));e=c.getColumnForX(b.getXForColumn(e+1))-1;b=c.getRowForY(b.getYForRow(f.row+1))-1;return!(a>l||e<d||k>n||b<h)}const g=c.denormalizeCol(f.col,f.world);return a.spans.some(h=>h.row===f.row&&h.colFrom<=g&&h.colTo>=g)}normalizeBounds(a,b,c){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];this._wrap&&(b=u.getInfo(this.tileInfo.spatialReference),
c=-c*(b.valid[1]-b.valid[0]),a[0]+=c,a[2]+=c);return a}getSmallestInfoForScale(a){const b=this.scales;if(this._infoByScale[a])return this._infoByScale[a];if(a>b[0])return this._infoByScale[b[0]];for(let c=1;c<b.length-1;c++)if(a>b[c]+1E-6)return this._infoByScale[b[c-1]];return this._infoByScale[b[b.length-1]]}getClosestInfoForScale(a){const b=this.scales;if(this._infoByScale[a])return this._infoByScale[a];a=b.reduce((c,e)=>Math.abs(e-a)<Math.abs(c-a)?e:c,b[0]);return this._infoByScale[a]}scaleToLevel(a){const b=
this.scales;if(this._infoByScale[a])return this._infoByScale[a].level;for(let c=b.length-1;0<=c;c--)if(a<b[c])return c===b.length-1?this._infoByScale[b[b.length-1]].level:this._infoByScale[b[c]].level+(b[c]-a)/(b[c]-b[c+1]);return this._infoByScale[b[0]].level}scaleToZoom(a){return this.tileInfo.scaleToZoom(a)}zoomToScale(a){return this.tileInfo.zoomToScale(a)}_getTileIdAtLOD(a,b,c){const e=this._infoByLevel[c.level];a.set(c);if(b.resolution<e.resolution)return null;if(b.resolution===e.resolution)return a;
a.level=b.level;a.col=Math.floor(c.col*e.resolution/b.resolution+.01);a.row=Math.floor(c.row*e.resolution/b.resolution+.01);return a}}return y});