/*
 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.tasks.servicearea"]){dojo._hasResource["esri.tasks.servicearea"]=true;dojo.provide("esri.tasks.servicearea");dojo.require("esri.tasks._task");dojo.require("esri.tasks.na");dojo.declare("esri.tasks.ServiceAreaTask",esri.tasks._Task,{constructor:function(_1){this._url.path+="/solveServiceArea";this._handler=dojo.hitch(this,this._handler);},__msigns:[{n:"solve",c:3,a:[{i:0,p:["facilities.features","pointBarriers.features","polylineBarriers.features","polygonBarriers.features"]}],e:2}],_handler:function(_2,io,_3,_4,_5){try{var _6=new esri.tasks.ServiceAreaSolveResult(_2);this._successHandler([_6],"onSolveComplete",_3,_5);}catch(err){this._errorHandler(err,_4,_5);}},solve:function(_7,_8,_9,_a){var _b=_a.assembly,_c=this._encode(dojo.mixin({},this._url.query,{f:"json"},_7.toJson(_b&&_b[0]))),_d=this._handler,_e=this._errorHandler;return esri.request({url:this._url.path,content:_c,callbackParamName:"callback",load:function(r,i){_d(r,i,_8,_9,_a.dfd);},error:function(r){_e(r,_9,_a.dfd);}});},onSolveComplete:function(){}});esri._createWrappers("esri.tasks.ServiceAreaTask");dojo.declare("esri.tasks.ServiceAreaParameters",null,{accumulateAttributes:null,attributeParameterValues:null,defaultBreaks:null,excludeSourcesFromPolygons:null,facilities:null,impedanceAttribute:null,mergeSimilarPolygonRanges:false,outputGeometryPrecision:null,outputGeometryPrecisionUnits:null,outputLines:null,outputPolygons:null,outSpatialReference:null,overlapLines:false,overlapPolygons:false,pointBarriers:null,polygonBarriers:null,polylineBarriers:null,restrictionAttributes:null,restrictUTurns:null,returnFacilities:false,returnPointBarriers:false,returnPolylgonBarriers:false,returnPolylineBarriers:false,splitLinesAtBreaks:false,splitPolygonsAtBreaks:false,travelDirection:null,trimOuterPolygon:false,trimPolygonDistance:null,trimPolygonDistanceUnits:null,useHierarchy:null,timeOfDay:null,toJson:function(_f){var _10={returnFacilities:this.returnFacilities,returnBarriers:this.returnPointBarriers,returnPolygonBarriers:this.returnPolygonBarriers,returnPolylineBarriers:this.returnPolylineBarriers,mergeSimilarPolygonRanges:this.mergeSimilarPolygonRanges,overlapLines:this.overlapLines,overlapPolygons:this.overlapPolygons,splitLinesAtBreaks:this.splitLinesAtBreaks,splitPolygonsAtBreaks:this.splitPolygonsAtBreaks,trimOuterPolygon:this.trimOuterPolygon,accumulateAttributeNames:this.accumulateAttributes?this.accumulateAttributes.join(","):null,attributeParameterValues:this.attributeParameterValues&&dojo.toJson(this.attributeParameterValues),defaultBreaks:this.defaultBreaks?this.defaultBreaks.join(","):null,excludeSourcesFromPolygons:this.excludeSourcesFromPolygons?this.excludeSourcesFromPolygons.join(","):null,impedanceAttributeName:this.impedanceAttribute,outputGeometryPrecision:this.outputGeometryPrecision,outputGeometryPrecisionUnits:this.outputGeometryPrecisionUnits,outputLines:this.outputLines,outputPolygons:this.outputPolygons,outSR:this.outSpatialReference?(this.outSpatialReference.wkid||dojo.toJson(this.outSpatialReference.toJson())):null,restrictionAttributeNames:this.restrictionAttributes?this.restrictionAttributes.join(","):null,restrictUTurns:this.restrictUTurns,travelDirection:this.travelDirection,trimPolygonDistance:this.trimPolygonDistance,trimPolygonDistanceUnits:this.trimPolygonDistanceUnits,useHierarchy:this.useHierarchy,timeOfDay:this.timeOfDay&&this.timeOfDay.getTime()};var _11=this.facilities;if(_11 instanceof esri.tasks.FeatureSet&&_11.features.length>0){_10.facilities=dojo.toJson({type:"features",features:esri._encodeGraphics(_11.features,_f&&_f["facilities.features"])});}else{if(_11 instanceof esri.tasks.DataLayer){_10.facilities=_11;}}var _12=function(_13,_14){if(!_13){return null;}if(_13 instanceof esri.tasks.FeatureSet){if(_13.features.length>0){return dojo.toJson({type:"features",features:esri._encodeGraphics(_13.features,_f&&_f[_14])});}else{return null;}}else{if(_13 instanceof esri.tasks.DataLayer){return _13;}}return dojo.toJson(_13);};_10.barriers=_12(this.pointBarriers,"pointBarriers.features");_10.polygonBarriers=_12(this.polygonBarriers,"polygonBarriers.features");_10.polylineBarriers=_12(this.polylineBarriers,"polylineBarriers.features");return esri.filter(_10,function(_15){if(_15!==null){return true;}});}});dojo.declare("esri.tasks.ServiceAreaSolveResult",null,{constructor:function(_16){if(_16.saPolygons){this.serviceAreaPolygons=this._graphicsFromJson(_16.saPolygons);}if(_16.saPolylines){this.serviceAreaPolylines=this._graphicsFromJson(_16.saPolylines);}if(_16.facilities){this.facilities=this._graphicsFromJson(_16.facilities);}if(_16.barriers){this.pointBarriers=this._graphicsFromJson(_16.barriers);}if(_16.polylineBarriers){this.polylineBarriers=this._graphicsFromJson(_16.polylineBarriers);}if(_16.polygonBarriers){this.polygonBarriers=this._graphicsFromJson(_16.polygonBarriers);}if(_16.messages){this.messages=dojo.map(_16.messages,function(_17,i){return new esri.tasks.NAMessage(_17);});}},serviceAreaPolygons:null,serviceAreaPolylines:null,facilities:null,pointBarriers:null,polylineBarriers:null,polygonBarriers:null,messages:null,_graphicsFromJson:function(_18){var sr=new esri.SpatialReference(_18.spatialReference);var _19=_18.features;return dojo.map(_19,function(_1a,i){var _1b=new esri.Graphic(_1a);_1b.geometry.setSpatialReference(sr);return _1b;});}});}