/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */

if(!dojo._hasResource["esri.geometry"]){dojo._hasResource["esri.geometry"]=true;dojo.provide("esri.geometry");dojo.require("dojox.gfx._base");dojo.require("esri.WKIDUnitConversion");dojo.require("esri.geometry.utils");esri.Units={CENTIMETERS:"esriCentimeters",DECIMAL_DEGREES:"esriDecimalDegrees",DEGREE_MINUTE_SECONDS:"esriDegreeMinuteSeconds",DECIMETERS:"esriDecimeters",FEET:"esriFeet",INCHES:"esriInches",KILOMETERS:"esriKilometers",METERS:"esriMeters",MILES:"esriMiles",MILLIMETERS:"esriMillimeters",NAUTICAL_MILES:"esriNauticalMiles",POINTS:"esriPoints",UNKNOWN:"esriUnknownUnits",YARDS:"esriYards",ACRES:"esriAcres",ARES:"esriAres",SQUARE_KILOMETERS:"esriSquareKilometers",SQUARE_MILES:"esriSquareMiles",SQUARE_FEET:"esriSquareFeet",SQUARE_METERS:"esriSquareMeters",HECTARES:"esriHectares",SQUARE_YARDS:"esriSquareYards",SQUARE_INCHES:"esriSquareInches",SQUARE_MILLIMETERS:"esriSquareMillimeters",SQUARE_CENTIMETERS:"esriSquareCentimeters",SQUARE_DECIMETERS:"esriSquareDecimeters"};(function(){var _1="PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]";var _2=[-20037508.342788905,20037508.342788905];var _3=[-20037508.342787,20037508.342787];dojo.declare("esri.SpatialReference",null,{constructor:function(_4){if(_4){if(dojo.isObject(_4)){dojo.mixin(this,_4);}else{if(dojo.isString(_4)){this.wkt=_4;}else{this.wkid=_4;}}}},wkid:null,wkt:null,_info:{"102113":{wkTemplate:"PROJCS[\"WGS_1984_Web_Mercator\",GEOGCS[\"GCS_WGS_1984_Major_Auxiliary_Sphere\",DATUM[\"D_WGS_1984_Major_Auxiliary_Sphere\",SPHEROID[\"WGS_1984_Major_Auxiliary_Sphere\",6378137.0,0.0]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],PARAMETER[\"Standard_Parallel_1\",0.0],UNIT[\"Meter\",1.0]]",valid:_2,origin:_3,dx:0.00001},"102100":{wkTemplate:_1,valid:_2,origin:_3,dx:0.00001},"3857":{wkTemplate:_1,valid:_2,origin:_3,dx:0.00001},"4326":{wkTemplate:"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",${Central_Meridian}],UNIT[\"Degree\",0.0174532925199433]]",altTemplate:"PROJCS[\"WGS_1984_Plate_Carree\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Plate_Carree\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],UNIT[\"Degrees\",111319.491]]",valid:[-180,180],origin:[-180,180],dx:0.00001}},_isWebMercator:function(){return dojo.indexOf([102113,102100,3857,3785],this.wkid)!==-1;},_isWrappable:function(){return dojo.indexOf([102113,102100,3857,3785,4326],this.wkid)!==-1;},_getInfo:function(){return this.wkid?this._info[this.wkid]:null;},toJson:function(){if(this.wkid!==null){return {wkid:this.wkid};}else{if(this.wkt!==null){return {wkt:this.wkt};}}return null;}});}());dojo.mixin(esri.geometry,(function(){var _5=6378137,PI=3.141592653589793,_6=57.29577951308232,_7=0.017453292519943,_8=Math.floor,_9=Math.log,_a=Math.sin,_b=Math.exp,_c=Math.atan;function _d(_e){return _e*_6;};function _f(deg){return deg*_7;};function _10(lng,lat){var _11=_f(lat);return [_f(lng)*_5,_5/2*_9((1+_a(_11))/(1-_a(_11)))];};function _12(x,y,_13){var _14=_d(x/_5);if(_13){return [_14,_d((PI/2)-(2*_c(_b(-1*y/_5))))];}return [_14-(_8((_14+180)/360)*360),_d((PI/2)-(2*_c(_b(-1*y/_5))))];};function _15(_16,_17,sr,_18){if(_16 instanceof esri.geometry.Point){var pt=_17(_16.x,_16.y,_18);return new esri.geometry.Point(pt[0],pt[1],new esri.SpatialReference(sr));}else{if(_16 instanceof esri.geometry.Extent){var min=_17(_16.xmin,_16.ymin,_18),max=_17(_16.xmax,_16.ymax,_18);return new esri.geometry.Extent(min[0],min[1],max[0],max[1],new esri.SpatialReference(sr));}else{if(_16 instanceof esri.geometry.Polyline||_16 instanceof esri.geometry.Polygon){var _19=_16 instanceof esri.geometry.Polyline,_1a=_19?_16.paths:_16.rings,_1b=[],_1c;dojo.forEach(_1a,function(_1d){_1b.push(_1c=[]);dojo.forEach(_1d,function(iPt){_1c.push(_17(iPt[0],iPt[1],_18));});});if(_19){return new esri.geometry.Polyline({paths:_1b,spatialReference:sr});}else{return new esri.geometry.Polygon({rings:_1b,spatialReference:sr});}}else{if(_16 instanceof esri.geometry.Multipoint){var _1e=[];dojo.forEach(_16.points,function(iPt){_1e.push(_17(iPt[0],iPt[1],_18));});return new esri.geometry.Multipoint({points:_1e,spatialReference:sr});}}}}};var _1f=39.37,_20=20015077/180,ecd=esri.config.defaults,_21=esri.WKIDUnitConversion;return {geographicToWebMercator:function(_22){return _15(_22,_10,{wkid:102100});},webMercatorToGeographic:function(_23,_24){return _15(_23,_12,{wkid:4326},_24);},getScale:function(map){var _25,_26,_27,wkt;if(arguments.length>1){_25=arguments[0];_26=arguments[1];_27=arguments[2];}else{_25=map.extent;_26=map.width;var sr=map.spatialReference;if(sr){_27=sr.wkid;wkt=sr.wkt;}}var _28;if(_27){_28=_21.values[_21[_27]];}else{if(wkt&&(wkt.search(/^PROJCS/i)!==-1)){var _29=/UNIT\[([^\]]+)\]\]$/i.exec(wkt);if(_29&&_29[1]){_28=parseFloat(_29[1].split(",")[1]);}}}return esri.geometry._getScale(_25,_26,_28);},_getScale:function(_2a,_2b,_2c){return (_2a.getWidth()/_2b)*(_2c||_20)*_1f*ecd.screenDPI;},getExtentForScale:function(map,_2d){var _2e,wkt,sr=map.spatialReference;if(sr){_2e=sr.wkid;wkt=sr.wkt;}var _2f;if(_2e){_2f=_21.values[_21[_2e]];}else{if(wkt&&(wkt.search(/^PROJCS/i)!==-1)){var _30=/UNIT\[([^\]]+)\]\]$/i.exec(wkt);if(_30&&_30[1]){_2f=parseFloat(_30[1].split(",")[1]);}}}return esri.geometry._getExtentForScale(map.extent,map.width,_2f,_2d,true);},_getExtentForScale:function(_31,_32,_33,_34,_35){var _36;if(_35){_36=_33;}else{_36=_21.values[_21[_33]];}return _31.expand(((_34*_32)/((_36||_20)*_1f*ecd.screenDPI))/_31.getWidth());}};}()),{defaultPoint:{type:"point",x:0,y:0},defaultMultipoint:{type:"multipoint",points:null},defaultExtent:{type:"extent",xmin:0,ymin:0,xmax:0,ymax:0},defaultPolyline:{type:"polyline",paths:null},defaultPolygon:{type:"polygon",rings:null},_rectToExtent:function(_37){return new esri.geometry.Extent(parseFloat(_37.x),parseFloat(_37.y)-parseFloat(_37.height),parseFloat(_37.x)+parseFloat(_37.width),parseFloat(_37.y),_37.spatialReference);},_extentToRect:function(_38){return new esri.geometry.Rect(_38.xmin,_38.ymax,_38.getWidth(),_38.getHeight(),_38.spatialReference);},fromJson:function(_39){if(_39.x!==undefined&&_39.y!==undefined){return new esri.geometry.Point(_39);}else{if(_39.paths!==undefined){return new esri.geometry.Polyline(_39);}else{if(_39.rings!==undefined){return new esri.geometry.Polygon(_39);}else{if(_39.points!==undefined){return new esri.geometry.Multipoint(_39);}else{if(_39.xmin!==undefined&&_39.ymin!==undefined&&_39.xmax!==undefined&&_39.ymax!==undefined){return new esri.geometry.Extent(_39);}}}}}},getJsonType:function(_3a){if(_3a instanceof esri.geometry.Point){return "esriGeometryPoint";}else{if(_3a instanceof esri.geometry.Polyline){return "esriGeometryPolyline";}else{if(_3a instanceof esri.geometry.Polygon){return "esriGeometryPolygon";}else{if(_3a instanceof esri.geometry.Extent){return "esriGeometryEnvelope";}else{if(_3a instanceof esri.geometry.Multipoint){return "esriGeometryMultipoint";}}}}}return null;},getGeometryType:function(_3b){if(_3b==="esriGeometryPoint"){return esri.geometry.Point;}else{if(_3b==="esriGeometryPolyline"){return esri.geometry.Polyline;}else{if(_3b==="esriGeometryPolygon"){return esri.geometry.Polygon;}else{if(_3b==="esriGeometryEnvelope"){return esri.geometry.Extent;}else{if(_3b==="esriGeometryMultipoint"){return esri.geometry.Multipoint;}}}}}return null;},isClockwise:function(arr){var _3c=0,i,il=arr.length,_3d=dojo.isArray(arr[0])?function(p1,p2){return p1[0]*p2[1]-p2[0]*p1[1];}:function(p1,p2){return p1.x*p2.y-p2.x*p1.y;};for(i=0;i<il;i++){_3c+=_3d(arr[i],arr[(i+1)%il]);}return (_3c/2)<=0;},toScreenPoint:function(ext,wd,ht,pt,_3e){if(_3e){return new esri.geometry.Point((pt.x-ext.xmin)*(wd/ext.getWidth()),(ext.ymax-pt.y)*(ht/ext.getHeight()));}else{return new esri.geometry.Point(Math.round((pt.x-ext.xmin)*(wd/ext.getWidth())),Math.round((ext.ymax-pt.y)*(ht/ext.getHeight())));}},toScreenGeometry:function(ext,wd,ht,g){var x=ext.xmin,y=ext.ymax,rwd=wd/ext.getWidth(),rht=ht/ext.getHeight(),_3f=dojo.forEach,_40=Math.round;if(g instanceof esri.geometry.Point){return new esri.geometry.Point(_40((g.x-x)*rwd),_40((y-g.y)*rht));}else{if(g instanceof esri.geometry.Multipoint){var mp=new esri.geometry.Multipoint(),mpp=mp.points;_3f(g.points,function(pt,i){mpp[i]=[_40((pt[0]-x)*rwd),_40((y-pt[1])*rht)];});return mp;}else{if(g instanceof esri.geometry.Extent){return new esri.geometry.Extent(_40((g.xmin-x)*rwd),_40((y-g.ymin)*rht),_40((g.xmax-x)*rwd),_40((y-g.ymax)*rwd));}else{if(g instanceof esri.geometry.Polyline){var _41=new esri.geometry.Polyline(),_42=_41.paths,_43;_3f(g.paths,function(_44,i){_43=(_42[i]=[]);_3f(_44,function(pt,j){_43[j]=[_40((pt[0]-x)*rwd),_40((y-pt[1])*rht)];});});return _41;}else{if(g instanceof esri.geometry.Polygon){var _45=new esri.geometry.Polygon(),_46=_45.rings,_47;_3f(g.rings,function(_48,i){_47=(_46[i]=[]);_3f(_48,function(pt,j){_47[j]=[_40((pt[0]-x)*rwd),_40((y-pt[1])*rht)];});});return _45;}}}}}},_toScreenPath:(function(){var _49=(function(){if(dojo.isIE<9){return function(x,y,rwd,rht,dx,dy,_4a){var _4b=[],_4c=Math.round,p,pl=_4a.length,_4d,_4e,_4f,pt,x1,y1,x2,y2;for(p=0;p<pl;p++){_4d=_4a[p];pt=_4d[0];if((_4f=_4d.length)>1){pt=_4d[0];x1=_4c(((pt[0]-x)*rwd)+dx);y1=_4c(((y-pt[1])*rht)+dy);x2=_4c(((_4d[1][0]-x)*rwd)+dx);y2=_4c(((y-_4d[1][1])*rht)+dy);_4b.push("M",x1+","+y1,"L",x2+","+y2);for(_4e=2;_4e<_4f;_4e++){pt=_4d[_4e];x1=_4c(((pt[0]-x)*rwd)+dx);y1=_4c(((y-pt[1])*rht)+dy);_4b.push(x1+","+y1);}}else{x1=_4c(((pt[0]-x)*rwd)+dx);y1=_4c(((y-pt[1])*rht)+dy);_4b.push("M",x1+","+y1);}}return _4b;};}else{return function(x,y,rwd,rht,dx,dy,_50){var _51=[],i,j,il,jl,_52,pt,_53=Math.round;for(i=0,il=_50?_50.length:0;i<il;i++){_52=_50[i];_51.push("M");for(j=0,jl=_52?_52.length:0;j<jl;j++){pt=_52[j];_51.push(_53(((pt[0]-x)*rwd)+dx)+","+_53(((y-pt[1])*rht)+dy));}}return _51;};}}());return function(ext,wd,ht,g,dx,dy){var _54=g instanceof esri.geometry.Polyline;return _49(ext.xmin,ext.ymax,wd/ext.getWidth(),ht/ext.getHeight(),dx,dy,_54?g.paths:g.rings);};}()),toMapPoint:function(ext,wd,ht,pt){return new esri.geometry.Point(ext.xmin+(pt.x/(wd/ext.getWidth())),ext.ymax-(pt.y/(ht/ext.getHeight())),ext.spatialReference);},toMapGeometry:function(ext,wd,ht,g){var x=ext.xmin,y=ext.ymax,sr=ext.spatialReference,rwd=wd/ext.getWidth(),rht=ht/ext.getHeight(),_55=dojo.forEach;if(g instanceof esri.geometry.Point){return new esri.geometry.Point(x+(g.x/rwd),y-(g.y/rht),sr);}else{if(g instanceof esri.geometry.Multipoint){var mp=new esri.geometry.Multipoint(sr),mpp=mp.points;_55(g.points,function(pt,i){mpp[i]=[x+(pt[0]/rwd),y-(pt[1]/rht)];});return mp;}else{if(g instanceof esri.geometry.Extent){return new esri.geometry.Extent(x+(g.xmin/rwd),y-(g.ymin/rht),x+(g.xmax/rwd),y-(g.ymax/rht),sr);}else{if(g instanceof esri.geometry.Polyline){var _56=new esri.geometry.Polyline(sr),_57=_56.paths,_58;_55(g.paths,function(_59,i){_58=(_57[i]=[]);_55(_59,function(pt,j){_58[j]=[x+(pt[0]/rwd),y-(pt[1]/rht)];});});return _56;}else{if(g instanceof esri.geometry.Polygon){var _5a=new esri.geometry.Polygon(sr),_5b=_5a.rings,_5c;_55(g.rings,function(_5d,i){_5c=(_5b[i]=[]);_55(_5d,function(pt,j){_5c[j]=[x+(pt[0]/rwd),y-(pt[1]/rht)];});});return _5a;}}}}}},getLength:function(pt1,pt2){var dx=pt2.x-pt1.x,dy=pt2.y-pt1.y;return Math.sqrt(dx*dx+dy*dy);},_getLength:function(pt1,pt2){var dx=pt2[0]-pt1[0],dy=pt2[1]-pt1[1];return Math.sqrt(dx*dx+dy*dy);},getMidpoint:function(pt0,pt1){return esri.geometry.getPointOnLine(pt0,pt1,0.5);},getPointOnLine:function(pt0,pt1,_5e){if(pt0 instanceof esri.geometry.Point){return new esri.geometry.Point(pt0.x+_5e*(pt1.x-pt0.x),pt0.y+_5e*(pt1.y-pt0.y));}else{return [pt0[0]+_5e*(pt1[0]-pt0[0]),pt0[1]+_5e*(pt1[1]-pt0[1])];}},_equals:function(n1,n2){return Math.abs(n1-n2)<1e-8;},getLineIntersection:function(_5f,_60,_61,_62){var pt=esri.geometry._getLineIntersection([_5f.x,_5f.y],[_60.x,_60.y],[_61.x,_61.y],[_62.x,_62.y]);if(pt){pt=new esri.geometry.Point(pt[0],pt[1]);}return pt;},_getLineIntersection:function(p0,p1,p2,p3){var _63=10000000000,x,y,a0=esri.geometry._equals(p0[0],p1[0])?_63:(p0[1]-p1[1])/(p0[0]-p1[0]),a1=esri.geometry._equals(p2[0],p3[0])?_63:(p2[1]-p3[1])/(p2[0]-p3[0]),b0=p0[1]-a0*p0[0],b1=p2[1]-a1*p2[0];if(esri.geometry._equals(a0,a1)){if(!esri.geometry._equals(b0,b1)){return null;}else{if(esri.geometry._equals(p0[0],p1[0])){if(Math.min(p0[1],p1[1])<Math.max(p2[1],p3[1])||Math.max(p0[1],p1[1])>Math.min(p2[1],p3[1])){y=(p0[1]+p1[1]+p2[1]+p3[1]-Math.min(p0[1],p1[1],p2[1],p3[1])-Math.max(p0[1],p1[1],p2[1],p3[1]))/2;x=(y-b0)/a0;}else{return null;}}else{if(Math.min(p0[0],p1[0])<Math.max(p2[0],p3[0])||Math.max(p0[0],p1[0])>Math.min(p2[0],p3[0])){x=(p0[0]+p1[0]+p2[0]+p3[0]-Math.min(p0[0],p1[0],p2[0],p3[0])-Math.max(p0[0],p1[0],p2[0],p3[0]))/2;y=a0*x+b0;}else{return null;}}return [x,y];}}if(esri.geometry._equals(a0,_63)){x=p0[0];y=a1*x+b1;}else{if(esri.geometry._equals(a1,_63)){x=p2[0];y=a0*x+b0;}else{x=-(b0-b1)/(a0-a1);y=a0*x+b0;}}return [x,y];},_getLineIntersection2:function(_64,_65){var p1=_64[0],p2=_64[1],p3=_65[0],p4=_65[1],x1=p1[0],y1=p1[1],x2=p2[0],y2=p2[1],x3=p3[0],y3=p3[1],x4=p4[0],y4=p4[1],x43=x4-x3,x13=x1-x3,x21=x2-x1,y43=y4-y3,y13=y1-y3,y21=y2-y1,_66=(y43*x21)-(x43*y21),ua,ub,px,py;if(_66===0){return false;}ua=((x43*y13)-(y43*x13))/_66;ub=((x21*y13)-(y21*x13))/_66;if(ua>=0&&ua<=1&&ub>=0&&ub<=1){px=x1+(ua*(x2-x1));py=y1+(ua*(y2-y1));return [px,py];}else{return false;}},_pointLineDistance:function(_67,_68){var p1=_68[0],p2=_68[1],x1=p1[0],y1=p1[1],x2=p2[0],y2=p2[1],x3=_67[0],y3=_67[1],x21=x2-x1,y21=y2-y1,x31=x3-x1,y31=y3-y1,_69=Math.sqrt,pow=Math.pow,mag=_69(pow(x21,2)+pow(y21,2)),u=((x31*x21)+(y31*y21))/(mag*mag),x=x1+u*x21,y=y1+u*y21;return _69(pow(x3-x,2)+pow(y3-y,2));}});dojo.declare("esri.geometry.Geometry",null,{spatialReference:null,type:null,setSpatialReference:function(sr){this.spatialReference=sr;return this;},getExtent:function(){return null;}});dojo.declare("esri.geometry.Point",esri.geometry.Geometry,{constructor:function(x,y,_6a){dojo.mixin(this,esri.geometry.defaultPoint);if(dojo.isArray(x)){this.x=x[0];this.y=x[1];this.spatialReference=y;}else{if(dojo.isObject(x)){dojo.mixin(this,x);if(this.spatialReference){this.spatialReference=new esri.SpatialReference(this.spatialReference);}}else{this.x=x;this.y=y;this.spatialReference=_6a;}}},offset:function(x,y){return new esri.geometry.Point(this.x+x,this.y+y,this.spatialReference);},setX:function(x){this.x=x;return this;},setY:function(y){this.y=y;return this;},update:function(x,y){this.x=x;this.y=y;return this;},normalize:function(){var x=this.x,sr=this.spatialReference;if(sr){var _6b=sr._getInfo();if(_6b){var _6c=_6b.valid[0],_6d=_6b.valid[1],_6e=2*_6d,_6f;if(x>_6d){_6f=Math.ceil(Math.abs(x-_6d)/_6e);x-=(_6f*_6e);}else{if(x<_6c){_6f=Math.ceil(Math.abs(x-_6c)/_6e);x+=(_6f*_6e);}}}}return new esri.geometry.Point(x,this.y,sr);},toJson:function(){var _70={x:this.x,y:this.y},sr=this.spatialReference;if(sr){_70.spatialReference=sr.toJson();}return _70;}});dojo.declare("esri.geometry.Polyline",esri.geometry.Geometry,{constructor:function(obj){dojo.mixin(this,esri.geometry.defaultPolyline);this.paths=[];this._path=0;if(obj){if(obj.paths){dojo.mixin(this,obj);}else{this.spatialReference=obj;}this.spatialReference=new esri.SpatialReference(this.spatialReference);}},_extent:null,addPath:function(_71){this._extent=null;this._path=this.paths.length;this.paths[this._path]=[];if(dojo.isArray(_71[0])){dojo.forEach(_71,this._addPointArr,this);}else{dojo.forEach(_71,this._addPoint,this);}return this;},_addPointArr:function(_72){this.paths[this._path].push(_72);},_addPoint:function(_73){this.paths[this._path].push([_73.x,_73.y]);},_insertPoints:function(_74,_75){this._extent=null;this._path=_75;if(!this.paths[this._path]){this.paths[this._path]=[];}dojo.forEach(_74,this._addPoint,this);},_validateInputs:function(_76,_77){if((_76!==null&&_76!==undefined)&&(_76<0||_76>=this.paths.length)){return false;}if((_77!==null&&_76!==undefined)&&(_77<0||_77>=this.paths[_76].length)){return false;}return true;},getPoint:function(_78,_79){if(this._validateInputs(_78,_79)){return new esri.geometry.Point(this.paths[_78][_79],this.spatialReference);}},setPoint:function(_7a,_7b,_7c){if(this._validateInputs(_7a,_7b)){this._extent=null;this.paths[_7a][_7b]=[_7c.x,_7c.y];return this;}},insertPoint:function(_7d,_7e,_7f){if(this._validateInputs(_7d)&&esri._isDefined(_7e)&&(_7e>=0&&_7e<=this.paths[_7d].length)){this._extent=null;this.paths[_7d].splice(_7e,0,[_7f.x,_7f.y]);return this;}},removePath:function(_80){if(this._validateInputs(_80,null)){this._extent=null;var arr=this.paths.splice(_80,1)[0],i,il=arr.length,_81=esri.geometry.Point,sr=this.spatialReference;for(i=0;i<il;i++){arr[i]=new _81(arr[i],sr);}return arr;}},removePoint:function(_82,_83){if(this._validateInputs(_82,_83)){this._extent=null;return new esri.geometry.Point(this.paths[_82].splice(_83,1)[0],this.spatialReference);}},getExtent:function(){var _84;if(this._extent){_84=new esri.geometry.Extent(this._extent);_84._partwise=this._partwise;return _84;}var _85=this.paths,pal=_85.length;if(!pal||!_85[0].length){return;}var _86,_87,x,y,_88,_89,pa,pt,ptl,_8a=(_88=_85[0][0][0]),_8b=(_89=_85[0][0][1]),min=Math.min,max=Math.max,sr=this.spatialReference,_8c=[],_8d,_8e,_8f,_90;for(pa=0;pa<pal;pa++){_86=_85[pa];_8d=(_8e=_86[0]&&_86[0][0]);_8f=(_90=_86[0]&&_86[0][1]);ptl=_86.length;for(pt=0;pt<ptl;pt++){_87=_86[pt];x=_87[0];y=_87[1];_8a=min(_8a,x);_8b=min(_8b,y);_88=max(_88,x);_89=max(_89,y);_8d=min(_8d,x);_8f=min(_8f,y);_8e=max(_8e,x);_90=max(_90,y);}_8c.push(new esri.geometry.Extent({xmin:_8d,ymin:_8f,xmax:_8e,ymax:_90,spatialReference:(sr?sr.toJson():null)}));}this._extent={xmin:_8a,ymin:_8b,xmax:_88,ymax:_89,spatialReference:sr?sr.toJson():null};this._partwise=_8c.length>1?_8c:null;_84=new esri.geometry.Extent(this._extent);_84._partwise=this._partwise;return _84;},toJson:function(){var _91={paths:dojo.clone(this.paths)},sr=this.spatialReference;if(sr){_91.spatialReference=sr.toJson();}return _91;}});dojo.declare("esri.geometry.Polygon",esri.geometry.Geometry,{constructor:function(obj){dojo.mixin(this,esri.geometry.defaultPolygon);this.rings=[];this._ring=0;if(obj){if(obj.rings){dojo.mixin(this,obj);}else{this.spatialReference=obj;}this.spatialReference=new esri.SpatialReference(this.spatialReference);}},_extent:null,addRing:function(_92){this._extent=null;this._ring=this.rings.length;this.rings[this._ring]=[];if(dojo.isArray(_92[0])){dojo.forEach(_92,this._addPointArr,this);}else{dojo.forEach(_92,this._addPoint,this);}return this;},_addPointArr:function(_93){this.rings[this._ring].push(_93);},_addPoint:function(_94){this.rings[this._ring].push([_94.x,_94.y]);},_insertPoints:function(_95,_96){this._extent=null;this._ring=_96;if(!this.rings[this._ring]){this.rings[this._ring]=[];}dojo.forEach(_95,this._addPoint,this);},_validateInputs:function(_97,_98){if((_97!==null&&_97!==undefined)&&(_97<0||_97>=this.rings.length)){return false;}if((_98!==null&&_97!==undefined)&&(_98<0||_98>=this.rings[_97].length)){return false;}return true;},getPoint:function(_99,_9a){if(this._validateInputs(_99,_9a)){return new esri.geometry.Point(this.rings[_99][_9a],this.spatialReference);}},setPoint:function(_9b,_9c,_9d){if(this._validateInputs(_9b,_9c)){this._extent=null;this.rings[_9b][_9c]=[_9d.x,_9d.y];return this;}},insertPoint:function(_9e,_9f,_a0){if(this._validateInputs(_9e)&&esri._isDefined(_9f)&&(_9f>=0&&_9f<=this.rings[_9e].length)){this._extent=null;this.rings[_9e].splice(_9f,0,[_a0.x,_a0.y]);return this;}},removeRing:function(_a1){if(this._validateInputs(_a1,null)){this._extent=null;var arr=this.rings.splice(_a1,1)[0],i,il=arr.length,_a2=esri.geometry.Point,sr=this.spatialReference;for(i=0;i<il;i++){arr[i]=new _a2(arr[i],sr);}return arr;}},removePoint:function(_a3,_a4){if(this._validateInputs(_a3,_a4)){this._extent=null;return new esri.geometry.Point(this.rings[_a3].splice(_a4,1)[0],this.spatialReference);}},getExtent:function(){var _a5;if(this._extent){_a5=new esri.geometry.Extent(this._extent);_a5._partwise=this._partwise;return _a5;}var _a6=this.rings,pal=_a6.length;if(!pal||!_a6[0].length){return;}var _a7,_a8,x,y,_a9,_aa,pa,pt,ptl,_ab=(_a9=_a6[0][0][0]),_ac=(_aa=_a6[0][0][1]),min=Math.min,max=Math.max,sr=this.spatialReference,_ad=[],_ae,_af,_b0,_b1;for(pa=0;pa<pal;pa++){_a7=_a6[pa];_ae=(_af=_a7[0]&&_a7[0][0]);_b0=(_b1=_a7[0]&&_a7[0][1]);ptl=_a7.length;for(pt=0;pt<ptl;pt++){_a8=_a7[pt];x=_a8[0];y=_a8[1];_ab=min(_ab,x);_ac=min(_ac,y);_a9=max(_a9,x);_aa=max(_aa,y);_ae=min(_ae,x);_b0=min(_b0,y);_af=max(_af,x);_b1=max(_b1,y);}_ad.push(new esri.geometry.Extent({xmin:_ae,ymin:_b0,xmax:_af,ymax:_b1,spatialReference:(sr?sr.toJson():null)}));}this._extent={xmin:_ab,ymin:_ac,xmax:_a9,ymax:_aa,spatialReference:(sr?sr.toJson():null)};this._partwise=_ad.length>1?_ad:null;_a5=new esri.geometry.Extent(this._extent);_a5._partwise=this._partwise;return _a5;},contains:function(_b2){var _b3=this.rings,_b4,_b5=false,pi,pj,_b6,j,i,pa,pal=_b3.length;for(pa=0;pa<pal;pa++){_b4=_b3[pa];_b6=_b4.length;j=0;for(i=0;i<_b6;i++){j++;if(j===_b6){j=0;}pi=_b4[i];pj=_b4[j];if((pi[1]<_b2.y&&pj[1]>=_b2.y||pj[1]<_b2.y&&pi[1]>=_b2.y)&&(pi[0]+(_b2.y-pi[1])/(pj[1]-pi[1])*(pj[0]-pi[0])<_b2.x)){_b5=!_b5;}}}return _b5;},toJson:function(){var _b7={rings:dojo.clone(this.rings)},sr=this.spatialReference;if(sr){_b7.spatialReference=sr.toJson();}return _b7;}});dojo.declare("esri.geometry.Multipoint",esri.geometry.Geometry,{constructor:function(obj){dojo.mixin(this,esri.geometry.defaultMultipoint);this.points=[];if(obj){if(obj.points){dojo.mixin(this,obj);}else{this.spatialReference=obj;}this.spatialReference=new esri.SpatialReference(this.spatialReference);}},_extent:null,addPoint:function(_b8){this._extent=null;if(dojo.isArray(_b8)){this.points.push(_b8);}else{this.points.push([_b8.x,_b8.y]);}return this;},removePoint:function(_b9){if(this._validateInputs(_b9)){this._extent=null;return new esri.geometry.Point(this.points.splice(_b9,1)[0],this.spatialReference);}},getExtent:function(){if(this._extent){return new esri.geometry.Extent(this._extent);}var _ba=this.points,il=_ba.length;if(!il){return;}var _bb=_ba[0],_bc,_bd,_be=(_bc=_bb[0]),_bf=(_bd=_bb[1]),min=Math.min,max=Math.max,sr=this.spatialReference,x,y,i;for(i=0;i<il;i++){_bb=_ba[i];x=_bb[0];y=_bb[1];_be=min(_be,x);_bf=min(_bf,y);_bc=max(_bc,x);_bd=max(_bd,y);}this._extent={xmin:_be,ymin:_bf,xmax:_bc,ymax:_bd,spatialReference:sr?sr.toJson():null};return new esri.geometry.Extent(this._extent);},_validateInputs:function(_c0){if(_c0===null||_c0<0||_c0>=this.points.length){return false;}return true;},getPoint:function(_c1){if(this._validateInputs(_c1)){var _c2=this.points[_c1];return new esri.geometry.Point(_c2[0],_c2[1],this.spatialReference);}},setPoint:function(_c3,_c4){if(this._validateInputs(_c3)){this._extent=null;this.points[_c3]=[_c4.x,_c4.y];return this;}},toJson:function(){var _c5={points:dojo.clone(this.points)},sr=this.spatialReference;if(sr){_c5.spatialReference=sr.toJson();}return _c5;}});dojo.declare("esri.geometry.Extent",esri.geometry.Geometry,{constructor:function(_c6,_c7,_c8,_c9,_ca){dojo.mixin(this,esri.geometry.defaultExtent);if(dojo.isObject(_c6)){dojo.mixin(this,_c6);this.spatialReference=new esri.SpatialReference(this.spatialReference);}else{this.update(_c6,_c7,_c8,_c9,_ca);}},getWidth:function(){return Math.abs(this.xmax-this.xmin);},getHeight:function(){return Math.abs(this.ymax-this.ymin);},getCenter:function(){return new esri.geometry.Point((this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2,this.spatialReference);},centerAt:function(_cb){var _cc=this.getCenter(),dx=_cb.x-_cc.x,dy=_cb.y-_cc.y;return new esri.geometry.Extent(this.xmin+dx,this.ymin+dy,this.xmax+dx,this.ymax+dy,this.spatialReference);},update:function(_cd,_ce,_cf,_d0,_d1){this.xmin=_cd;this.ymin=_ce;this.xmax=_cf;this.ymax=_d0;this.spatialReference=_d1;return this;},offset:function(ox,oy){return new esri.geometry.Extent(this.xmin+ox,this.ymin+oy,this.xmax+ox,this.ymax+oy,this.spatialReference);},expand:function(_d2){var _d3=(1-_d2)/2,_d4=this.getWidth()*_d3,_d5=this.getHeight()*_d3;return new esri.geometry.Extent(this.xmin+_d4,this.ymin+_d5,this.xmax-_d4,this.ymax-_d5,this.spatialReference);},intersects:function(_d6){var _d7=_d6.type;switch(_d7){case "point":return this.contains(_d6);case "multipoint":return this._intersectsMultipoint(_d6);case "extent":return this._intersectsExtent(_d6);case "polygon":return this._intersectsPolygon(_d6);case "polyline":return this._intersectsPolyline(_d6);}},_intersectsMultipoint:function(_d8){var len=_d8.points.length,i;for(i=0;i<len;i++){if(this.contains(_d8.getPoint(i))){return true;}}return false;},_intersectsExtent:function(_d9){var _da,_db,_dc,_dd,_de=false;if(this.xmin<=_d9.xmin){_da=_d9.xmin;if(this.xmax<_da){_de=true;}else{_dc=Math.min(this.xmax,_d9.xmax)-_da;}}else{_da=this.xmin;if(_d9.xmax<_da){_de=true;}else{_dc=Math.min(this.xmax,_d9.xmax)-_da;}}if(this.ymin<=_d9.ymin){_db=_d9.ymin;if(this.ymax<_db){_de=true;}else{_dd=Math.min(this.ymax,_d9.ymax)-_db;}}else{_db=this.ymin;if(_d9.ymax<_db){_de=true;}else{_dd=Math.min(this.ymax,_d9.ymax)-_db;}}if(_de){return null;}return new esri.geometry.Extent(_da,_db,_da+_dc,_db+_dd,this.spatialReference);},_intersectsPolygon:function(_df){var _e0=[this.xmin,this.ymax],_e1=[this.xmax,this.ymax],_e2=[this.xmin,this.ymin],_e3=[this.xmax,this.ymin],_e4=[_e0,_e1,_e2,_e3],_e5=[[_e2,_e0],[_e0,_e1],[_e1,_e3],[_e3,_e2]],i,j,_e6=_df.rings,_e7=_e6.length,_e8,len,_e9=new esri.geometry.Point(0,0);len=_e4.length;for(i=0;i<len;i++){_e9.update(_e4[i][0],_e4[i][1]);if(_df.contains(_e9)){return true;}}var pi,pj;for(i=0;i<_e7;i++){_e8=_e6[i];len=_e8.length;pi=_e8[0];_e9.update(pi[0],pi[1]);if(this.contains(_e9)){return true;}for(j=1;j<len;j++){pj=_e8[j];_e9.update(pj[0],pj[1]);if(this.contains(_e9)||this._intersectsLine([pi,pj],_e5)){return true;}pi=pj;}}return false;},_intersectsPolyline:function(_ea){var _eb=[[[this.xmin,this.ymin],[this.xmin,this.ymax]],[[this.xmin,this.ymax],[this.xmax,this.ymax]],[[this.xmax,this.ymax],[this.xmax,this.ymin]],[[this.xmax,this.ymin],[this.xmin,this.ymin]]];var i,j,_ec=_ea.paths,_ed=_ec.length,_ee,len;var pi,pj,_ef=new esri.geometry.Point(0,0);for(i=0;i<_ed;i++){_ee=_ec[i];len=_ee.length;pi=_ee[0];_ef.update(pi[0],pi[1]);if(this.contains(_ef)){return true;}for(j=1;j<len;j++){pj=_ee[j];_ef.update(pj[0],pj[1]);if(this.contains(_ef)||this._intersectsLine([pi,pj],_eb)){return true;}pi=pj;}}return false;},_intersectsLine:function(_f0,_f1){var _f2=esri.geometry._getLineIntersection2,i,len=_f1.length;for(i=0;i<len;i++){if(_f2(_f0,_f1[i])){return true;}}return false;},contains:function(_f3){if(!_f3){return false;}var _f4=_f3.type;switch(_f4){case "point":return _f3.x>=this.xmin&&_f3.x<=this.xmax&&_f3.y>=this.ymin&&_f3.y<=this.ymax;case "extent":return this._containsExtent(_f3);}return false;},_containsExtent:function(_f5){var _f6=_f5.xmin,_f7=_f5.ymin,_f8=_f5.xmax,_f9=_f5.ymax,pt1=new esri.geometry.Point(_f6,_f7),pt2=new esri.geometry.Point(_f6,_f9),pt3=new esri.geometry.Point(_f8,_f9),pt4=new esri.geometry.Point(_f8,_f7);if(this.contains(pt1)&&this.contains(pt2)&&this.contains(pt3)&&this.contains(pt4)){return true;}return false;},union:function(_fa){return new esri.geometry.Extent(Math.min(this.xmin,_fa.xmin),Math.min(this.ymin,_fa.ymin),Math.max(this.xmax,_fa.xmax),Math.max(this.ymax,_fa.ymax),this.spatialReference);},getExtent:function(){var sr=this.spatialReference;return new esri.geometry.Extent(this.xmin,this.ymin,this.xmax,this.ymax,sr&&new esri.SpatialReference(sr.toJson()));},_shiftCM:function(_fb){if(!this._shifted){var EG=esri.geometry,_fc=EG.fromJson(this.toJson()),sr=_fc.spatialReference;_fb=_fb||sr._getInfo();if(_fb){var _fd=this._getCM(_fb);if(_fd){var _fe=sr._isWebMercator()?EG.webMercatorToGeographic(_fd):_fd;_fc.xmin-=_fd.x;_fc.xmax-=_fd.x;if(!sr._isWebMercator()){_fe.x=this._normalizeX(_fe.x,_fb).x;}_fc.spatialReference.wkt=esri.substitute({Central_Meridian:_fe.x},sr.wkid===4326?_fb.altTemplate:_fb.wkTemplate);_fc.spatialReference.wkid=null;}}this._shifted=_fc;}return this._shifted;},_getCM:function(_ff){var _100,_101=_ff.valid[0],_102=_ff.valid[1],xmin=this.xmin,xmax=this.xmax;var _103=(xmin>=_101&&xmin<=_102),_104=(xmax>=_101&&xmax<=_102);if(!(_103&&_104)){_100=this.getCenter();}return _100;},_normalize:function(_105,_106,info){var EG=esri.geometry,_107=EG.fromJson(this.toJson()),sr=_107.spatialReference;if(sr){info=info||sr._getInfo();if(info){var _108=dojo.map(this._getParts(info),function(part){return part.extent;});if(_108.length>2){if(_105){return this._shiftCM(info);}else{return _107.update(info.valid[0],_107.ymin,info.valid[1],_107.ymax,sr);}}else{if(_108.length===2){if(_105){return this._shiftCM(info);}else{return _106?_108:new EG.Polygon({"rings":dojo.map(_108,function(_109){return [[_109.xmin,_109.ymin],[_109.xmin,_109.ymax],[_109.xmax,_109.ymax],[_109.xmax,_109.ymin],[_109.xmin,_109.ymin]];}),"spatialReference":sr});}}else{return _108[0]||_107;}}}}return _107;},_getParts:function(info){if(!this._parts){var xmin=this.xmin,xmax=this.xmax,ymin=this.ymin,ymax=this.ymax,sr=this.spatialReference,_10a=this.getWidth(),_10b=xmin,_10c=xmax,_10d=0,_10e=0,nrml,_10f=[],_110,_111,_112;info=info||sr._getInfo();_110=info.valid[0];_111=info.valid[1];nrml=this._normalizeX(xmin,info);xmin=nrml.x;_10d=nrml.frameId;nrml=this._normalizeX(xmax,info);xmax=nrml.x;_10e=nrml.frameId;_112=(xmin===xmax&&_10a>0);if(_10a>(2*_111)){var E1=new esri.geometry.Extent(_10b<_10c?xmin:xmax,ymin,_111,ymax,sr),E2=new esri.geometry.Extent(_110,ymin,_10b<_10c?xmax:xmin,ymax,sr),E3=new esri.geometry.Extent(0,ymin,_111,ymax,sr),E4=new esri.geometry.Extent(_110,ymin,0,ymax,sr),k,_113=[],_114=[];if(E1.contains(E3)){_113.push(_10d);}if(E1.contains(E4)){_114.push(_10d);}if(E2.contains(E3)){_113.push(_10e);}if(E2.contains(E4)){_114.push(_10e);}for(k=_10d+1;k<_10e;k++){_113.push(k);_114.push(k);}_10f.push({extent:E1,frameIds:[_10d]},{extent:E2,frameIds:[_10e]},{extent:E3,frameIds:_113},{extent:E4,frameIds:_114});}else{if((xmin>xmax)||_112){_10f.push({extent:new esri.geometry.Extent(xmin,ymin,_111,ymax,sr),frameIds:[_10d]},{extent:new esri.geometry.Extent(_110,ymin,xmax,ymax,sr),frameIds:[_10e]});}else{_10f.push({extent:new esri.geometry.Extent(xmin,ymin,xmax,ymax,sr),frameIds:[_10d]});}}this._parts=_10f;}return this._parts;},_normalizeX:function(x,info){var _115=0,_116=info.valid[0],_117=info.valid[1],_118=2*_117,_119;if(x>_117){_119=Math.ceil(Math.abs(x-_117)/_118);x-=(_119*_118);_115=_119;}else{if(x<_116){_119=Math.ceil(Math.abs(x-_116)/_118);x+=(_119*_118);_115=-_119;}}return {x:x,frameId:_115};},toJson:function(){var json={xmin:this.xmin,ymin:this.ymin,xmax:this.xmax,ymax:this.ymax},sr=this.spatialReference;if(sr){json.spatialReference=sr.toJson();}return json;}});dojo.declare("esri.geometry.Rect",esri.geometry.Geometry,{constructor:function(json,y,_11a,_11b,_11c){dojo.mixin(this,dojox.gfx.defaultRect);if(dojo.isObject(json)){dojo.mixin(this,json);this.spatialReference=new esri.SpatialReference(this.spatialReference);}else{this.x=json;this.y=y;this.width=_11a;this.height=_11b;this.spatialReference=_11c;}},getCenter:function(){return new esri.geometry.Point(this.x+this.width/2,this.y+this.height/2,this.spatialReference);},offset:function(ox,oy){return new esri.geometry.Rect(this.x+ox,this.y+oy,this.width,this.height,this.spatialReference);},intersects:function(rect){if((rect.x+rect.width)<=this.x){return false;}if((rect.y+rect.height)<=this.y){return false;}if(rect.y>=(this.y+this.height)){return false;}if(rect.x>=(this.x+this.width)){return false;}return true;},getExtent:function(){return esri.geometry._rectToExtent(this);},update:function(x,y,_11d,_11e,_11f){this.x=x;this.y=y;this.width=_11d;this.height=_11e;this.spatialReference=_11f;return this;}});}