/*
 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.closestfacility"],["require","esri.tasks._task"],["require","esri.tasks.na"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.tasks.closestfacility"]){_4._hasResource["esri.tasks.closestfacility"]=true;_4.provide("esri.tasks.closestfacility");_4.require("esri.tasks._task");_4.require("esri.tasks.na");_4.declare("esri.tasks.ClosestFacilityTask",esri.tasks._Task,{constructor:function(_7){this._url.path+="/solveClosestFacility";this._handler=_4.hitch(this,this._handler);},__msigns:[{n:"solve",c:3,a:[{i:0,p:["incidents.features","facilities.features","pointBarriers.features","polylineBarriers.features","polygonBarriers.features"]}],e:2}],_handler:function(_8,io,_9,_a,_b){try{var _c=new esri.tasks.ClosestFacilitySolveResult(_8);this._successHandler([_c],"onSolveComplete",_9,_b);}catch(err){this._errorHandler(err,_a,_b);}},solve:function(_d,_e,_f,_10){var _11=_10.assembly,_12=this._encode(_4.mixin({},this._url.query,{f:"json"},_d.toJson(_11&&_11[0]))),_13=this._handler,_14=this._errorHandler;return esri.request({url:this._url.path,content:_12,callbackParamName:"callback",load:function(r,i){_13(r,i,_e,_f,_10.dfd);},error:function(r){_14(r,_f,_10.dfd);}});},onSolveComplete:function(){}});esri._createWrappers("esri.tasks.ClosestFacilityTask");_4.declare("esri.tasks.ClosestFacilityParameters",null,{accumulateAttributes:null,attributeParameterValues:null,defaultCutoff:null,defaultTargetFacilityCount:null,directionsLanguage:null,directionsLengthUnits:null,directionsTimeAttribute:false,facilities:null,impedanceAttribute:null,incidents:null,outputGeometryPrecision:null,outputGeometryPrecisionUnits:null,outputLines:null,outSpatialReference:null,pointBarriers:null,polygonBarriers:null,polylineBarriers:null,restrictionAttributes:null,restrictUTurns:null,returnDirections:false,returnFacilities:false,returnIncidents:false,returnPointBarriers:false,returnPolylgonBarriers:false,returnPolylineBarriers:false,returnRoutes:true,travelDirection:null,useHierarchy:false,timeOfDay:null,timeOfDayUsage:null,toJson:function(_15){var _16={returnDirections:this.returnDirections,returnFacilities:this.returnFacilities,returnIncidents:this.returnIncidents,returnBarriers:this.returnPointBarriers,returnPolygonBarriers:this.returnPolygonBarriers,returnPolylineBarriers:this.returnPolylineBarriers,returnCFRoutes:this.returnRoutes,useHierarchy:this.useHierarchy,attributeParameterValues:this.attributeParameterValues&&_4.toJson(this.attributeParameterValues),defaultCutoff:this.defaultCutoff,defaultTargetFacilityCount:this.defaultTargetFacilityCount,directionsLanguage:this.directionsLanguage,directionsLengthUnits:esri.tasks._NALengthUnit[this.directionsLengthUnits],directionsTimeAttributeName:this.directionsTimeAttribute,impedanceAttributeName:this.impedanceAttribute,outputGeometryPrecision:this.outputGeometryPrecision,outputGeometryPrecisionUnits:this.outputGeometryPrecisionUnits,outputLines:this.outputLines,outSR:this.outSpatialReference?(this.outSpatialReference.wkid||_4.toJson(this.outSpatialReference.toJson())):null,restrictionAttributeNames:this.restrictionAttributes?this.restrictionAttributes.join(","):null,restrictUTurns:this.restrictUTurns,accumulateAttributeNames:this.accumulateAttributes?this.accumulateAttributes.join(","):null,travelDirection:this.travelDirection,timeOfDay:this.timeOfDay&&this.timeOfDay.getTime()};if(this.timeOfDayUsage){var _17;switch(this.timeOfDayUsage.toLowerCase()){case "start":_17="esriNATimeOfDayUseAsStartTime";break;case "end":_17="esriNATimeOfDayUseAsEndTime";break;default:_17=this.timeOfDayUsage;}_16.timeOfDayUsage=_17;}var _18=this.incidents;if(_18 instanceof esri.tasks.FeatureSet&&_18.features.length>0){_16.incidents=_4.toJson({type:"features",features:esri._encodeGraphics(_18.features,_15&&_15["incidents.features"])});}else{if(_18 instanceof esri.tasks.DataLayer){_16.incidents=_18;}}var _19=this.facilities;if(_19 instanceof esri.tasks.FeatureSet&&_19.features.length>0){_16.facilities=_4.toJson({type:"features",features:esri._encodeGraphics(_19.features,_15&&_15["facilities.features"])});}else{if(_19 instanceof esri.tasks.DataLayer){_16.facilities=_19;}}var _1a=function(_1b,_1c){if(!_1b){return null;}if(_1b instanceof esri.tasks.FeatureSet){if(_1b.features.length>0){return _4.toJson({type:"features",features:esri._encodeGraphics(_1b.features,_15&&_15[_1c])});}else{return null;}}else{if(_1b instanceof esri.tasks.DataLayer){return _1b;}}return _4.toJson(_1b);};_16.barriers=_1a(this.pointBarriers,"pointBarriers.features");_16.polygonBarriers=_1a(this.polygonBarriers,"polygonBarriers.features");_16.polylineBarriers=_1a(this.polylineBarriers,"polylineBarriers.features");return esri.filter(_16,function(_1d){if(_1d!==null){return true;}});}});_4.declare("esri.tasks.ClosestFacilitySolveResult",null,{constructor:function(_1e){if(_1e.directions){this.directions=[];_4.forEach(_1e.directions,function(_1f,idx){var cgs=[];_4.forEach(_1f.features,function(f,i){cgs[i]=f.compressedGeometry;});this.directions[idx]=new esri.tasks.DirectionsFeatureSet(_1f,cgs);},this);}if(_1e.routes){this.routes=this._graphicsFromJson(_1e.routes);}if(_1e.facilities){this.facilities=this._graphicsFromJson(_1e.facilities);}if(_1e.incidents){this.incidents=this._graphicsFromJson(_1e.incidents);}if(_1e.barriers){this.pointBarriers=this._graphicsFromJson(_1e.barriers);}if(_1e.polylineBarriers){this.polylineBarriers=this._graphicsFromJson(_1e.polylineBarriers);}if(_1e.polygonBarriers){this.polygonBarriers=this._graphicsFromJson(_1e.polygonBarriers);}if(_1e.messages){this.messages=_4.map(_1e.messages,function(_20,i){return new esri.tasks.NAMessage(_20);});}},routes:null,facilities:null,incidents:null,pointBarriers:null,polylineBarriers:null,polygonBarriers:null,directions:null,messages:null,_graphicsFromJson:function(_21){var sr=new esri.SpatialReference(_21.spatialReference);var _22=_21.features;return _4.map(_22,function(_23,i){var _24=new esri.Graphic(_23);_24.geometry.setSpatialReference(sr);return _24;});}});}}};});