// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.12/esri/copyright.txt for details.
//>>built
require({cache:{"esri/layers/labelLayerUtils/DynamicLabelClass":function(){define("dojo/_base/declare dojo/_base/lang dojo/has ../../kernel ../GraphicsLayer ../../geometry/Extent ../../geometry/Polygon".split(" "),function(A,F,z,G,D,B,C){A=A(D,{declaredClass:"esri.layers.labelLayerUtils.DynamicLabelClass",constructor:function(){this._preparedLabels=[];this._placedLabels=[];this._extent=null;this._y1=this._x1=this._y0=this._x0=this._ymax=this._ymin=this._xmax=this._xmin=0;this._scale=1},setMap:function(d,
b){this._labelLayer=b;this._xmin=d.extent.xmin;this._xmax=d.extent.xmax;this._ymin=d.extent.ymin;this._ymax=d.extent.ymax;this._scale=(this._xmax-this._xmin)/d.width},_process:function(d){this._preparedLabels=d;this._placedLabels=[];var b;for(d=this._preparedLabels.length-1;0<=d;d--){var a=this._preparedLabels[d],f=Math.min(a.labelWidth,a.labelHeight),c=a.labelWidth+0*f,f=a.labelHeight+0*f,h=(b=a.options)&&void 0!==b.lineLabelPlacement?b.lineLabelPlacement:"PlaceAtCenter",g=b&&void 0!==b.lineLabelPosition?
b.lineLabelPosition:"Above",e=b&&void 0!==b.pointPriorities?b.pointPriorities:"AboveRight",k=[2,2,1,3,0,2,3,3,2];"AboveLeft"==e?k=[1,2,2,2,0,3,2,3,3]:"AboveCenter"==e?k=[2,1,2,2,0,2,3,3,3]:"AboveRight"==e?k=[2,2,1,3,0,2,3,3,2]:"CenterLeft"==e?k=[2,2,3,1,0,3,2,2,3]:"CenterCenter"==e?k=[0,0,0,0,1,0,0,0,0]:"CenterRight"==e?k=[3,2,2,3,0,1,3,2,2]:"BelowLeft"==e?k=[2,3,3,2,0,3,1,2,2]:"BelowCenter"==e?k=[3,3,3,2,0,2,2,1,2]:"BelowRight"==e&&(k=[3,3,2,3,0,2,2,2,1]);var m=b&&void 0!==b.labelRotation?b.labelRotation:
!0,e=a.angle*(Math.PI/180);b=b&&void 0!==b.howManyLabels?b.howManyLabels:"OneLabel";if("point"==a.geometry.type)this._generatePointPositions(a,a.geometry.x,a.geometry.y,a.text,e,c,f,a.symbolWidth,a.symbolHeight,k);else if("multipoint"==a.geometry.type){h=a.geometry;for(g=0;g<h.points.length;g++)this._generatePointPositions(a,h.points[g][0],h.points[g][1],a.text,e,c,f,a.symbolWidth,a.symbolHeight,k)}else"polyline"==a.geometry.type?this._generateLinePositions(a,a.geometry,a.text,c,f,2*a.symbolHeight+
f,h,g,m):"polygon"==a.geometry.type&&this._generatePolygonPositions(a,b,a.geometry,a.text,e,c,f)}return this._placedLabels},_generatePointPositions:function(d,b,a,f,c,h,g,e,k,m){e=(e+h)*this._scale;k=(k+g)*this._scale;var n,l;for(n=1;3>=n;n++)for(l=1;9>=l;l++)if(m[l-1]==n)switch(l){case 1:if(this._findPlace(d,f,b-e,a+k,c,h,g))return;break;case 2:if(this._findPlace(d,f,b,a+k,c,h,g))return;break;case 3:if(this._findPlace(d,f,b+e,a+k,c,h,g))return;break;case 4:if(this._findPlace(d,f,b-e,a,c,h,g))return;
break;case 5:if(this._findPlace(d,f,b,a,c,h,g))return;break;case 6:if(this._findPlace(d,f,b+e,a,c,h,g))return;break;case 7:if(this._findPlace(d,f,b-e,a-k,c,h,g))return;break;case 8:if(this._findPlace(d,f,b,a-k,c,h,g))return;break;case 9:if(this._findPlace(d,f,b+e,a-k,c,h,g))return}},_generateLinePositions:function(d,b,a,f,c,h,g,e,k){var m=f*this._scale*f*this._scale,n,l,p;for(n=0;n<b.paths.length;n++){var r=b.paths[n],q=r.length,t=Math.floor((q-1)/2),u=0!==(q-1)%2?1:-1;"PlaceAtStart"==g&&(t=0,u=1);
"PlaceAtEnd"==g&&(t=q-2,u=-1);for(;0<=t&&t<q-1;){for(l=t;l<q;l++){var s=r[t][0],w=r[t][1],v=r[l][0]-s,y=r[l][1]-w;if(v*v+y*y>m){for(var x=Math.atan2(y,v);x>Math.PI/2;)x-=Math.PI;for(;x<-(Math.PI/2);)x+=Math.PI;var E=Math.sin(x),J=Math.cos(x),H=0,I=0;"Above"==e&&(H=h*E*this._scale,I=h*J*this._scale);"Below"==e&&(H=-h*E*this._scale,I=-h*J*this._scale);if(1==l-t){if(this._clipLine(s,w,r[l][0],r[l][1])&&(s=this._x1-this._x0,p=this._y1-this._y0,s*s+p*p>m&&(l=Math.atan2(p,s),v=f/2+2*c,w=v*this._scale*Math.cos(l),
v=v*this._scale*Math.sin(l),"PlaceAtStart"==g?(s=this._x0+w,p=this._y0+v):"PlaceAtEnd"==g?(s=this._x1-w,p=this._y1-v):(s=this._x0+s/2,p=this._y0+p/2),this._findPlace(d,a,s-H,p+I,k?-l:0,f,c))))return}else{var z=0;for(p=t;p<=l;p++)z=Math.max(z,Math.abs((r[p][1]-w)*J-(r[p][0]-s)*E));if(z<c&&this._findPlace(d,a,s+v/2-H,w+y/2+I,k?-x:0,f,c))return}break}}t+=u}}},_generatePolygonPositions:function(d,b,a,f,c,h,g){var e;if("ManyLabels"==b)for(b=0;b<a.rings.length;b++)e=a.rings[b],C.prototype.isClockwise(e)&&
(e=this._findCentroid(e,this._xmin,this._ymin,this._xmax,this._ymax),this._findPlace(d,f,e[0],e[1],c,h,g));else{e=this._findCentroidForFeature(a,this._xmin,this._ymin,this._xmax,this._ymax);var k=e[1],m=0;for(b=0;10>b;b++){m+=g/4;e=this._findCentroidForFeature(a,this._xmin,k+(m-g/4),this._xmax,k+(m+g/4));if(this._findPlace(d,f,e[0],e[1],c,h,g))break;e=this._findCentroidForFeature(a,this._xmin,k-(m+g/4),this._xmax,k-(m-g/4));if(this._findPlace(d,f,e[0],e[1],c,h,g))break}}},_findCentroid:function(d,
b,a,f,c){var h=d.length,g=[0,0],e=0,k=d[0][0],m=d[0][1];k>f&&(k=f);k<b&&(k=b);m>c&&(m=c);m<a&&(m=a);for(var n=1;n<h-1;n++){var l=d[n][0],p=d[n][1],r=d[n+1][0],q=d[n+1][1];l>f&&(l=f);l<b&&(l=b);p>c&&(p=c);p<a&&(p=a);r>f&&(r=f);r<b&&(r=b);q>c&&(q=c);q<a&&(q=a);var t=(l-k)*(q-m)-(r-k)*(p-m);g[0]+=t*(k+l+r);g[1]+=t*(m+p+q);e+=t}g[0]/=3*e;g[1]/=3*e;if(isNaN(g[0])||isNaN(g[1]))return g;a=[];this._fillBuffer(d,a,g);g[0]=this._sortBuffer(a,g[0],b,f);return g},_findCentroidForFeature:function(d,b,a,f,c){for(var h,
g=0,e=[0,0],k=0;k<d.rings.length;k++){var m=d.rings[k],n=m.length,l=m[0][0],p=m[0][1];l>f&&(l=f);l<b&&(l=b);p>c&&(p=c);p<a&&(p=a);for(h=1;h<n-1;h++){var r=m[h][0],q=m[h][1],t=m[h+1][0],u=m[h+1][1];r>f&&(r=f);r<b&&(r=b);q>c&&(q=c);q<a&&(q=a);t>f&&(t=f);t<b&&(t=b);u>c&&(u=c);u<a&&(u=a);var s=(r-l)*(u-p)-(t-l)*(q-p);e[0]+=s*(l+r+t);e[1]+=s*(p+q+u);g+=s}}e[0]/=3*g;e[1]/=3*g;if(isNaN(e[0])||isNaN(e[1]))return e;a=[];for(h=0;h<d.rings.length;h++)this._fillBuffer(d.rings[h],a,e);e[0]=this._sortBuffer(a,
e[0],b,f);return e},_fillBuffer:function(d,b,a){for(var f=d.length-1,c=d[0][1]>=d[f][1]?1:-1,h=0;h<=f;h++){var g=h,e=h+1;h==f&&(e=0);var k=d[g][0],g=d[g][1],m=d[e][0],e=d[e][1],n=e>=g?1:-1;if(g<=a[1]&&a[1]<=e||e<=a[1]&&a[1]<=g)a[1]!=g&&a[1]!=e?(b.push((a[1]-g)*(m-k)/(e-g)+k),c=n):a[1]==g&&a[1]!=e?(c!=n&&b.push(k),c=n):a[1]!=g&&a[1]==e?(b.push(m),c=n):a[1]==g&&a[1]==e&&(1==c&&b.push(k),b.push(m),c=n)}},_sortBuffer:function(d,b,a,f){var c=d.length;d.sort();if(0<c){for(var h=0,g=b=0;g<c-1;g+=2){var e=
Math.abs(d[g+1]-d[g]);!(d[g]<=a&&d[g+1]<=a)&&(!(d[g]>=f&&d[g+1]>=f)&&e>h)&&(h=e,b=g)}c=d[b];d=d[b+1];c>f&&(c=f);c<a&&(c=a);d>f&&(d=f);d<a&&(d=a);b=(c+d)/2}return b},_findPlace:function(d,b,a,f,c,h,g){if(isNaN(a)||isNaN(f))return!1;for(var e=0;e<this._placedLabels.length;e++){var k=this._placedLabels[e].angle,m=this._placedLabels[e].width*this._scale,n=this._placedLabels[e].height*this._scale,l=this._placedLabels[e].x-a,p=this._placedLabels[e].y-f;if(0===c&&0===k){if(this._findPlace2(-h*this._scale,
-g*this._scale,h*this._scale,g*this._scale,l-m,p-n,l+m,p+n))return!1}else{var r=new B(-h*this._scale,-g*this._scale,h*this._scale,g*this._scale,null),q=0,t=1;0!==c&&(q=Math.sin(c),t=Math.cos(c));var u=l*t-p*q,l=l*q+p*t,k=k-c,q=Math.sin(k),t=Math.cos(k),s=-m*t- -n*q,p=-m*q+-n*t,k=+m*t- -n*q,w=+m*q+-n*t,m=u+s,n=l-p,q=u+k,t=l-w,s=u-s,p=l+p,u=u-k,l=l+w,k=new C;k.addRing([[m,n],[q,t],[s,p],[u,l],[m,n]]);if(r.intersects(k))return!1}}for(;c>Math.PI/2;)c-=Math.PI;for(;c<-(Math.PI/2);)c+=Math.PI;e={};e.layer=
d;e.text=b;e.angle=c;e.x=a;e.y=f;e.width=h;e.height=g;this._placedLabels.push(e);return!0},_findPlace2:function(d,b,a,f,c,h,g,e){return(d>=c&&d<=g||a>=c&&a<=g||d<=c&&a>=g)&&(b>=h&&b<=e||f>=h&&f<=e||b<=h&&f>=e)?!0:!1},_clipLine:function(d,b,a,f){for(var c=this._code(d,b),h=this._code(a,f);0!==c||0!==h;){if(0!==(c&h))return!1;var g=a-d,e=f-b;0!==c?(d<this._xmin?(b+=e*(this._xmin-d)/g,d=this._xmin):d>this._xmax?(b+=e*(this._xmax-d)/g,d=this._xmax):b<this._ymin?(d+=g*(this._ymin-b)/e,b=this._ymin):b>
this._ymax&&(d+=g*(this._ymax-b)/e,b=this._ymax),c=this._code(d,b)):(a<this._xmin?(f+=e*(this._xmin-a)/g,a=this._xmin):a>this._xmax?(f+=e*(this._xmax-a)/g,a=this._xmax):f<this._ymin?(a+=g*(this._ymin-f)/e,f=this._ymin):f>this._ymax&&(a+=g*(this._ymax-f)/e,f=this._ymax),h=this._code(a,f))}this._x0=d;this._y0=b;this._x1=a;this._y1=f;return!0},_code:function(d,b){return(d<this._xmin?1:0)<<3|(d>this._xmax?1:0)<<2|(b<this._ymin?1:0)<<1|(b>this._ymax?1:0)}});z("extend-esri")&&F.setObject("layers.labelLayerUtils.DynamicLabelClass",
A,G);return A})},"esri/layers/labelLayerUtils/StaticLabelClass":function(){define("dojo/_base/declare dojo/_base/lang dojo/has ../../kernel ../GraphicsLayer ../../geometry/Extent ../../geometry/Polygon".split(" "),function(A,F,z,G,D,B,C){A=A(D,{declaredClass:"esri.layers.labelLayerUtils.StaticLabel",constructor:function(){this._preparedLabels=[];this._placedLabels=[];this._extent=null;this._ymax=this._ymin=this._xmax=this._xmin=0;this._scale=1;this._LINE_STEP_CONST=1.5;this._POLYGON_X_STEP_CONST=
1;this._POLYGON_Y_STEP_CONST=0.75},setMap:function(d,b){this._labelLayer=b;this._map=d;this._xmin=d.extent.xmin;this._xmax=d.extent.xmax;this._ymin=d.extent.ymin;this._ymax=d.extent.ymax;this._scale=(this._xmax-this._xmin)/d.width},_process:function(d){var b,a,f,c,h,g,e,k;this._preparedLabels=d;this._placedLabels=[];for(d=this._preparedLabels.length-1;0<=d;d--){b=this._preparedLabels[d];c=b.labelWidth;h=b.labelHeight;e=(g=b.options)&&void 0!==g.lineLabelPlacement?g.lineLabelPlacement:"PlaceAtCenter";
k=g&&void 0!==g.lineLabelPosition?g.lineLabelPosition:"Above";a=g&&void 0!==g.labelRotation?g.labelRotation:!0;f=b.angle*(Math.PI/180);var m=[];if("point"===b.geometry.type)this._generatePointPositions(b.geometry.x,b.geometry.y,b.text,f,c,h,b.symbolWidth,b.symbolHeight,g,m);else if("multipoint"===b.geometry.type)for(a=0;a<b.geometry.points.length;a++)this._generatePointPositions(b.geometry.points[a][0],b.geometry.points[a][1],b.text,f,c,h,b.symbolWidth,b.symbolHeight,g,m);else if("polyline"===b.geometry.type)if("PlaceAtStart"===
e)this._generateLinePositionsPlaceAtStart(b.geometry,!0,b.text,c,h,2*b.symbolHeight+h,e,k,a,m);else if("PlaceAtEnd"===e)this._generateLinePositionsPlaceAtEnd(b.geometry,!0,b.text,c,h,2*b.symbolHeight+h,e,k,a,m);else{g=[];var n=b.geometry.getExtent(),l=this._map.extent;n.getWidth()<c*this._scale&&n.getHeight()<c*this._scale||(0.5*n.getWidth()<l.getWidth()&&0.5*n.getHeight()<l.getHeight()?(l=0.1*Math.min(this._map.width,this._map.height)*this._scale,this._generateLinePositionsPlaceAtCenter(b.geometry,
!1,l,b.text,c,h,2*b.symbolHeight+h,e,k,a,g)):(l=this._LINE_STEP_CONST*Math.min(this._map.width,this._map.height)*this._scale,this._generateLinePositionsPlaceAtCenter(b.geometry,!0,l,b.text,c,h,2*b.symbolHeight+h,e,k,a,g)));this._postSorting(n,g,m)}else if("polygon"===b.geometry.type)for(a=0;a<b.geometry.rings.length;a++){e=b.geometry.rings[a];for(var l=n=g=k=null,p=0;p<e.length;p++){var r=e[p][0],q=e[p][1];null===k&&(k=r);null===n&&(n=r);null===g&&(g=q);null===l&&(l=q);r<k&&(k=r);r>n&&(n=r);q<g&&
(g=q);q>l&&(l=q)}n-k<4*c*this._scale&&l-g<4*h*this._scale||C.prototype.isClockwise(e)&&this._generatePolygonPositionsForManyLabels(e,b.geometry.spatialReference,b.text,f,c,h,m)}for(a=0;a<m.length;a++)e=m[a].x,k=m[a].y,void 0!==m[a].angle&&(f=m[a].angle),this._findPlace(b,b.text,e,k,f,c,h)}return this._placedLabels},_generatePointPositions:function(d,b,a,f,c,h,g,e,k,m){a=k&&k.pointPriorities?k.pointPriorities:"AboveRight";c=(g+c)*this._scale;h=(e+h)*this._scale;switch(a.toLowerCase()){case "aboveleft":d-=
c;b+=h;break;case "abovecenter":b+=h;break;case "aboveright":d+=c;b+=h;break;case "centerleft":d-=c;break;case "centercenter":break;case "centerright":d+=c;break;case "belowleft":d-=c;b-=h;break;case "belowcenter":b-=h;break;case "belowright":d+=c;b-=h;break;default:return}m.push({x:d,y:b})},_generateLinePositionsPlaceAtStart:function(d,b,a,f,c,h,g,e,k,m){g=f*this._scale;var n=this._LINE_STEP_CONST*Math.min(this._map.width,this._map.height)*this._scale,l,p,r,q,t,u,s,w;for(l=0;l<d.paths.length;l++){var v=
d.paths[l],y=g,x=0;for(p=0;p<v.length-1;p++)r=v[p][0],q=v[p][1],t=v[p+1][0],u=v[p+1][1],s=t-r,w=u-q,s=Math.sqrt(s*s+w*w),x+s>y?(x=this._generatePositionsOnLine(d.spatialReference,b,y,n,x,r,q,t,u,a,f,c,h,e,k,m),y=n):x+=s}},_generateLinePositionsPlaceAtEnd:function(d,b,a,f,c,h,g,e,k,m){g=f*this._scale;var n=this._LINE_STEP_CONST*Math.min(this._map.width,this._map.height)*this._scale,l,p,r,q,t,u,s,w;for(l=0;l<d.paths.length;l++){var v=d.paths[l],y=g,x=0;for(p=v.length-2;0<=p;p--)r=v[p+1][0],q=v[p+1][1],
t=v[p][0],u=v[p][1],s=t-r,w=u-q,s=Math.sqrt(s*s+w*w),x+s>y?(x=this._generatePositionsOnLine(d.spatialReference,b,y,n,x,r,q,t,u,a,f,c,h,e,k,m),y=n):x+=s}},_generateLinePositionsPlaceAtCenter:function(d,b,a,f,c,h,g,e,k,m,n){var l,p,r,q,t,u,s,w;for(e=0;e<d.paths.length;e++){var v=d.paths[e];if(!(2>v.length)){var y=0;for(l=0;l<v.length-1;l++)r=v[l][0],q=v[l][1],t=v[l+1][0],u=v[l+1][1],s=t-r,w=u-q,y+=Math.sqrt(s*s+w*w);var x=0;for(l=0;l<v.length-1;l++){r=v[l][0];q=v[l][1];t=v[l+1][0];u=v[l+1][1];s=t-r;
w=u-q;s=Math.sqrt(s*s+w*w);if(x+s>y/2)break;x+=s}l==v.length-1&&l--;r=v[l][0];q=v[l][1];t=v[l+1][0];u=v[l+1][1];s=t-r;w=u-q;x=y/2-x;w=Math.atan2(w,s);s=r+x*Math.cos(w);w=q+x*Math.sin(w);r=this._angleAndShifts(r,q,t,u,g,k,m);n.push({x:s+r.shiftX,y:w+r.shiftY,angle:r.angle});var y=s,E=w,x=0;for(p=l;p<v.length-1;p++)p==l?(r=y,q=E):(r=v[p][0],q=v[p][1]),t=v[p+1][0],u=v[p+1][1],s=t-r,w=u-q,s=Math.sqrt(s*s+w*w),x=x+s>a?this._generatePositionsOnLine(d.spatialReference,b,a,a,x,r,q,t,u,f,c,h,g,k,m,n):x+s;
x=0;for(p=l;0<=p;p--)p==l?(r=y,q=E):(r=v[p+1][0],q=v[p+1][1]),t=v[p][0],u=v[p][1],s=t-r,w=u-q,s=Math.sqrt(s*s+w*w),x=x+s>a?this._generatePositionsOnLine(d.spatialReference,b,a,a,x,r,q,t,u,f,c,h,g,k,m,n):x+s}}},_generatePositionsOnLine:function(d,b,a,f,c,h,g,e,k,m,n,l,p,r,q,t){m=Math.atan2(k-g,e-h);n=h;l=g;var u=n,s=l;do if(c=a-c,n+=c*Math.cos(m),l+=c*Math.sin(m),this._belongs(n,l,h,g,e,k))c=this._angleAndShifts(h,g,e,k,p,r,q),a=n+c.shiftX,s=l+c.shiftY,b?this._labelLayer._isWithinScreenArea(new B(a,
s,a,s,d))&&t.push({x:a,y:s,angle:c.angle}):t.push({x:a,y:s,angle:c.angle}),u=n,s=l,c=0,a=f;else return d=e-u,k-=s,Math.sqrt(d*d+k*k);while(1)},_postSorting:function(d,b,a){if(d&&0<b.length){var f=0.5*(d.xmin+d.xmax);d=0.5*(d.ymin+d.ymax);for(var c=b[0].x,h=b[0].y,g=Math.sqrt((c-f)*(c-f)+(h-d)*(h-d)),e=b[0].angle,k=0;k<b.length;k++){var m=b[k].x,n=b[k].y,l=Math.sqrt((m-f)*(m-f)+(n-d)*(n-d));l<g&&(c=m,h=n,g=l,e=b[k].angle)}a.push({x:c,y:h,angle:e})}},_belongs:function(d,b,a,f,c,h){if(c==a&&h==f)return!1;
if(c>a){if(d>c||d<a)return!1}else if(d<c||d>a)return!1;if(h>f){if(b>h||b<f)return!1}else if(b<h||b>f)return!1;return!0},_angleAndShifts:function(d,b,a,f,c,h,g){for(d=Math.atan2(f-b,a-d);d>Math.PI/2;)d-=Math.PI;for(;d<-(Math.PI/2);)d+=Math.PI;f=Math.sin(d);var e=Math.cos(d);a=b=0;"Above"==h&&(b=c*f*this._scale,a=c*e*this._scale);"Below"==h&&(b=-c*f*this._scale,a=-c*e*this._scale);c=[];c.angle=g?-d:0;c.shiftX=-b;c.shiftY=a;return c},_generatePolygonPositionsForManyLabels:function(d,b,a,f,c,h,g){f=this._calcRingExtent(d);
if(0.75*(f.xmax-f.xmin)>this._map.width*this._scale||0.75*(f.ymax-f.ymin)>this._map.height*this._scale){var e=this._findCentroidForRing(d);h=this._map.width*this._scale<f.xmax-f.xmin?this._POLYGON_X_STEP_CONST*this._map.width*this._scale:this._POLYGON_X_STEP_CONST*(f.xmax-f.xmin);c=this._map.height*this._scale<f.ymax-f.ymin?this._POLYGON_Y_STEP_CONST*this._map.height*this._scale:this._POLYGON_Y_STEP_CONST*(f.ymax-f.ymin);var k=e[0]-Math.round((e[0]-f.xmin)/h)*h,m=e[1]-Math.round((e[1]-f.ymin)/c)*
c,n,e=!0;for(n=m;n<f.ymax;n+=c)if(e=!e,!(n<this._ymin||n>this._ymax))for(m=k+(e?0:h/2);m<f.xmax;m+=h)this._labelLayer._isWithinScreenArea(new B(m,n,m,n,b))&&this._isPointWithinRing(a,d,m,n)&&g.push({x:m,y:n})}else{e=this._findCentroidForRing(d);for(f=0;10>f;f++)if(c=e[0],k=e[1]+(f%2?-1:1)*Math.floor(f/2)*h*this._scale,this._labelLayer._isWithinScreenArea(new B(c,k,c,k,b))&&this._isPointWithinRing(a,d,c,k)){g.push({x:c,y:k});break}}},_calcRingExtent:function(d){var b,a;a=new B;for(b=0;b<d.length-1;b++){var f=
d[b][0],c=d[b][1];if(void 0===a.xmin||f<a.xmin)a.xmin=f;if(void 0===a.ymin||c<a.ymin)a.ymin=c;if(void 0===a.xmax||f>a.xmax)a.xmax=f;if(void 0===a.ymax||c>a.ymax)a.ymax=c}return a},_isPointWithinPolygon:function(d,b,a,f){var c;for(c=0;c<b.rings.length;c++)if(this._isPointWithinRing(d,b.rings[c],a,f))return!0;return!1},_isPointWithinRing:function(d,b,a,f){var c,h,g,e,k=[],m=b.length;for(d=0;d<m-1;d++)if(c=b[d][0],h=b[d][1],g=b[d+1][0],e=b[d+1][1],!(c==g&&h==e)){if(h==e)if(f==h)k.push(c);else continue;
c==g?(h<e&&(f>=h&&f<e)&&k.push(c),h>e&&(f<=h&&f>e)&&k.push(c)):(h=(g-c)/(e-h)*(f-h)+c,c<g&&(h>=c&&h<g)&&k.push(h),c>g&&(h<=c&&h>g)&&k.push(h))}k.sort(function(a,b){return a-b});for(d=0;d<k.length-1;d++)if(c=k[d],g=k[d+1],a>=c&&a<g)if(d%2)break;else return!0;return!1},_findCentroidForRing:function(d){for(var b=d.length,a=[0,0],f=0,c=d[0][0],h=d[0][1],g=1;g<b-1;g++){var e=d[g][0],k=d[g][1],m=d[g+1][0],n=d[g+1][1],l=(e-c)*(n-h)-(m-c)*(k-h);a[0]+=l*(c+e+m);a[1]+=l*(h+k+n);f+=l}a[0]/=3*f;a[1]/=3*f;return a},
_findCentroidForFeature:function(d){for(var b=0,a=[0,0],f=0;f<d.rings.length;f++)for(var c=d.rings[f],h=c.length,g=c[0][0],e=c[0][1],k=1;k<h-1;k++){var m=c[k][0],n=c[k][1],l=c[k+1][0],p=c[k+1][1],r=(m-g)*(p-e)-(l-g)*(n-e);a[0]+=r*(g+m+l);a[1]+=r*(e+n+p);b+=r}a[0]/=3*b;a[1]/=3*b;return a},_findPlace:function(d,b,a,f,c,h,g){if(isNaN(a)||isNaN(f))return!1;for(var e=0;e<this._placedLabels.length;e++){var k=this._placedLabels[e].angle,m=this._placedLabels[e].width*this._scale,n=this._placedLabels[e].height*
this._scale,l=this._placedLabels[e].x-a,p=this._placedLabels[e].y-f;if(0===c&&0===k){if(this._findPlace2(-h*this._scale,-g*this._scale,h*this._scale,g*this._scale,l-m,p-n,l+m,p+n))return!1}else{var r=new B(-h*this._scale,-g*this._scale,h*this._scale,g*this._scale,null),q=0,t=1;0!==c&&(q=Math.sin(c),t=Math.cos(c));var u=l*t-p*q,l=l*q+p*t,k=k-c,q=Math.sin(k),t=Math.cos(k),s=-m*t- -n*q,p=-m*q+-n*t,k=+m*t- -n*q,w=+m*q+-n*t,m=u+s,n=l-p,q=u+k,t=l-w,s=u-s,p=l+p,u=u-k,l=l+w,k=new C;k.addRing([[m,n],[q,t],
[s,p],[u,l],[m,n]]);if(r.intersects(k))return!1}}for(;c>Math.PI/2;)c-=Math.PI;for(;c<-(Math.PI/2);)c+=Math.PI;e={};e.layer=d;e.text=b;e.angle=c;e.x=a;e.y=f;e.width=h;e.height=g;this._placedLabels.push(e);return!0},_findPlace2:function(d,b,a,f,c,h,g,e){return(d>=c&&d<=g||a>=c&&a<=g||d<=c&&a>=g)&&(b>=h&&b<=e||f>=h&&f<=e||b<=h&&f>=e)?!0:!1}});z("extend-esri")&&F.setObject("layers.labelLayerUtils.StaticLabel",A,G);return A})},"*noref":1}});
define("esri/layers/LabelLayer","require dojo/_base/declare dojo/_base/lang dojo/number dojo/_base/array dojo/_base/connect dojo/has dojox/gfx/_base ../kernel ../lang ../graphic ../PopupInfo ./labelLayerUtils/DynamicLabelClass ./labelLayerUtils/StaticLabelClass ../symbols/TextSymbol ../symbols/ShieldLabelSymbol ../geometry/Extent ../geometry/Point ../geometry/webMercatorUtils ./GraphicsLayer ./LabelClass ../renderers/SimpleRenderer".split(" "),function(A,F,z,G,D,B,C,d,b,a,f,c,h,g,e,k,m,n,l,p,r,q){function t(a){return"sizeInfo"===
a.type}A=F(p,{declaredClass:"esri.layers.LabelLayer",constructor:function(a){this.id="labels";this.featureLayers=[];this._featureLayerInfos=[];this._preparedLabels=[];this._engineType="STATIC";this._mapEventHandlers=[];a&&(a.id&&(this.id=a.id),a.mode&&(this._engineType="DYNAMIC"===a.mode.toUpperCase()?"DYNAMIC":"STATIC"))},_setMap:function(a){var b=this.inherited(arguments);this._map&&this._mapEventHandlers.push(this._map.on("extent-change",z.hitch(this,"refresh")));this.refresh();return b},_unsetMap:function(){var a;
for(a=0;a<this._mapEventHandlers.length;a++)B.disconnect(this._mapEventHandlers[a]);this.refresh();this.inherited(arguments)},setAlgorithmType:function(a){this._engineType=a&&"DYNAMIC"===a.toUpperCase()?"DYNAMIC":"STATIC";this.refresh()},addFeatureLayer:function(a,b,d,c){if(!this.getFeatureLayer(a.layerId)){var e=[];e.push(a.on("update-end",z.hitch(this,"refresh")));e.push(a.on("suspend",z.hitch(this,"refresh")));e.push(a.on("resume",z.hitch(this,"refresh")));e.push(a.on("edits-complete",z.hitch(this,
"refresh")));e.push(a.on("labeling-info-change",z.hitch(this,"refresh")));e.push(a.on("time-extent-change",z.hitch(this,"refresh")));e.push(a.on("show-labels-change",z.hitch(this,"refresh")));this._featureLayerInfos.push({FeatureLayer:a,LabelExpressionInfo:d,LabelingOptions:c,LabelRenderer:b,EventHandlers:e});this.featureLayers.push(a);this.refresh()}},getFeatureLayer:function(a){var b,d;for(b=0;b<this.featureLayers.length;b++)if(d=this.featureLayers[b],void 0!==d&&d.id==a)return d;return null},removeFeatureLayer:function(a){var b;
a=this.getFeatureLayer(a);if(void 0!==a&&(b=D.indexOf(this.featureLayers,a),-1<b)){this.featureLayers.splice(b,1);for(a=0;a<this._featureLayerInfos[b].EventHandlers.length;a++)B.disconnect(this._featureLayerInfos[b].EventHandlers[a]);this._featureLayerInfos.splice(b,1);this.refresh()}},removeAllFeatureLayers:function(){var a;for(a=0;a<this.featureLayers.length;a++){for(var b=0;b<this._featureLayerInfos[a].EventHandlers.length;b++)B.disconnect(this._featureLayerInfos[a].EventHandlers[b]);this.featureLayers=
[];this._featureLayerInfos=[]}this.refresh()},getFeatureLayers:function(){return this.featureLayers},getFeatureLayerInfo:function(a){var b,d;for(b=0;b<this.featureLayers.length;b++)if(d=this.featureLayers[b],void 0!==d&&d.id==a)return this._featureLayerInfos[b];return null},refresh:function(a){var b,d,e,c,f,k=[],l="DYNAMIC"===this._engineType?new h:new g;if(this._map){l.setMap(this._map,this);this._preparedLabels=[];for(a=0;a<this.featureLayers.length;a++)if(d=this.featureLayers[a],d.visible&&d.showLabels&&
d.visibleAtMapScale&&!d._suspended)if(b=this._featureLayerInfos[a],b.LabelRenderer){if(k=d.labelingInfo)if(f=k[0])c=this._getLabelExpression(f),this._convertOptions(f);e=b.LabelRenderer;b.LabelExpressionInfo&&(c=b.LabelExpressionInfo);f=this._convertOptions(null);b.LabelingOptions&&(void 0!==b.LabelingOptions.lineLabelPlacement&&(f.lineLabelPlacement=b.LabelingOptions.lineLabelPlacement),void 0!==b.LabelingOptions.lineLabelPosition&&(f.lineLabelPosition=b.LabelingOptions.lineLabelPosition),void 0!==
b.LabelingOptions.labelRotation&&(f.labelRotation=b.LabelingOptions.labelRotation),void 0!==b.LabelingOptions.howManyLabels&&(f.howManyLabels=b.LabelingOptions.howManyLabels));e instanceof r&&(c=this._getLabelExpression(e),e=new q(e.symbol),f=this._convertOptions(e));this._addLabels(d,e,c,f)}else if(k=d.labelingInfo)for(b=k.length-1;0<=b;b--)if(f=k[b])e=new r(f instanceof r?f.toJson():f),c=this._getLabelExpression(f),f=this._convertOptions(f),this._addLabels(d,e,c,f);c=l._process(this._preparedLabels);
this.clear();this.drawLabels(this._map,c)}},drawLabels:function(a,b){this._scale=(a.extent.xmax-a.extent.xmin)/a.width;var d;for(d=0;d<b.length;d++){var c=b[d],g=c.x,h=c.y,k=c.text,l=c.angle,m=c.layer.labelSymbol;"polyline"==c.layer.geometry.type&&c.layer.options.labelRotation?m.setAngle(l*(180/Math.PI)):m.setAngle(0);m.setText(k);c=g;m instanceof e&&(g=m.getHeight(),l=Math.sin(l),c-=0.25*g*this._scale*l,h-=0.33*g*this._scale);l=new f(new n(c,h,a.extent.spatialReference));l.setSymbol(m);this.add(l)}},
_addLabels:function(a,b,d,c){var e,f,g,h;if(this._isWithinScaleRange(b.minScale,b.maxScale)&&d&&""!==d){var k=this._map,m=!a.url&&!k.spatialReference.equals(a.spatialReference);for(e=0;e<a.graphics.length;e++)if(f=a.graphics[e],!1!==f.visible){g=f.geometry;if(m){if(!l.canProject(g,k))continue;g=l.project(g,k)}g&&(this._isWhere(b.where,f.attributes)&&this._isWithinScreenArea(g))&&(h=this._buildLabelText(d,f.attributes,a.fields,c),this._addLabel(h,b,a.renderer,f,c,g,k))}}},_isWithinScreenArea:function(a){a=
"point"===a.type?new m(a.x,a.y,a.x,a.y,a.spatialReference):a.getExtent();a=this._intersects(this._map,a);return null===a||0===a.length?!1:!0},_isWithinScaleRange:function(a,b){var d=this._map.getScale();return 0<a&&d>=a||0<b&&d<=b?!1:!0},_isWhere:function(a,b){try{if(!a)return!0;if(a){var d=a.split(" ");if(3===d.length)return this._sqlEquation(b[d[0].substr(1,d[0].length-2)],d[1],d[2]);if(7===d.length){var c=this._sqlEquation(b[d[0].substr(1,d[0].length-2)],d[1],d[2]),e=d[3],f=this._sqlEquation(b[d[4].substr(1,
d[4].length-2)],d[5],d[6]);switch(e){case "AND":return c&&f;case "OR":return c||f}}}return!1}catch(g){console.log("Error.: can't parse \x3d "+a)}},_sqlEquation:function(a,b,d){switch(b){case "\x3d":return a==d?!0:!1;case "\x3c\x3e":return a!=d?!0:!1;case "\x3e":return a>d?!0:!1;case "\x3e\x3d":return a>=d?!0:!1;case "\x3c":return a<d?!0:!1;case "\x3c\x3d":return a<=d?!0:!1}return!1},_getSizeInfo:function(a){return a?a.sizeInfo||D.filter(a.visualVariables,t)[0]:null},_addLabel:function(a,b,c,f,g,h,
l){var m,n,p,q;if(a&&""!==z.trim(a)&&b){m=b.getSymbol(f);m instanceof e?(m=new e(m.toJson()),m.setVerticalAlignment("baseline"),m.setHorizontalAlignment("center")):m=m instanceof k?new k(m.toJson()):new e;m.setText(a);b.symbol=m;if(p=this._getProportionalSize(b.sizeInfo,f.attributes))m instanceof e?m.setSize(p):m instanceof k&&(m.setWidth(p),m.setHeight(p));q=p=0;if(c){n=c.getSymbol(f);var r=this._getSizeInfo(c);if(r)q=p=c.getSize(f,{sizeInfo:r,resolution:l.getResolutionInMeters()});else if(n)if("simplemarkersymbol"==
n.type)q=p=n.size;else if("picturemarkersymbol"==n.type)p=n.width,q=n.height;else if("simplelinesymbol"==n.type||"cartographiclinesymbol"==n.type)p=n.width}c={};c.graphic=f;c.options=g;c.geometry=h;c.labelRenderer=b;c.labelSymbol=m;c.labelWidth=m.getWidth()/2;c.labelHeight=m.getHeight()/2;c.symbolWidth=d.normalizedLength(p)/2;c.symbolHeight=d.normalizedLength(q)/2;c.text=a;c.angle=m.angle;this._preparedLabels.push(c)}},_buildLabelText:function(b,d,e,f){return b.replace(/{[^}]*}/g,function(b){var g,
h=b;for(g=0;g<e.length;g++)if("{"+e[g].name+"}"==b){var h=d[e[g].name],k=e[g].domain;if(k&&z.isObject(k)){if("codedValue"==k.type)for(b=0;b<k.codedValues.length;b++)k.codedValues[b].code==h&&(h=k.codedValues[b].name);else"range"==k.type&&(k.minValue<=h&&h<=k.maxValue)&&(h=k.name);break}k=e[g].type;if("esriFieldTypeDate"==k)(k="DateFormat"+c.prototype._dateFormats[f&&f.dateFormat||"shortDate"])&&(h=a.substitute({myKey:h},"${myKey:"+k+"}"));else if("esriFieldTypeInteger"==k||"esriFieldTypeSmallInteger"==
k||"esriFieldTypeLong"==k||"esriFieldTypeDouble"==k)f&&(f.numberFormat&&f.numberFormat.digitSeparator&&f.numberFormat.places)&&(h=G.format(h,{places:f.numberFormat.places}))}return h})},_getLabelExpression:function(a){return a.labelExpressionInfo?a.labelExpressionInfo.value:this._validSyntax(a.labelExpression)?this._convertLabelExpression(a.labelExpression):""},_validSyntax:function(a){return/^(\s*\[[^\]]+\]\s*)+$/i.test(a)},_convertLabelExpression:function(a){return a.replace(RegExp("\\[","g"),"{").replace(RegExp("\\]",
"g"),"}")},_getProportionalSize:function(b,d){if(!b)return null;var c=a.substitute(d,"${"+b.field+"}",{first:!0});return!b.minSize||!b.maxSize||!b.minDataValue||!b.maxDataValue||!c||0>=b.maxDataValue-b.minDataValue?null:(b.maxSize-b.minSize)/(b.maxDataValue-b.minDataValue)*(c-b.minDataValue)+b.minSize},_convertOptions:function(a){var b="shortDate",d=null,c="",e=!0;a&&(void 0!==a.format&&(b=a.format.dateFormat,d={places:a.format.places,digitSeparator:a.format.digitSeparator}),c=a.labelPlacement);if("always-horizontal"==
c||"esriServerPolygonPlacementAlwaysHorizontal"==c)e=!1;return{dateFormat:b,numberFormat:d,pointPriorities:"above-center"==c||"esriServerPointLabelPlacementAboveCenter"==c?"AboveCenter":"above-left"==c||"esriServerPointLabelPlacementAboveLeft"==c?"AboveLeft":"above-right"==c||"esriServerPointLabelPlacementAboveRight"==c?"AboveRight":"below-center"==c||"esriServerPointLabelPlacementBelowCenter"==c?"BelowCenter":"below-left"==c||"esriServerPointLabelPlacementBelowLeft"==c?"BelowLeft":"below-right"==
c||"esriServerPointLabelPlacementBelowRight"==c?"BelowRight":"center-center"==c||"esriServerPointLabelPlacementCenterCenter"==c?"CenterCenter":"center-left"==c||"esriServerPointLabelPlacementCenterLeft"==c?"CenterLeft":"center-right"==c||"esriServerPointLabelPlacementCenterRight"==c?"CenterRight":"AboveRight",lineLabelPlacement:"above-start"==c||"below-start"==c||"center-start"==c?"PlaceAtStart":"above-end"==c||"below-end"==c||"center-end"==c?"PlaceAtEnd":"PlaceAtCenter",lineLabelPosition:"above-after"==
c||"esriServerLinePlacementAboveAfter"==c||"above-along"==c||"esriServerLinePlacementAboveAlong"==c||"above-before"==c||"esriServerLinePlacementAboveBefore"==c||"above-start"==c||"esriServerLinePlacementAboveStart"==c||"above-end"==c||"esriServerLinePlacementAboveEnd"==c?"Above":"below-after"==c||"esriServerLinePlacementBelowAfter"==c||"below-along"==c||"esriServerLinePlacementBelowAlong"==c||"below-before"==c||"esriServerLinePlacementBelowBefore"==c||"below-start"==c||"esriServerLinePlacementBelowStart"==
c||"below-end"==c||"esriServerLinePlacementBelowEnd"==c?"Below":"center-after"==c||"esriServerLinePlacementCenterAfter"==c||"center-along"==c||"esriServerLinePlacementCenterAlong"==c||"center-before"==c||"esriServerLinePlacementCenterBefore"==c||"center-start"==c||"esriServerLinePlacementCenterStart"==c||"center-end"==c||"esriServerLinePlacementCenterEnd"==c?"OnLine":"Above",labelRotation:e,howManyLabels:"OneLabel"}}});C("extend-esri")&&z.setObject("layers.LabelLayer",A,b);return A});