12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../../chunks/tslib.es6.js";import n from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";var i;const c=147914382,l=[{id:"room",minScale:100},{id:"rooms",minScale:400},{id:"smallBuilding",minScale:800},{id:"building",minScale:1999},{id:"buildings",minScale:3999},{id:"street",minScale:7499},{id:"streets",minScale:14999},{id:"neighborhood",minScale:29999},{id:"town",minScale:59999},{id:"city",minScale:119999},{id:"cities",minScale:249999},{id:"metropolitanArea",minScale:499999},{id:"county",minScale:999999},{id:"counties",minScale:1999999},{id:"stateProvince",minScale:3999999},{id:"statesProvinces",minScale:6999999},{id:"countriesSmall",minScale:14999999},{id:"countriesBig",minScale:34999999},{id:"continent",minScale:99999999},{id:"world",minScale:c}];function r(e,n){const t=l,a=t.length,i=[];let c,r=e;e=e>=0?e:0,n=n>0?n:t[a-1].minScale;for(let l=0;l<a;l++){const a=Math.min(t[l].minScale,n);c=Math.min(a,n),e<=a&&r<n&&i.push({id:t[l].id,maxScale:Math.max(r,e),minScale:c}),r=c+1}return i.reverse(),s(i)}function s(e){if(0===e.length)return e;const[n]=e,t=e[e.length-1];return n.minScale===n.maxScale&&(e.shift(),n.minScale+=1),t.minScale===t.maxScale&&(e.pop(),t.maxScale-=1),e}let o=i=class extends n{constructor(){super(...arguments),this.ranges=[]}static fromScaleRange({maxScale:e,minScale:n}){return new i({ranges:r(e,n)})}static async fromLayer(e){await e.when();const n=e.get("tileInfo.lods");let t;if(n){t=r(n[n.length-1].scale,n[0].scale)}else t=r(0,0);return new i({ranges:t})}get firstRange(){return this.ranges[0]}get lastRange(){const e=this.ranges;return e[e.length-1]}get length(){return this.ranges.length}get maxScale(){return this.lastRange.maxScale}get minScale(){return this.firstRange.minScale}isMinScaleEdge(e){const{firstRange:n}=this,t=n.minScale,a=i.RecommendedScales[n.id]||n.maxScale;return e<=t&&e>=a}isMaxScaleEdge(e){const{lastRange:n}=this,t=n.maxScale;return e<=(i.RecommendedScales[n.id]||n.minScale)&&e>=t}findScaleRange(e){const n=this.ranges;let t;if(e>=n[0].maxScale)return n[0];if(e<=n[n.length-1].minScale)return n[n.length-1];for(let a=0;a<n.length;a++){const i=n[a];if(e>=i.maxScale&&e<=i.minScale){t=i;break}}return t}findScaleRangeByIndex(e){return this.ranges[this._clampScaleRangeIndex(e)]}scaleToRangeIndex(e){return this.ranges.indexOf(this.findScaleRange(e))}clampScale(e){return Math.min(this.minScale,Math.max(this.maxScale,e))}clampMinScale(e){return 0===e?this.minScale:this.clampScale(e)}clampMaxScale(e){return this.clampScale(e)}contains(e){const n=this.ranges;let t=!1;for(let a=0;a<n.length;a++){const{maxScale:i,minScale:c}=n[a];if(e>=i&&e<=c){t=!0;break}}return t}_clampScaleRangeIndex(e){const n=0;if(e<=n)return n;const t=this.ranges.length-1;return e>t?t:Math.floor(e)}};o.RecommendedScales=Object.freeze({world:c,continent:5e7,countriesBig:25e6,countriesSmall:12e6,statesProvinces:6e6,stateProvince:3e6,counties:15e5,county:75e4,metropolitanArea:32e4,cities:16e4,city:8e4,town:4e4,neighborhood:2e4,streets:1e4,street:5e3,buildings:2500,building:1250,smallBuilding:800,rooms:400,room:100}),e([t()],o.prototype,"firstRange",null),e([t()],o.prototype,"lastRange",null),e([t()],o.prototype,"length",null),e([t()],o.prototype,"maxScale",null),e([t()],o.prototype,"minScale",null),e([t({constructOnly:!0})],o.prototype,"ranges",void 0),o=i=e([a("esri.widgets.ScaleRangeSlider.ScaleRanges")],o);const m=o;export{m as default};
|