/*
 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
 */

window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","esri.tasks.route"],["require","esri.tasks.na"],["require","esri.tasks.gp"],["require","esri.utils"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.tasks.route"]){_4._hasResource["esri.tasks.route"]=true;_4.provide("esri.tasks.route");_4.require("esri.tasks.na");_4.require("esri.tasks.gp");_4.require("esri.utils");_4.declare("esri.tasks.RouteTask",esri.tasks._Task,{constructor:function(_7){this._url.path+="/solve";this._handler=_4.hitch(this,this._handler);},__msigns:[{n:"solve",c:3,a:[{i:0,p:["stops.features","barriers.features","polylineBarriers.features","polygonBarriers.features"]}],e:2}],_handler:function(_8,io,_9,_a,_b){try{var _c=[],_d=[],_e=_8.directions||[],_f=_8.routes?_8.routes.features:[],_10=_8.stops?_8.stops.features:[],_11=_8.barriers?_8.barriers.features:[],_12=_8.polygonBarriers?_8.polygonBarriers.features:[],_13=_8.polylineBarriers?_8.polylineBarriers.features:[],_14=_8.messages,_15="esri.tasks.RouteTask.NULL_ROUTE_NAME",_16=_4.forEach,_17=_4.indexOf,_18=true,_19,_1a;_16(_e,function(dir){_c.push(_19=dir.routeName);_d[_19]={directions:dir};});_16(_f,function(_1b){if(_17(_c,(_19=_1b.attributes.Name))===-1){_c.push(_19);_d[_19]={};}_d[_19].route=_1b;});_16(_10,function(_1c){_1a=_1c.attributes;if(_17(_c,(_19=_1a.RouteName||_15))===-1){_c.push(_19);_d[_19]={};}if(_19!==_15){_18=false;}if(_d[_19].stops===undefined){_d[_19].stops=[];}_d[_19].stops.push(_1c);});if(_10.length>0&&_18===true){_d[_c[0]].stops=_d[_15].stops;delete _d[_15];_c.splice(_4.indexOf(_c,_15),1);}var _1d=[];_16(_c,function(_1e,i){_d[_1e].routeName=_1e===_15?null:_1e;_1d.push(new esri.tasks.RouteResult(_d[_1e]));});var _1f=function(_20){_16(_20,function(_21,i){_20[i]=new esri.Graphic(_21);});return _20;};_16(_14,function(_22,i){_14[i]=new esri.tasks.NAMessage(_22);});var _23={routeResults:_1d,barriers:_1f(_11),polygonBarriers:_1f(_12),polylineBarriers:_1f(_13),messages:_14};this._successHandler([_23],"onSolveComplete",_9,_b);}catch(err){this._errorHandler(err,_a,_b);}},solve:function(_24,_25,_26,_27){var _28=_24.stops;if(_28&&_28 instanceof esri.tasks.FeatureSet){var _29=[],_2a=false,_2b;_4.forEach(_28.features,function(_2c){_2b=_2c.attributes;if((!_2b||!_2b.RouteName)&&!_2a){_2a=true;}else{if(_4.indexOf(_29,_2b?_2b.RouteName:"")===-1){_29.push(_2b?_2b.RouteName:"");}}});if(_29.length>1&&_2a){_2a=new Error(esri.bundle.tasks.na.route.routeNameNotSpecified);this.onError(_2a);if(_26){_26(_2a);}throw _2a;}}var _2d=_27.assembly,_2e=this._encode(_4.mixin({},this._url.query,{f:"json"},_24.toJson(_2d&&_2d[0]))),_2f=this._handler,_30=this._errorHandler;return esri.request({url:this._url.path,content:_2e,callbackParamName:"callback",load:function(r,i){_2f(r,i,_25,_26,_27.dfd);},error:function(r){_30(r,_26,_27.dfd);}});},onSolveComplete:function(){}});esri._createWrappers("esri.tasks.RouteTask");_4.declare("esri.tasks.RouteParameters",null,{accumulateAttributes:null,attributeParameterValues:null,barriers:null,directionsLanguage:null,directionsLengthUnits:null,directionsTimeAttribute:null,doNotLocateOnRestrictedElements:false,findBestSequence:null,ignoreInvalidLocations:null,impedanceAttribute:null,outputLines:null,outputGeometryPrecision:null,outputGeometryPrecisionUnits:null,outSpatialReference:null,polygonBarriers:null,polylineBarriers:null,preserveFirstStop:null,preserveLastStop:null,restrictionAttributes:null,restrictUTurns:null,returnBarriers:false,returnDirections:false,returnPolygonBarriers:false,returnPolylineBarriers:false,returnRoutes:true,returnStops:false,startTime:null,stops:null,useHierarchy:null,useTimeWindows:null,toJson:function(_31){var _32={returnDirections:this.returnDirections,returnRoutes:this.returnRoutes,returnStops:this.returnStops,returnBarriers:this.returnBarriers,returnPolygonBarriers:this.returnPolygonBarriers,returnPolylineBarriers:this.returnPolylineBarriers,attributeParameterValues:this.attributeParameterValues&&_4.toJson(this.attributeParameterValues),outSR:this.outSpatialReference?(this.outSpatialReference.wkid||_4.toJson(this.outSpatialReference.toJson())):null,outputLines:this.outputLines,findBestSequence:this.findBestSequence,preserveFirstStop:this.preserveFirstStop,preserveLastStop:this.preserveLastStop,useTimeWindows:this.useTimeWindows,startTime:this.startTime?this.startTime.getTime():null,accumulateAttributeNames:this.accumulateAttributes?this.accumulateAttributes.join(","):null,ignoreInvalidLocations:this.ignoreInvalidLocations,impedanceAttributeName:this.impedanceAttribute,restrictionAttributeNames:this.restrictionAttributes?this.restrictionAttributes.join(","):null,restrictUTurns:this.restrictUTurns,useHierarchy:this.useHierarchy,directionsLanguage:this.directionsLanguage,outputGeometryPrecision:this.outputGeometryPrecision,outputGeometryPrecisionUnits:this.outputGeometryPrecisionUnits,directionsLengthUnits:esri.tasks._NALengthUnit[this.directionsLengthUnits],directionsTimeAttributeName:this.directionsTimeAttribute},_33=this.stops;if(_33 instanceof esri.tasks.FeatureSet&&_33.features.length>0){_32.stops=_4.toJson({type:"features",features:esri._encodeGraphics(_33.features,_31&&_31["stops.features"]),doNotLocateOnRestrictedElements:this.doNotLocateOnRestrictedElements});}else{if(_33 instanceof esri.tasks.DataLayer){_32.stops=_33;}}var _34=function(_35,_36){if(!_35){return null;}if(_35 instanceof esri.tasks.FeatureSet){if(_35.features.length>0){return _4.toJson({type:"features",features:esri._encodeGraphics(_35.features,_31&&_31[_36])});}else{return null;}}else{if(_35 instanceof esri.tasks.DataLayer){return _35;}}return _4.toJson(_35);};_32.barriers=_34(this.barriers,"barriers.features");_32.polygonBarriers=_34(this.polygonBarriers,"polygonBarriers.features");_32.polylineBarriers=_34(this.polylineBarriers,"polylineBarriers.features");return esri.filter(_32,function(_37){if(_37!==null){return true;}});}});_4.declare("esri.tasks.RouteResult",null,{constructor:function(_38){if(_38.directions){var cgs=[];_4.forEach(_38.directions.features,function(f,i){cgs[i]=f.compressedGeometry;});this.directions=new esri.tasks.DirectionsFeatureSet(_38.directions,cgs);}this.routeName=_38.routeName;if(_38.route){this.route=new esri.Graphic(_38.route);}if(_38.stops){var ss=(this.stops=[]);_4.forEach(_38.stops,function(_39,i){ss[_39.attributes.Sequence-1]=new esri.Graphic(_39);});}},routeName:null,directions:null,route:null,stops:null});}}};});