/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import l from"../../../../geometry/Point.js";import e from"../../../../layers/support/LOD.js";import n from"../../../../layers/support/TileInfo.js";const s=1e-6;function r(l,e){if(l===e)return!0;if(null==l&&null!=e)return!1;if(null!=l&&null==e)return!1;if(null==l||null==e)return!1;if(!l.spatialReference.equals(e.spatialReference)||l.dpi!==e.dpi)return!1;const n=l.origin,r=e.origin;if(Math.abs(n.x-r.x)>=s||Math.abs(n.y-r.y)>=s)return!1;let o,t;l.lods[0].scale>e.lods[0].scale?(o=l,t=e):(t=l,o=e);for(let i=o.lods[0].scale;i>=t.lods[t.lods.length-1].scale-s;i/=2)if(Math.abs(i-t.lods[0].scale)<s)return!0;return!1}function o(s,r){if(s===r)return s;if(null==s&&null!=r)return r;if(null!=s&&null==r)return s;if(null==s||null==r)return null;const o=s.size[0],t=s.format,i=s.dpi,u=new l({x:s.origin.x,y:s.origin.y}),a=s.spatialReference,f=s.lods[0].scale>r.lods[0].scale?s.lods[0]:r.lods[0],d=s.lods[s.lods.length-1].scale<=r.lods[r.lods.length-1].scale?s.lods[s.lods.length-1]:r.lods[r.lods.length-1],c=f.scale,p=f.resolution,g=d.scale,h=[];let m=c,y=p,x=0;for(;m>=g;)h.push(new e({level:x,resolution:y,scale:m})),x++,m/=2,y/=2;return new n({size:[o,o],dpi:i,format:t||"pbf",origin:u,lods:h,spatialReference:a})}export{r as areSchemasOverlapping,o as unionTileInfos};
