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.
15 lines
6.3 KiB
15 lines
6.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(["exports","../../geometry/GeometryCursor","./CurveHelper"],function(e,k,h){class l{constructor(){this._values=[];this._currentValue=this._length=this.ctrlPtGap=this.extPtGap=0}isEmpty(){return 0===this._values.length}size(){return this._values.length}init(a,b,c=!0){this._setEmpty();if(!a||0===a.length)return!1;for(let f=0;f<a.length;f++){let d=Math.abs(a[f]);c&&1E-7>d&&(d=1E-7);this._values.push(d);this._length+=d}b&&a.length&1&&(this._length*=2);if(0===this._length)return!1;this.ctrlPtGap= |
|
this.extPtGap=0;this._currentValue=-1;return!0}scale(a){const b=this._values?this._values.length:0;for(let c=0;c<b;++c)this._values[c]*=a;this._length*=a;this.extPtGap*=a;this.ctrlPtGap*=a}addValue(a){this._length+=a;this._values.push(a)}firstValue(){return this._values[0]}lastValue(){return this._values[this._values.length-1]}nextValue(){this._currentValue++;this._currentValue===this._values.length&&(this._currentValue=0);return this._values[this._currentValue]}reset(){this._currentValue=-1}length(){return this._length}_setEmpty(){this.extPtGap= |
|
this.ctrlPtGap=this._length=0;this._currentValue=-1;this._values.length=0}}class m{constructor(){this.pt=null;this.sa=this.ca=0}}e.EndType=void 0;(function(a){a[a.FAIL=0]="FAIL";a[a.END=1]="END";a[a.CONTINUE=2]="CONTINUE"})(e.EndType||(e.EndType={}));class g{constructor(){this.reset()}reset(){this.segment=null;this.abscissa=this.segmentLength=0;this.isPartEnd=this.isPathEnd=!1}isValid(){return null!==this.segment}copyTo(a){a.segment=this.segment;a.segmentLength=this.segmentLength;a.abscissa=this.abscissa; |
|
a.isPathEnd=this.isPathEnd;a.isPartEnd=this.isPartEnd}}class n extends h.CurveHelper{constructor(a=0,b=!1){super(a,b);this._tolerance=h.pixelTolerance;this._currentPosition=new g}updateTolerance(a){this._tolerance=h.pixelTolerance*a}init(a,b,c=!0){c?(this._patternLength=b.length(),this._partExtPtGap=b.extPtGap,this._partCtrlPtGap=b.ctrlPtGap):this._partCtrlPtGap=this._partExtPtGap=this._patternLength=0;this._currentPosition.reset();this._partSegCount=0;this._pathCursor=a;this._seg=-1;return this._setPosAtNextPart()}curPositionIsValid(){return this._currentPosition.isValid()}nextPosition(a, |
|
b=e.EndType.FAIL){const c=new g;if(!this._nextPosition(a,c,null,b))return!1;c.copyTo(this._currentPosition);return!0}curPointAndAngle(a){a.pt=this._getPoint(this._currentPosition);const [b,c]=this._getAngleCS(this._currentPosition);a.ca=b;a.sa=c}nextPointAndAngle(a,b,c=e.EndType.FAIL){const f=new g;if(!this._nextPosition(a,f,null,c))return!1;f.copyTo(this._currentPosition);b.pt=this._getPoint(f);const [d,p]=this._getAngleCS(f);b.ca=d;b.sa=p;return!0}nextCurve(a){if(0===a)return null;const b=k.GeometryCursor.createEmptyOptimizedCIM("esriGeometryPolyline"); |
|
b.startPath();b.nextPath();const c=new g;if(!this._nextPosition(a,c,b,e.EndType.END))return null;c.copyTo(this._currentPosition);return b}isPathEnd(){return this._currentPosition.isPathEnd}getPathEnd(){return this._currentPosition.segment[1]}getPt(a){this._pathCursor.seekInPath(a);return[this._pathCursor.x,this._pathCursor.y]}getSeg(a){const b=this.getPt(a);a=this.getPt(a+1);return[b,a]}_nextPosition(a,b,c,f){if(this._currentPosition.isPathEnd)return!1;var d=this._currentPosition.abscissa;0<this._currentPosition.segmentLength&& |
|
(d/=this._currentPosition.segmentLength);for(this._currentPosition.copyTo(b);b.abscissa+a*this._partLengthRatio>b.segmentLength+this._tolerance;)if(c&&(0===c.pathSize&&(0===d?(d=b.segment[0],c.pushXY(d[0],d[1])):c.pushPoint(this.getSegCoord2D(b.segment,d))),d=b.segment[1],c.pushXY(d[0],d[1])),d=0,a-=(b.segmentLength-b.abscissa)/this._partLengthRatio,this._partSegCount)b.segment=this._nextSegment(),b.segmentLength=this.getSegLength(b.segment),b.abscissa=0,this._partSegCount--;else{if(!this._setPosAtNextPart()){if(f=== |
|
e.EndType.FAIL)return!1;b.segmentLength=this.getSegLength(b.segment);b.isPartEnd=!0;f===e.EndType.END?(b.abscissa=b.segmentLength,b.isPathEnd=!0):b.abscissa=b.segmentLength+a;return!0}this._currentPosition.copyTo(b)}b.abscissa+=a*this._partLengthRatio;c&&(0===c.pathSize&&(0===d?c.pushPoint(b.segment[0]):c.pushPoint(this.getSegCoord2D(b.segment,d))),a=b.abscissa/b.segmentLength,1===a?c.pushPoint(b.segment[1]):c.pushPoint(this.getSegCoord2D(b.segment,a)));!this._partSegCount&&Math.abs(b.abscissa-b.segmentLength)< |
|
this._tolerance&&(b.isPathEnd=this._partIsLast,b.isPartEnd=!0);return!0}_getPoint(a){return this.getSegCoord2D(this._currentPosition.segment,0>=a.segmentLength?0:a.abscissa/a.segmentLength)}_getAngleCS(a){return this.getSegAngleCS(this._currentPosition.segment,0>=a.segmentLength?0:a.abscissa/a.segmentLength)}_setPosAtNextPart(){for(;this._partSegCount;)this._hasNextSegment()&&this._nextSegment(),this._partSegCount--;if(!this._hasNextSegment())return!1;this._partLength=0;this._partIsLast=!0;for(this._partSegCount= |
|
0;this._hasNextSegment();)if(this._partLength+=this.getSegLength(this._nextSegment()),this._partSegCount++,this._pathCursor.getControlPointAt(this._getEndPointIndex())){this._partIsLast=!this._hasNextSegment();break}for(var a=this._partSegCount;a;)this._previousSegment(),--a;this._currentPosition.segment=this._nextSegment();this._currentPosition.segmentLength=this.getSegLength(this._currentPosition.segment);this._currentPosition.abscissa=0;this._currentPosition.isPathEnd=this._currentPosition.isPartEnd= |
|
!1;--this._partSegCount;a=this._getStartPointIndex();this._ctrlPtBegin=this._pathCursor.getControlPointAt(a);a=a+this._partSegCount+1;a>=this._pathCursor.pathSize&&(a=0);this._ctrlPtEnd=this._pathCursor.getControlPointAt(a);if(0<this._patternLength){a=this._ctrlPtBegin?this._partCtrlPtGap:this._partExtPtGap;const b=this._ctrlPtEnd?this._partCtrlPtGap:this._partExtPtGap;let c=Math.round((this._partLength-(a+b))/this._patternLength);0>=c&&(c=0<a+b?0:1);this._partLengthRatio=this._partLength/(a+b+c* |
|
this._patternLength);.01>this._partLengthRatio&&(this._partLengthRatio=1)}else this._partLengthRatio=1;return!0}_hasNextSegment(){return this._seg<this._pathCursor.pathSize-2}_previousSegment(){return this.getSeg(--this._seg)}_nextSegment(){return this.getSeg(++this._seg)}_getStartPointIndex(){return this._seg}_getEndPointIndex(){return this._seg+1}}e.DashPattern=l;e.GeometryWalker=n;e.Pos=m;Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}); |