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.
24 lines
10 KiB
24 lines
10 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(["exports"],function(p){p.GeometryType=void 0;(function(a){a[a.Unknown=0]="Unknown";a[a.Point=1]="Point";a[a.LineString=2]="LineString";a[a.Polygon=3]="Polygon"})(p.GeometryType||(p.GeometryType={}));class n{constructor(a,b){this.x=a;this.y=b}clone(){return new n(this.x,this.y)}equals(a,b){return a===this.x&&b===this.y}isEqual(a){return a.x===this.x&&a.y===this.y}setCoords(a,b){this.x=a;this.y=b;return this}normalize(){var a=this.x;const b=this.y;a=Math.sqrt(a*a+b*b);this.x/=a;this.y/=a;return this}rightPerpendicular(){const a= |
|
this.x;this.x=this.y;this.y=-a;return this}leftPerpendicular(){const a=this.x;this.x=-this.y;this.y=a;return this}move(a,b){this.x+=a;this.y+=b;return this}assign(a){this.x=a.x;this.y=a.y;return this}assignAdd(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this}assignSub(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this}rotate(a,b){const c=this.x,e=this.y;this.x=c*a-e*b;this.y=c*b+e*a;return this}scale(a){this.x*=a;this.y*=a;return this}length(){const a=this.x,b=this.y;return Math.sqrt(a*a+b*b)}sub(a){this.x-= |
|
a.x;this.y-=a.y;return this}add(a){this.x+=a.x;this.y+=a.y;return this}static distance(a,b){const c=b.x-a.x;a=b.y-a.y;return Math.sqrt(c*c+a*a)}static add(a,b){return new n(a.x+b.x,a.y+b.y)}static sub(a,b){return new n(a.x-b.x,a.y-b.y)}}class w{constructor(a,b,c){this.ratio=a;this.x=b;this.y=c}}class z{constructor(a,b,c,e=8,k=8){this._lines=[];this._starts=[];this.validateTessellation=!0;this._pixelRatio=e;this._pixelMargin=k;this._tileSize=512*e;this._dz=a;this._yPos=b;this._xPos=c}setPixelMargin(a){a!== |
|
this._pixelMargin&&(this._pixelMargin=a,this.setExtent(this._extent))}setExtent(a){this._extent=a;this._finalRatio=this._tileSize/a*(1<<this._dz);let b=this._pixelRatio*this._pixelMargin;b/=this._finalRatio;a>>=this._dz;b>a&&(b=a);this._margin=b;this._xmin=a*this._xPos-b;this._ymin=a*this._yPos-b;this._xmax=this._xmin+a+2*b;this._ymax=this._ymin+a+2*b}reset(a){this._type=a;this._lines=[];this._starts=[];this._line=null;this._start=0}moveTo(a,b){this._pushLine();this._prevIsIn=this._isIn(a,b);this._moveTo(a, |
|
b,this._prevIsIn);this._prevPt=new n(a,b);this._firstPt=new n(a,b);this._dist=0}lineTo(a,b){const c=this._isIn(a,b),e=new n(a,b),k=n.distance(this._prevPt,e);if(c)if(this._prevIsIn)this._lineTo(a,b,!0);else{var d=this._prevPt;var g=e;a=this._intersect(g,d);this._start=this._dist+k*(1-this._r);this._lineTo(a.x,a.y,!0);this._lineTo(g.x,g.y,!0)}else if(this._prevIsIn)g=this._prevPt,d=e,a=this._intersect(g,d),this._lineTo(a.x,a.y,!0),this._lineTo(d.x,d.y,!1);else{const f=this._prevPt;if(!(f.x<=this._xmin&& |
|
e.x<=this._xmin||f.x>=this._xmax&&e.x>=this._xmax||f.y<=this._ymin&&e.y<=this._ymin||f.y>=this._ymax&&e.y>=this._ymax)){a=[];if(f.x<this._xmin&&e.x>this._xmin||f.x>this._xmin&&e.x<this._xmin){b=(this._xmin-f.x)/(e.x-f.x);var h=f.y+b*(e.y-f.y);h<=this._ymin?g=!1:h>=this._ymax?g=!0:a.push(new w(b,this._xmin,h))}if(f.x<this._xmax&&e.x>this._xmax||f.x>this._xmax&&e.x<this._xmax)b=(this._xmax-f.x)/(e.x-f.x),h=f.y+b*(e.y-f.y),h<=this._ymin?g=!1:h>=this._ymax?g=!0:a.push(new w(b,this._xmax,h));if(f.y<this._ymin&& |
|
e.y>this._ymin||f.y>this._ymin&&e.y<this._ymin)b=(this._ymin-f.y)/(e.y-f.y),h=f.x+b*(e.x-f.x),h<=this._xmin?d=!1:h>=this._xmax?d=!0:a.push(new w(b,h,this._ymin));if(f.y<this._ymax&&e.y>this._ymax||f.y>this._ymax&&e.y<this._ymax)b=(this._ymax-f.y)/(e.y-f.y),h=f.x+b*(e.x-f.x),h<=this._xmin?d=!1:h>=this._xmax?d=!0:a.push(new w(b,h,this._ymax));if(0===a.length)d?g?this._lineTo(this._xmax,this._ymax,!0):this._lineTo(this._xmax,this._ymin,!0):g?this._lineTo(this._xmin,this._ymax,!0):this._lineTo(this._xmin, |
|
this._ymin,!0);else if(1<a.length&&a[0].ratio>a[1].ratio)this._start=this._dist+k*a[1].ratio,this._lineTo(a[1].x,a[1].y,!0),this._lineTo(a[0].x,a[0].y,!0);else for(this._start=this._dist+k*a[0].ratio,d=0;d<a.length;d++)this._lineTo(a[d].x,a[d].y,!0)}this._lineTo(e.x,e.y,!1)}this._dist+=k;this._prevIsIn=c;this._prevPt=e}close(){if(2<this._line.length){var a=this._firstPt,b=this._prevPt;a.x===b.x&&a.y===b.y||this.lineTo(a.x,a.y);a=this._line;for(b=a.length;4<=b;)if(a[0].x===a[1].x&&a[0].x===a[b-2].x|| |
|
a[0].y===a[1].y&&a[0].y===a[b-2].y)a.pop(),a[0].x=a[b-2].x,a[0].y=a[b-2].y,--b;else break}}result(a=!0){this._pushLine();if(0===this._lines.length)return null;this._type===p.GeometryType.Polygon&&a&&u.simplify(this._tileSize,this._margin*this._finalRatio,this._lines);return this._lines}resultWithStarts(){if(this._type!==p.GeometryType.LineString)throw Error("Only valid for lines");this._pushLine();const a=this._lines,b=a.length;if(0===b)return null;const c=[];for(let e=0;e<b;e++)c.push({line:a[e], |
|
start:this._starts[e]||0});return c}_isIn(a,b){return a>=this._xmin&&a<=this._xmax&&b>=this._ymin&&b<=this._ymax}_intersect(a,b){let c,e,k;if(b.x>=this._xmin&&b.x<=this._xmax)e=b.y<=this._ymin?this._ymin:this._ymax,k=(e-a.y)/(b.y-a.y),c=a.x+k*(b.x-a.x);else if(b.y>=this._ymin&&b.y<=this._ymax)c=b.x<=this._xmin?this._xmin:this._xmax,k=(c-a.x)/(b.x-a.x),e=a.y+k*(b.y-a.y);else{e=b.y<=this._ymin?this._ymin:this._ymax;c=b.x<=this._xmin?this._xmin:this._xmax;const d=(c-a.x)/(b.x-a.x),g=(e-a.y)/(b.y-a.y); |
|
d<g?(k=d,e=a.y+d*(b.y-a.y)):(k=g,c=a.x+g*(b.x-a.x))}this._r=k;return new n(c,e)}_pushLine(){this._line&&(this._type===p.GeometryType.Point?0<this._line.length&&(this._lines.push(this._line),this._starts.push(this._start)):this._type===p.GeometryType.LineString?1<this._line.length&&(this._lines.push(this._line),this._starts.push(this._start)):this._type===p.GeometryType.Polygon&&3<this._line.length&&(this._lines.push(this._line),this._starts.push(this._start)));this._line=[];this._start=0}_moveTo(a, |
|
b,c){this._type!==p.GeometryType.Polygon?c&&(a=Math.round((a-(this._xmin+this._margin))*this._finalRatio),b=Math.round((b-(this._ymin+this._margin))*this._finalRatio),this._line.push(new n(a,b))):(c||(a<this._xmin&&(a=this._xmin),a>this._xmax&&(a=this._xmax),b<this._ymin&&(b=this._ymin),b>this._ymax&&(b=this._ymax)),a=Math.round((a-(this._xmin+this._margin))*this._finalRatio),b=Math.round((b-(this._ymin+this._margin))*this._finalRatio),this._line.push(new n(a,b)),this._isV=this._isH=!1)}_lineTo(a, |
|
b,c){if(this._type!==p.GeometryType.Polygon)if(c){a=Math.round((a-(this._xmin+this._margin))*this._finalRatio);b=Math.round((b-(this._ymin+this._margin))*this._finalRatio);if(0<this._line.length&&(c=this._line[this._line.length-1],c.equals(a,b)))return;this._line.push(new n(a,b))}else this._line&&0<this._line.length&&this._pushLine();else if(c||(a<this._xmin&&(a=this._xmin),a>this._xmax&&(a=this._xmax),b<this._ymin&&(b=this._ymin),b>this._ymax&&(b=this._ymax)),a=Math.round((a-(this._xmin+this._margin))* |
|
this._finalRatio),b=Math.round((b-(this._ymin+this._margin))*this._finalRatio),this._line&&0<this._line.length){c=this._line[this._line.length-1];const e=c.x===a,k=c.y===b;e&&k||(this._isH&&e?(c.x=a,c.y=b,c=this._line[this._line.length-2],c.x===a&&c.y===b?(this._line.pop(),1>=this._line.length?this._isV=this._isH=!1:(c=this._line[this._line.length-2],this._isH=c.x===a,this._isV=c.y===b)):(this._isH=c.x===a,this._isV=c.y===b)):this._isV&&k?(c.x=a,c.y=b,c=this._line[this._line.length-2],c.x===a&&c.y=== |
|
b?(this._line.pop(),1>=this._line.length?this._isV=this._isH=!1:(c=this._line[this._line.length-2],this._isH=c.x===a,this._isV=c.y===b)):(this._isH=c.x===a,this._isV=c.y===b)):(this._line.push(new n(a,b)),this._isH=e,this._isV=k))}else this._line.push(new n(a,b))}}class A{setExtent(a){this._ratio=4096===a?1:4096/a}get validateTessellation(){return 1>this._ratio}reset(a){this._lines=[];this._line=null}moveTo(a,b){this._line&&this._lines.push(this._line);this._line=[];const c=this._ratio;this._line.push(new n(a* |
|
c,b*c))}lineTo(a,b){const c=this._ratio;this._line.push(new n(a*c,b*c))}close(){const a=this._line;a&&!a[0].isEqual(a[a.length-1])&&a.push(a[0])}result(){this._line&&this._lines.push(this._line);return 0===this._lines.length?null:this._lines}}var m;(function(a){a[a.sideLeft=0]="sideLeft";a[a.sideRight=1]="sideRight";a[a.sideTop=2]="sideTop";a[a.sideBottom=3]="sideBottom"})(m||={});class u{static simplify(a,b,c){if(c){var e=-b,k=a+b,d=-b,g=a+b;a=[];b=[];var h=c.length;for(let f=0;f<h;++f){const r= |
|
c[f];if(!r||2>r.length)continue;let q=r[0],t;const v=r.length;for(let l=1;l<v;++l)t=r[l],q.x===t.x&&(q.x<=e&&(q.y>t.y?(a.push(f),a.push(l),a.push(m.sideLeft),a.push(-1)):(b.push(f),b.push(l),b.push(m.sideLeft),b.push(-1))),q.x>=k&&(q.y<t.y?(a.push(f),a.push(l),a.push(m.sideRight),a.push(-1)):(b.push(f),b.push(l),b.push(m.sideRight),b.push(-1)))),q.y===t.y&&(q.y<=d&&(q.x<t.x?(a.push(f),a.push(l),a.push(m.sideTop),a.push(-1)):(b.push(f),b.push(l),b.push(m.sideTop),b.push(-1))),q.y>=g&&(q.x>t.x?(a.push(f), |
|
a.push(l),a.push(m.sideBottom),a.push(-1)):(b.push(f),b.push(l),b.push(m.sideBottom),b.push(-1)))),q=t}0!==a.length&&0!==b.length&&(u.fillParent(c,b,a),u.fillParent(c,a,b),e=[],u.calcDeltas(e,b,a),u.calcDeltas(e,a,b),u.addDeltas(e,c))}}static fillParent(a,b,c){const e=c.length,k=b.length;for(let r=0;r<k;r+=4){var d=b[r],g=b[r+1];const q=b[r+2],t=a[d][g-1];d=a[d][g];g=8092;let v=-1;for(let l=0;l<e;l+=4){if(c[l+2]!==q)continue;var h=c[l];const y=c[l+1];var f=a[h][y-1];h=a[h][y];switch(q){case m.sideLeft:case m.sideRight:x(t.y, |
|
f.y,h.y)&&x(d.y,f.y,h.y)&&(f=Math.abs(h.y-f.y),f<g&&(g=f,v=l));break;case m.sideTop:case m.sideBottom:x(t.x,f.x,h.x)&&x(d.x,f.x,h.x)&&(f=Math.abs(h.x-f.x),f<g&&(g=f,v=l))}}b[r+3]=v}}static calcDeltas(a,b,c){const e=b.length;for(let k=0;k<e;k+=4){const d=u.calcDelta(k,b,c,[]);a.push(b[k]);a.push(b[k+1]);a.push(b[k+2]);a.push(d)}}static calcDelta(a,b,c,e){a=b[a+3];if(-1===a)return 0;const k=e.length;if(1<k&&e[k-2]===a)return 0;e.push(a);return u.calcDelta(a,c,b,e)+1}static addDeltas(a,b){const c=a.length; |
|
let e=0;for(var k=0;k<c;k+=4){var d=a[k+3];d>e&&(e=d)}for(k=0;k<c;k+=4){d=b[a[k]];const g=a[k+1],h=e-a[k+3];switch(a[k+2]){case m.sideLeft:d[g-1].x-=h;d[g].x-=h;1===g&&(d[d.length-1].x-=h);g===d.length-1&&(d[0].x-=h);break;case m.sideRight:d[g-1].x+=h;d[g].x+=h;1===g&&(d[d.length-1].x+=h);g===d.length-1&&(d[0].x+=h);break;case m.sideTop:d[g-1].y-=h;d[g].y-=h;1===g&&(d[d.length-1].y-=h);g===d.length-1&&(d[0].y-=h);break;case m.sideBottom:d[g-1].y+=h,d[g].y+=h,1===g&&(d[d.length-1].y+=h),g===d.length- |
|
1&&(d[0].y+=h)}}}}const x=(a,b,c)=>a>=b&&a<=c||a>=c&&a<=b;p.Point=n;p.SimpleBuilder=A;p.TileClipper=z;Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}); |