/*
 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.layers.FeatureLayer"]){dojo._hasResource["esri.layers.FeatureLayer"]=true;dojo.provide("esri.layers.FeatureLayer");dojo.require("esri.layers.graphics");dojo.require("esri.tasks.query");dojo.require("dojo.io.iframe");dojo.require("esri.layers.agscommon");dojo.require("dojo.date.locale");dojo.declare("esri.layers.FeatureLayer",esri.layers.GraphicsLayer,{constructor:function(_1,_2){this._outFields=_2&&_2.outFields;this._loadCallback=_2&&_2.loadCallback;var _3=_2&&_2._usePatch;this._usePatch=(_3===null||_3===undefined)?true:_3;this._trackIdField=_2&&_2.trackIdField;this.objectIdField=_2&&_2.objectIdField;this._maxOffset=_2&&_2.maxAllowableOffset;this._optEditable=_2&&_2.editable;this._optAutoGen=_2&&_2.autoGeneralize;this.editSummaryCallback=_2&&_2.editSummaryCallback;this.userId=_2&&_2.userId;this.userIsAdmin=_2&&_2.userIsAdmin;this.useMapTime=(_2&&_2.hasOwnProperty("useMapTime"))?(!!_2.useMapTime):true;this.source=_2&&_2.source;this.gdbVersion=_2&&_2.gdbVersion;this._selectedFeatures={};this._selectedFeaturesArr=[];this._newFeatures=[];this._deletedFeatures={};this._ulid=this._getUniqueId();var _4=this.constructor,_5=this.mode=(esri._isDefined(_2&&_2.mode)?_2.mode:_4.MODE_ONDEMAND);switch(_5){case _4.MODE_SNAPSHOT:this._mode=new esri.layers._SnapshotMode(this);this._isSnapshot=true;break;case _4.MODE_ONDEMAND:this._tileWidth=(_2&&_2.tileWidth)||512;this._tileHeight=(_2&&_2.tileHeight)||512;this._mode=new esri.layers._OnDemandMode(this);var _6=_2&&_2.latticeTiling;this.latticeTiling=_6;break;case _4.MODE_SELECTION:this._mode=new esri.layers._SelectionMode(this);this._isSelOnly=true;break;}this._initLayer=dojo.hitch(this,this._initLayer);this._selectHandler=dojo.hitch(this,this._selectHandler);this._editable=false;if(dojo.isObject(_1)&&_1.layerDefinition){var _7=_1;this._collection=true;this.mode=_4.MODE_SNAPSHOT;this._initLayer(_7);return this;}this._task=new esri.tasks.QueryTask(this.url,{source:this.source,gdbVersion:this.gdbVersion});var _8=this._url.path;this._fserver=false;if(_8.search(/\/FeatureServer\//i)!==-1){this._fserver=true;}var _9=_2&&_2.resourceInfo;if(_9){this._initLayer(_9);}else{if(this.source){var _a={source:this.source.toJson()};this._url.query=dojo.mixin(this._url.query,{layer:dojo.toJson(_a)});}if(this.gdbVersion){this._url.query=dojo.mixin(this._url.query,{gdbVersion:this.gdbVersion});}esri.request({url:_8,content:dojo.mixin({f:"json"},this._url.query),callbackParamName:"callback",load:this._initLayer,error:this._errorHandler});}},_initLayer:function(_b,io){if(_b||io){this._json=_b;this._findCredential();if(this._collection){this._mode=new esri.layers._SnapshotMode(this);this._isSnapshot=true;this._featureSet=_b.featureSet;this._nextId=_b.nextObjectId;_b=_b.layerDefinition;}if(_b.hasOwnProperty("capabilities")){var _c=(this.capabilities=_b.capabilities);if(_c&&_c.toLowerCase().indexOf("editing")!==-1){this._editable=true;}else{this._editable=false;}}else{if(!this._collection){this._editable=this._fserver;}}if(esri._isDefined(this._optEditable)){this._editable=this._optEditable;delete this._optEditable;}this._json=dojo.toJson(this._json);if(this._editable){delete this._maxOffset;}else{if(this.mode!==this.constructor.MODE_SNAPSHOT&&((_b.geometryType==="esriGeometryPolyline")||(_b.geometryType==="esriGeometryPolygon"))){this._autoGeneralize=esri._isDefined(this._optAutoGen)?this._optAutoGen:(this.mode===this.constructor.MODE_ONDEMAND);delete this._optAutoGen;}}this.minScale=_b.minScale||0;this.maxScale=_b.maxScale||0;this.layerId=_b.id;this.name=_b.name;this.description=_b.description;this.copyright=_b.copyrightText;this.type=_b.type;this.geometryType=_b.geometryType;this.displayField=_b.displayField;this.defaultDefinitionExpression=_b.definitionExpression;this.fullExtent=new esri.geometry.Extent(_b.extent);if((this.geometryType==="esriGeometryPoint")||(this.geometryType==="esriGeometryMultipoint")){this.latticeTiling=false;}this.indexedFields=_b.indexedFields;this.maxRecordCount=_b.maxRecordCount;this.canModifyLayer=_b.canModifyLayer;this.supportsStatistics=_b.supportsStatistics;this.supportsAdvancedQueries=_b.supportsAdvancedQueries;this.hasLabels=_b.hasLabels;this.canScaleSymbols=_b.canScaleSymbols;this.supportsRollbackOnFailure=_b.supportsRollbackOnFailure;this.syncCanReturnChanges=_b.syncCanReturnChanges;this.isDataVersioned=_b.isDataVersioned;this.editFieldsInfo=_b.editFieldsInfo;this.ownershipBasedAccessControlForFeatures=_b.ownershipBasedAccessControlForFeatures;if(this.editFieldsInfo&&this.ownershipBasedAccessControlForFeatures){this.creatorField=this.editFieldsInfo.creatorField;}this.relationships=_b.relationships;this.allowGeometryUpdates=esri._isDefined(_b.allowGeometryUpdates)?_b.allowGeometryUpdates:true;this._isTable=(this.type==="Table");var _d=(this.fields=[]),_e=_b.fields,i;for(i=0;i<_e.length;i++){_d.push(new esri.layers.Field(_e[i]));}if(!this.objectIdField){this.objectIdField=_b.objectIdField;if(!this.objectIdField){_e=_b.fields;for(i=0;i<_e.length;i++){var _f=_e[i];if(_f.type==="esriFieldTypeOID"){this.objectIdField=_f.name;break;}}}if(!this.objectIdField){console.debug("esri.layers.FeatureLayer: "+esri.substitute({url:this.url},esri.bundle.layers.FeatureLayer.noOIDField));}}if(!esri._isDefined(this._nextId)){var _10=this.objectIdField,_11=-1;if(this._collection&&_10){var _12=this._featureSet,_13=_12&&_12.features,il=_13?_13.length:0,oid,_14;for(i=0;i<il;i++){_14=_13[i].attributes;oid=_14&&_14[_10];if(oid>_11){_11=oid;}}}this._nextId=(_11+1);}this.globalIdField=_b.globalIdField;this.typeIdField=_b.typeIdField;this.visibilityField=_b.visibilityField;var _15=_b.defaultSymbol;if(_15){this.defaultSymbol=esri.symbol.fromJson(_15);}var _16=this.types=[],_17=_b.types,_18,_19,_1a,_1b=this.editFieldsInfo,_1c=_1b&&_1b.creatorField,_1d=_1b&&_1b.editorField,fix=(_1c||_1d),_1e=[];if(_17){for(i=0;i<_17.length;i++){_18=new esri.layers.FeatureType(_17[i]);_19=_18.templates;if(fix&&_19&&_19.length){_1e=_1e.concat(_19);}_16.push(_18);}}var _1f=_b.templates,_20,_21=this.templates=[];if(_1f){for(i=0;i<_1f.length;i++){_20=new esri.layers.FeatureTemplate(_1f[i]);if(fix){_1e.push(_20);}_21.push(_20);}}for(i=0;i<_1e.length;i++){_1a=dojo.getObject("prototype.attributes",false,_1e[i]);if(_1a){if(_1c){delete _1a[_1c];}if(_1d){delete _1a[_1d];}}}var _22=_b.timeInfo;if(_22){this.timeInfo=new esri.layers.TimeInfo(_22);this._startTimeField=_22.startTimeField;this._endTimeField=_22.endTimeField;if(this._startTimeField&&this._endTimeField){this._twoTimeFields=true;}if(this._trackIdField){_22.trackIdField=this._trackIdField;}else{this._trackIdField=_22.trackIdField;}}this.hasAttachments=(!this._collection&&_b.hasAttachments)?true:false;this.htmlPopupType=_b.htmlPopupType;var _23=_b.drawingInfo,_24;if(!this.renderer){if(_23&&_23.renderer){_24=_23.renderer;this.setRenderer(esri.renderer.fromJson(_24));if(_24.type==="classBreaks"){this.renderer._setMaxInclusiveness(true);}if(!this._collection){var _25=_24.type,_26=[];_24=this.renderer;switch(_25){case "simple":_26.push(_24.symbol);break;case "uniqueValue":case "classBreaks":_26.push(_24.defaultSymbol);_26=_26.concat(dojo.map(_24.infos,function(_27){return _27.symbol;}));break;}_26=dojo.filter(_26,esri._isDefined);var _28=this._url.path+"/images/",_29=this._getToken();dojo.forEach(_26,function(sym){var url=sym.url;if(url){if((url.search(/https?\:/)===-1)&&(url.indexOf("data:")===-1)){sym.url=_28+url;}if(_29&&sym.url.search(/https?\:/)!==-1){sym.url+=("?token="+_29);}}});}}else{if(_15){_17=this.types;if(_17.length>0){_24=new esri.renderer.UniqueValueRenderer(this.defaultSymbol,this.typeIdField);dojo.forEach(_17,function(_2a){_24.addValue(_2a.id,_2a.symbol);});}else{_24=new esri.renderer.SimpleRenderer(this.defaultSymbol);}this.setRenderer(_24);}else{if(!this._isTable){var _2b;switch(this.geometryType){case "esriGeometryPoint":case "esriGeometryMultipoint":_2b=new esri.symbol.SimpleMarkerSymbol();break;case "esriGeometryPolyline":_2b=new esri.symbol.SimpleLineSymbol();break;case "esriGeometryPolygon":_2b=new esri.symbol.SimpleFillSymbol();break;}this.setRenderer(_2b?new esri.renderer.SimpleRenderer(_2b):null);}}}}var _2c=(_23&&_23.transparency)||0;if(!esri._isDefined(this.opacity)&&_2c>0){this.opacity=1-(_2c/100);}this.version=_b.currentVersion;if(!this.version){var ver;if("capabilities" in _b||"drawingInfo" in _b||"hasAttachments" in _b||"htmlPopupType" in _b||"relationships" in _b||"timeInfo" in _b||"typeIdField" in _b||"types" in _b){ver=10;}else{ver=9.3;}this.version=ver;}if((dojo.isIE||dojo.isSafari)&&this._editable&&this.version<10.02){this._ts=true;}this.loaded=true;this._fixRendererFields();this._checkFields();this._updateCaps();if(this._collection){this._fireUpdateStart();var _2d=this._featureSet;delete this._featureSet;this._mode._drawFeatures(new esri.tasks.FeatureSet(_2d));this._fcAdded=true;}this.onLoad(this);var _2e=this._loadCallback;if(_2e){delete this._loadCallback;_2e(this);}}},setRenderer:function(ren){this.inherited("setRenderer",arguments);var _2f=this.renderer;if(_2f){this._ager=(_2f.declaredClass.indexOf("TemporalRenderer")!==-1&&_2f.observationAger&&_2f.observationRenderer);var _30=dojo.filter([_2f,_2f.observationRenderer,_2f.latestObservationRenderer,_2f.trackRenderer],esri._isDefined);var _31=[];dojo.forEach(_30,function(rnd){_31.push(rnd.attributeField);_31.push(rnd.attributeField2);_31.push(rnd.attributeField3);},this);this._rendererFields=dojo.filter(_31,esri._isDefined);}else{this._ager=false;this._rendererFields=[];}if(this.loaded&&this._rendererFields.length>0){this._fixRendererFields();this._checkFields(this._rendererFields);}if(this.loaded&&this._collection){this._typesDirty=true;}},_setMap:function(map,_32){this._map=map;this._toggleTime(true);var div=this.inherited("_setMap",arguments);this.clearSelection();var _33=this.renderer;if(this.timeInfo){if(this._trackIdField||(_33&&(_33.latestObservationRenderer||_33.trackRenderer))){this._trackManager=new esri.layers._TrackManager(this);this._trackManager.initialize(map);}}this._zoomConnect=dojo.connect(map,"onZoomEnd",this,this._zoomHandler);this._zoomHandler();var _34=this._mode;if(_34){_34.initialize(map);}return div;},_unsetMap:function(map,_35){var _36=this._mode;if(_36){_36.destroy();this._mode=null;}if(this._trackManager){this._trackManager.destroy();this._trackManager=null;}dojo.disconnect(this._zoomConnect);this._zoomConnect=null;this._toggleTime(false);this.inherited("_unsetMap",arguments);},refresh:function(){var _37=this._mode;if(_37){_37.refresh();}},setEditable:function(_38){if(!this._collection){console.log("FeatureLayer:setEditCapabilities - this functionality is not yet supported for layer in a feature service");return this;}if(!this.loaded){this._optEditable=_38;return this;}var _39=this._editable;this._editable=_38;this._updateCaps();if(_39!==_38){this.onCapabilitiesChange();}return this;},getEditCapabilities:function(_3a){var _3b={"canCreate":false,"canUpdate":false,"canDelete":false};if(!this.loaded||!this._editable){return _3b;}var _3c=_3a&&_3a.feature,_3d=_3a&&_3a.userId,_3e=dojo.map((this.capabilities?this.capabilities.toLowerCase().split(","):[]),dojo.trim),_3f=dojo.indexOf(_3e,"editing")>-1,_40=_3f&&(dojo.indexOf(_3e,"create")>-1),_41=_3f&&(dojo.indexOf(_3e,"update")>-1),_42=_3f&&(dojo.indexOf(_3e,"delete")>-1),_43=this.ownershipBasedAccessControlForFeatures,_44=this.editFieldsInfo,_45=_44&&_44.creatorField,_46=_44&&_44.realm,_47=_3c&&_3c.attributes,_48=(_47&&_45)?_47[_45]:undefined,_49,_4a=!!this.userIsAdmin,_4b=!_43||_4a||!!(_43.allowOthersToUpdate||_43.allowUpdateToOthers),_4c=!_43||_4a||!!(_43.allowOthersToDelete||_43.allowDeleteToOthers);if(_3f&&(!(_40||_41||_42)||_4a)){_40=_41=_42=true;}_49={"canCreate":_40,"canUpdate":_41,"canDelete":_42};if(_48===null){_49.canUpdate=_41&&_4b;_49.canDelete=_42&&_4c;}else{if(_48===""){return _49;}else{if(_48){_3d=_3d||this.getUserId();if(_3d&&_46){_3d=_3d+"@"+_46;}if(_3d.toLowerCase()===_48.toLowerCase()){return _49;}else{_49.canUpdate=_41&&_4b;_49.canDelete=_42&&_4c;}}}}return _49;},getUserId:function(){var _4d;if(this.loaded){_4d=(this.credential&&this.credential.userId)||this.userId||"";}return _4d;},setUserIsAdmin:function(_4e){this.userIsAdmin=_4e;},setEditSummaryCallback:function(_4f){this.editSummaryCallback=_4f;},getEditSummary:function(_50,_51,_52){_52=esri._isDefined(_52)?_52:(new Date()).getTime();var _53="",_54=this.getEditInfo(_50,_51,_52),_55=(_51&&_51.callback)||this.editSummaryCallback;if(_55){_54=_55(_50,_54)||"";}if(dojo.isString(_54)){_53=_54;}else{if(_54){var _56=_54.action,_57=_54.userId,_58=_54.timeValue,_59=0;if(_56){_59++;}if(_57){_59++;}if(esri._isDefined(_58)){_59++;}if(_59>1){_53=(_56==="edit"?"edit":"create")+(_57?"User":"")+(esri._isDefined(_58)?_54.displayPattern:"");}}_53=_53&&esri.substitute(_54,esri.bundle.layers.FeatureLayer[_53]);}return _53;},getEditInfo:function(_5a,_5b,_5c){if(!this.loaded){return;}_5c=esri._isDefined(_5c)?_5c:(new Date()).getTime();var _5d=(_5b&&_5b.action)||"last",_5e=this.editFieldsInfo,_5f=_5e&&_5e.creatorField,_60=_5e&&_5e.creationDateField,_61=_5e&&_5e.editorField,_62=_5e&&_5e.editDateField,_63=_5e&&_5e.realm,_64=_5a&&_5a.attributes,_65=(_64&&_5f)?_64[_5f]:undefined,_66=(_64&&_60)?_64[_60]:null,_67=(_64&&_61)?_64[_61]:undefined,_68=(_64&&_62)?_64[_62]:null,_69=this._getEditData(_65,_66,_5c),_6a=this._getEditData(_67,_68,_5c),_6b;switch(_5d){case "creation":_6b=_69;break;case "edit":_6b=_6a;break;case "last":_6b=_6a||_69;break;}if(_6b){_6b.action=(_6b===_6a)?"edit":"creation";}return _6b;},_getEditData:function(_6c,_6d,_6e){var _6f,_70,_71,_72=60000,_73=3600000,_74=2*_73,_75=24*_73,_76=7*_75;if(esri._isDefined(_6d)){_70=_6e-_6d;if(_70<0){_71="Full";}else{if(_70<_72){_71="Seconds";}else{if(_70<(2*_72)){_71="Minute";}else{if(_70<_73){_71="Minutes";}else{if(_70<_74){_71="Hour";}else{if(_70<_75){_71="Hours";}else{if(_70<_76){_71="WeekDay";}else{_71="Full";}}}}}}}}if((_6c!==undefined)||_71){_6f=_6f||{};_6f.userId=_6c;if(_71){var _77=dojo.date.locale.format,_78=new Date(_6d);_6f.minutes=Math.floor(_70/_72);_6f.hours=Math.floor(_70/_73);_6f.weekDay=_77(_78,{datePattern:"EEEE",selector:"date"});_6f.formattedDate=_77(_78,{selector:"date"});_6f.formattedTime=_77(_78,{selector:"time"});_6f.displayPattern=_71;_6f.timeValue=_6d;}}return _6f;},isEditable:function(){return this._editable;},setMaxAllowableOffset:function(_79){if(!this._editable){this._maxOffset=_79;}return this;},getMaxAllowableOffset:function(){return this._maxOffset;},setAutoGeneralize:function(_7a){if(!this.loaded){this._optAutoGen=_7a;}else{if(!this._editable&&(this.mode!==this.constructor.MODE_SNAPSHOT)&&((this.geometryType==="esriGeometryPolyline")||(this.geometryType==="esriGeometryPolygon"))){this._autoGeneralize=_7a;if(_7a){var map=this._map;if(map&&map.loaded){this._maxOffset=Math.floor(map.extent.getWidth()/map.width);}}else{delete this._maxOffset;}}}return this;},setScaleRange:function(_7b,_7c){this.minScale=_7b||0;this.maxScale=_7c||0;if(this._map&&this._map.loaded){this._updateStatus();}},setGDBVersion:function(_7d){if(!this._collection&&(_7d!==this.gdbVersion)&&(_7d||this.gdbVersion)){this.gdbVersion=_7d;this._task.gdbVersion=_7d;this._url.query=dojo.mixin(this._url.query,{gdbVersion:_7d});if(this.loaded){this.clearSelection();if(this._map){this.refresh();}}this.onGDBVersionChange();}return this;},setDefinitionExpression:function(_7e){this._defnExpr=_7e;var _7f=this._mode;if(_7f){_7f.propertyChangeHandler(1);}return this;},getDefinitionExpression:function(){return this._defnExpr;},setTimeDefinition:function(_80){if(this._isSnapshot){this._timeDefn=_80;var _81=this._mode;if(_81){_81.propertyChangeHandler(2);}}return this;},getTimeDefinition:function(){return this._timeDefn;},setTimeOffset:function(_82,_83){this._timeOffset=_82;this._timeOffsetUnits=_83;var _84=this._mode;if(_84){_84.propertyChangeHandler(0);}return this;},setUseMapTime:function(use){this.useMapTime=use;this._toggleTime(!this._suspended);var _85=this._mode;if(_85){_85.propertyChangeHandler(0);}},selectFeatures:function(_86,_87,_88,_89){_87=_87||this.constructor.SELECTION_NEW;var _8a=this._getShallowClone(_86),map=this._map,_8b,dfd=esri._fixDfd(new dojo.Deferred(esri._dfdCanceller));_8a.outFields=this._getOutFields();_8a.returnGeometry=true;if(map){_8a.outSpatialReference=new esri.SpatialReference(map.spatialReference.toJson());}if(!this._applyQueryFilters(_8a)){_8b={features:[]};this._selectHandler(_8b,_87,_88,_89,dfd);return dfd;}var _8c=this._canDoClientSideQuery(_8a);if(_8c){_8b={features:this._doQuery(_8a,_8c)};this._selectHandler(_8b,_87,_88,_89,dfd);return dfd;}else{if(this._collection){var err=new Error("FeatureLayer::selectFeatures - "+esri.bundle.layers.FeatureLayer.invalidParams);this._resolve([err],null,_89,dfd,true);return dfd;}var _8d=this;if(this._ts){_8a._ts=(new Date()).getTime();}var _8e=dfd._pendingDfd=this._task.execute(_8a);_8e.addCallbacks(function(_8f){_8d._selectHandler(_8f,_87,_88,_89,dfd);},function(err){_8d._resolve([err],null,_89,dfd,true);});return dfd;}},getSelectedFeatures:function(){var _90=this._selectedFeatures,_91=[],_92;for(_92 in _90){if(_90.hasOwnProperty(_92)){_91.push(_90[_92]);}}return _91;},clearSelection:function(_93){var _94=this._selectedFeatures,_95=this._mode,_96;for(_96 in _94){if(_94.hasOwnProperty(_96)){this._unSelectFeatureIIf(_96,_95);_95._removeFeatureIIf(_96);}}this._selectedFeatures={};if(this._isSelOnly){_95._applyTimeFilter(true);}if(!_93){this.onSelectionClear();}return this;},setSelectionSymbol:function(_97){this._selectionSymbol=_97;if(_97){var _98=this._selectedFeatures,_99;for(_99 in _98){if(_98.hasOwnProperty(_99)){_98[_99].setSymbol(_97);}}}return this;},getSelectionSymbol:function(){return this._selectionSymbol;},__msigns:[{n:"applyEdits",c:5,a:[{i:0},{i:1}],e:4,f:1}],applyEdits:function(_9a,_9b,_9c,_9d,_9e,_9f){var _a0=_9f.assembly,dfd=_9f.dfd;this._applyNormalized(_9a,_a0&&_a0[0]);this._applyNormalized(_9b,_a0&&_a0[1]);this.onBeforeApplyEdits(_9a,_9b,_9c);var i,_a1={},_a2=this.objectIdField,_a3={f:"json"},_a4=false;if(this._collection){var _a5={};_a5.addResults=_9a?dojo.map(_9a,function(){_a4=true;return {objectId:this._nextId++,success:true};},this):null;_a5.updateResults=_9b?dojo.map(_9b,function(_a6){_a4=true;var oid=_a6.attributes[_a2];_a1[oid]=_a6;return {objectId:oid,success:true};},this):null;_a5.deleteResults=_9c?dojo.map(_9c,function(_a7){_a4=true;return {objectId:_a7.attributes[_a2],success:true};},this):null;if(_a4){this._editHandler(_a5,_9a,_a1,_9d,_9e,dfd);}return;}if(_9a&&_9a.length>0){_a3.adds=this._convertFeaturesToJson(_9a,0,1);_a4=true;}if(_9b&&_9b.length>0){for(i=0;i<_9b.length;i++){var _a8=_9b[i];_a1[_a8.attributes[_a2]]=_a8;}_a3.updates=this._convertFeaturesToJson(_9b,0,0,1);_a4=true;}if(_9c&&_9c.length>0){var ids=[];for(i=0;i<_9c.length;i++){ids.push(_9c[i].attributes[_a2]);}_a3.deletes=ids.join(",");_a4=true;}if(_a4){var _a9=this;return esri.request({url:this._url.path+"/applyEdits",content:dojo.mixin(_a3,this._url.query),callbackParamName:"callback",load:function(_aa){_a9._editHandler(_aa,_9a,_a1,_9d,_9e,dfd);},error:function(err){_a9._resolve([err],null,_9e,dfd,true);}},{usePost:true});}},queryFeatures:function(_ab,_ac,_ad){return this._query("execute","onQueryFeaturesComplete",_ab,_ac,_ad);},queryRelatedFeatures:function(_ae,_af,_b0){return this._query("executeRelationshipQuery","onQueryRelatedFeaturesComplete",_ae,_af,_b0);},queryIds:function(_b1,_b2,_b3){return this._query("executeForIds","onQueryIdsComplete",_b1,_b2,_b3);},queryCount:function(_b4,_b5,_b6){return this._query("executeForCount","onQueryCountComplete",_b4,_b5,_b6);},queryAttachmentInfos:function(_b7,_b8,_b9){var url=this._url.path+"/"+_b7+"/attachments",dfd=new dojo.Deferred(esri._dfdCanceller),_ba=this;dfd._pendingDfd=esri.request({url:url,content:dojo.mixin({f:"json"},this._url.query),callbackParamName:"callback",load:function(_bb){var _bc=_bb.attachmentInfos,_bd;dojo.forEach(_bc,function(_be){_bd=dojo.objectToQuery({gdbVersion:_ba._url.query&&_ba._url.query.gdbVersion,layer:_ba._url.query&&_ba._url.query.layer,token:_ba._getToken()});_be.url=url+"/"+_be.id+(_bd?("?"+_bd):"");_be.objectId=_b7;});_ba._resolve([_bc],"onQueryAttachmentInfosComplete",_b8,dfd);},error:function(err){_ba._resolve([err],null,_b9,dfd,true);}});return dfd;},addAttachment:function(_bf,_c0,_c1,_c2){return this._sendAttachment("add",_bf,_c0,_c1,_c2);},updateAttachment:function(_c3,_c4,_c5,_c6,_c7){_c5.appendChild(dojo.create("input",{type:"hidden",name:"attachmentId",value:_c4}));return this._sendAttachment("update",_c3,_c5,_c6,_c7);},deleteAttachments:function(_c8,_c9,_ca,_cb){var url=this._url.path+"/"+_c8+"/deleteAttachments",dfd=new dojo.Deferred(esri._dfdCanceller),_cc=this,_cd={f:"json",attachmentIds:_c9.join(",")};dfd._pendingDfd=esri.request({url:url,content:dojo.mixin(_cd,this._url.query),callbackParamName:"callback",load:dojo.hitch(this,function(_ce){var _cf=_ce.deleteAttachmentResults;_cf=dojo.map(_cf,function(_d0){var res=new esri.layers.FeatureEditResult(_d0);res.attachmentId=res.objectId;res.objectId=_c8;return res;});_cc._resolve([_cf],"onDeleteAttachmentsComplete",_ca,dfd);}),error:function(err){_cc._resolve([err],null,_cb,dfd,true);}},{usePost:true});return dfd;},addType:function(_d1){if(!this._collection){return false;}var _d2=this.types;if(_d2){var _d3=dojo.some(_d2,function(_d4){if(_d4.id==_d1.id){return true;}return false;});if(_d3){return false;}else{_d2.push(_d1);}}else{this.types=[_d1];}this._typesDirty=true;return true;},deleteType:function(_d5){if(!this._collection){return;}var _d6=this.types;if(_d6){var _d7=-1;dojo.some(_d6,function(_d8,_d9){if(_d8.id==_d5){_d7=_d9;return true;}return false;});if(_d7>-1){this._typesDirty=true;return _d6.splice(_d7,1)[0];}}},toJson:function(){var _da=this._json,_db=dojo.isString(_da)?dojo.fromJson(_da):dojo.clone(_da);if(!_db){return;}_db=_db.layerDefinition?_db:{layerDefinition:_db};var _dc=_db.layerDefinition,_dd=this._collection;if(_dd&&this._typesDirty){_dc.types=dojo.map(this.types||[],function(_de){return _de.toJson();});var _df=this.renderer,_e0=_dc.drawingInfo;if(_e0&&_df&&_df.declaredClass.indexOf("TemporalRenderer")===-1){_e0.renderer=_df.toJson();}}var _e1=null;if(!(_dd&&!this._fcAdded)){_e1={geometryType:_dc.geometryType,features:this._convertFeaturesToJson(this.graphics,true)};}_db.featureSet=dojo.mixin({},_db.featureSet||{},_e1);if(_dd){_db.nextObjectId=this._nextId;_dc.capabilities=this.capabilities;}return _db;},onSelectionComplete:function(){},onSelectionClear:function(){},onBeforeApplyEdits:function(){},onEditsComplete:function(){},onQueryFeaturesComplete:function(){},onQueryRelatedFeaturesComplete:function(){},onQueryIdsComplete:function(){},onQueryCountComplete:function(){},onQueryAttachmentInfosComplete:function(){},onAddAttachmentComplete:function(){},onUpdateAttachmentComplete:function(){},onDeleteAttachmentsComplete:function(){},onCapabilitiesChange:function(){},onGDBVersionChange:function(){},onQueryLimitExceeded:function(){},_updateCaps:function(){var _e2=this._editable,_e3=dojo.trim(this.capabilities||""),_e4=dojo.map((_e3?_e3.split(","):[]),dojo.trim),_e5=dojo.map((_e3?_e3.toLowerCase().split(","):[]),dojo.trim),_e6=dojo.indexOf(_e5,"editing"),cap,i,_e7,_e8={"Create":dojo.indexOf(_e5,"create"),"Update":dojo.indexOf(_e5,"update"),"Delete":dojo.indexOf(_e5,"delete")};if(_e2&&_e6===-1){_e4.push("Editing");}else{if(!_e2&&_e6>-1){_e7=[_e6];for(cap in _e8){if(_e8[cap]>-1){_e7.push(_e8[cap]);}}_e7.sort();for(i=_e7.length-1;i>=0;i--){_e4.splice(_e7[i],1);}}}this.capabilities=_e4.join(",");},_counter:{value:0},_getUniqueId:function(){return this._counter.value++;},_getDesiredStatus:function(){return this.visible&&this._isMapAtVisibleScale();},_isMapAtVisibleScale:function(){if(!this._map){return false;}var _e9=esri.geometry.getScale(this._map);var _ea=this.minScale,_eb=this.maxScale,_ec=!_ea,_ed=!_eb;if(!_ec&&_e9<=_ea){_ec=true;}if(!_ed&&_e9>=_eb){_ed=true;}return (_ec&&_ed)?true:false;},_suspend:function(){this.inherited("_suspend",arguments);this._toggleTime(false);var _ee=this._mode;if(_ee){_ee.suspend();}},_resume:function(){this.inherited("_resume",arguments);this._toggleTime(true);var _ef=this._mode;if(_ef){_ef.resume();}},_zoomHandler:function(){var map=this._map;if(map&&map.loaded){if(this._autoGeneralize){this._maxOffset=Math.floor(map.extent.getWidth()/map.width);}this._updateStatus();}},_toggleTime:function(_f0){var map=this._map;if(_f0&&this.timeInfo&&this.useMapTime&&map){this._mapTimeExtent=map.timeExtent;if(!this._timeConnect){this._timeConnect=dojo.connect(map,"onTimeExtentChange",this,this._timeChangeHandler);}}else{this._mapTimeExtent=null;dojo.disconnect(this._timeConnect);this._timeConnect=null;}},_timeChangeHandler:function(_f1){this._mapTimeExtent=_f1;var _f2=this._mode;if(_f2){_f2.propertyChangeHandler(0);}},_getOffsettedTE:function(_f3){var _f4=this._timeOffset,_f5=this._timeOffsetUnits;return (_f3&&_f4&&_f5)?_f3.offset(-1*_f4,_f5):_f3;},_getTimeOverlap:function(_f6,_f7){if(_f6&&_f7){return _f6.intersection(_f7);}else{return _f6||_f7;}},_getTimeFilter:function(_f8){var _f9=this.getTimeDefinition(),_fa=null,_fb;if(_f9||_fa){_fb=this._getTimeOverlap(_f9,_fa);if(!_fb){return [false];}}if(_f8){_f8=_fb?this._getTimeOverlap(_f8,_fb):_f8;if(!_f8){return [false];}}else{_f8=_fb;}return [true,_f8];},_getAttributeFilter:function(_fc){var _fd=this.getDefinitionExpression();if(_fc){_fc=_fd?"("+_fd+") AND ("+_fc+")":_fc;}else{_fc=_fd;}return _fc;},_applyQueryFilters:function(_fe){_fe.where=this._getAttributeFilter(_fe.where);_fe.maxAllowableOffset=this._maxOffset;if(this.timeInfo){var _ff=this._getTimeFilter(_fe.timeExtent);if(!_ff[0]){return false;}else{_fe.timeExtent=_ff[1];}}return true;},_add:function(_100){var _101=this._selectionSymbol,attr=_100.attributes,_102=this.visibilityField;if(_101&&this._isSelOnly){_100.setSymbol(_101);}if(_102&&attr&&attr.hasOwnProperty(_102)){_100[attr[_102]?"show":"hide"]();}return this.add.apply(this,arguments);},_remove:function(){return this.remove.apply(this,arguments);},_canDoClientSideQuery:function(_103){var _104=[],map=this._map;if(this._isTable||!map){return;}if(_103.text||(_103.where&&_103.where!==this.getDefinitionExpression())){return;}var _105=this._isSnapshot,_106=this._isSelOnly;var _107=_103.geometry;if(_107){if(!_106&&_103.spatialRelationship===esri.tasks.Query.SPATIAL_REL_INTERSECTS&&(_107.type==="extent"&&(_105||map.extent.contains(_107)))){_104.push(1);}else{return;}}var ids=_103.objectIds;if(ids){if(_105){_104.push(2);}else{var len=ids.length,mode=this._mode,_108=0,i;for(i=0;i<len;i++){if(mode._getFeature(ids[i])){_108++;}}if(_108===len){_104.push(2);}else{return;}}}if(this.timeInfo){var _109=_103.timeExtent,_10a=this._mapTimeExtent;if(_105){if(_109){_104.push(3);}}else{if(_106){if(_109){return;}}else{if(_10a){if(dojo.indexOf(_104,2)!==-1){if(_109){_104.push(3);}}else{return;}}else{if(_104.length>0){if(_109){_104.push(3);}}else{if(_109){return;}}}}}}return _104.length>0?_104:null;},_doQuery:function(_10b,_10c,_10d){var _10e=[],mode=this._mode,_10f=this.objectIdField,i,len,_110;if(dojo.indexOf(_10c,2)!==-1){_10e=[];var ids=_10b.objectIds;len=ids.length;for(i=0;i<len;i++){var obj=mode._getFeature(ids[i]);if(obj){_10e.push(obj);}}if(_10e.length===0){return [];}}if(dojo.indexOf(_10c,1)!==-1){_110=_10e.length>0?_10e:this.graphics;len=_110.length;var _111=_10b.geometry._normalize(null,true);_10e=[];for(i=0;i<len;i++){var _112=_110[i],_113=_112.geometry;if(_113){if(this.normalization&&_111.length){if(_111[0].intersects(_113)||_111[1].intersects(_113)){_10e.push(_112);}}else{if(_111.intersects(_113)){_10e.push(_112);}}}}if(_10e.length===0){return [];}}if(dojo.indexOf(_10c,3)!==-1){if(this.timeInfo){_110=_10e.length>0?_10e:this.graphics;var time=_10b.timeExtent,_114=this._filterByTime(_110,time.startTime,time.endTime);_10e=_114.match;}}if(_10d){return dojo.map(_10e,function(obj){return obj.attributes[_10f];},this);}else{return _10e;}},_filterByTime:function(_115,_116,_117){var _118=this._startTimeField,_119=this._endTimeField,_11a;if(!this._twoTimeFields){_11a=_118||_119;}var _11b=esri._isDefined,yea=[],nay=[],i,len=_115.length,_11c,_11d;_116=_116?_116.getTime():-Infinity;_117=_117?_117.getTime():Infinity;if(_11a){for(i=0;i<len;i++){_11c=_115[i];_11d=_11c.attributes;var time=_11d[_11a];if(time>=_116&&time<=_117){yea.push(_11c);}else{nay.push(_11c);}}}else{for(i=0;i<len;i++){_11c=_115[i];_11d=_11c.attributes;var _11e=_11d[_118],end=_11d[_119];_11e=_11b(_11e)?_11e:-Infinity;end=_11b(end)?end:Infinity;if((_11e>=_116&&_11e<=_117)||(end>=_116&&end<=_117)||(_116>=_11e&&_117<=end)){yea.push(_11c);}else{nay.push(_11c);}}}return {match:yea,noMatch:nay};},_resolve:function(args,_11f,_120,dfd,_121){if(_11f){this[_11f].apply(this,args);}if(_120){_120.apply(null,args);}if(dfd){esri._resDfd(dfd,args,_121);}},_getShallowClone:function(_122){var _123=new esri.tasks.Query(),prop;for(prop in _122){if(_122.hasOwnProperty(prop)){_123[prop]=_122[prop];}}return _123;},_query:function(type,_124,_125,_126,_127){var that=this,dfd=new dojo.Deferred(esri._dfdCanceller);var _128=function(_129,_12a){if(!_12a&&type==="execute"&&!that._isTable){var _12b=_129.features,mode=that._mode,_12c=that.objectIdField,il=_12b.length,i;for(i=il-1;i>=0;i--){var oid=_12b[i].attributes[_12c];var _12d=mode._getFeature(oid);if(_12d){_12b.splice(i,1,_12d);}}}that._resolve([_129],_124,_126,dfd);};if(type!=="executeRelationshipQuery"){_125=this._getShallowClone(_125);_125.outFields=this._getOutFields();_125.returnGeometry=true;var map=this._map,_12e;if(map){_125.outSpatialReference=new esri.SpatialReference(map.spatialReference.toJson());}if(!this._applyQueryFilters(_125)){switch(type){case "execute":_12e=new esri.tasks.FeatureSet({features:[]});break;case "executeForIds":_12e=[];break;case "executeForCount":_12e=0;break;}_128(_12e,true);return dfd;}var _12f=this._canDoClientSideQuery(_125);if(_12f){var _130=this._doQuery(_125,_12f,(type==="executeForIds"||type==="executeForCount"));switch(type){case "execute":_12e=new esri.tasks.FeatureSet();_12e.features=_130;break;case "executeForIds":_12e=_130;break;case "executeForCount":_12e=_130.length;break;}_128(_12e,true);return dfd;}}if(this._collection){var err=new Error("FeatureLayer::_query - "+esri.bundle.layers.FeatureLayer.invalidParams);this._resolve([err],null,_127,dfd,true);return dfd;}if(this._ts){_125._ts=(new Date()).getTime();}var temp=dfd._pendingDfd=this._task[type](_125);temp.addCallbacks(_128,function(err){that._resolve([err],null,_127,dfd,true);});return dfd;},_convertFeaturesToJson:function(_131,_132,_133,_134){var json=[],_135=this._selectionSymbol,_136=this.visibilityField,i,_137,_138=this.objectIdField;if(_133||_134){_137=dojo.filter(this.fields,function(_139){return (_139.editable===false)&&(!_134||(_139.name!==_138));});}for(i=0;i<_131.length;i++){var _13a=_131[i],_13b={},_13c=_13a.geometry,attr=_13a.attributes,_13d=_13a.symbol;if(_13c&&(!_134||this.allowGeometryUpdates)){_13b.geometry=_13c.toJson();}if(_136){_13b.attributes=attr=dojo.mixin({},attr);attr[_136]=_13a.visible?1:0;}else{if(attr){_13b.attributes=dojo.mixin({},attr);}}if(_13b.attributes&&_137&&_137.length){dojo.forEach(_137,function(_13e){delete _13b.attributes[_13e.name];});}if(_13d&&(_13d!==_135)){_13b.symbol=_13d.toJson();}json.push(_13b);}return _132?json:dojo.toJson(json);},_selectHandler:function(_13f,_140,_141,_142,dfd){var _143,ctor=this.constructor;switch(_140){case ctor.SELECTION_NEW:this.clearSelection(true);_143=true;break;case ctor.SELECTION_ADD:_143=true;break;case ctor.SELECTION_SUBTRACT:_143=false;break;}var i,_144=_13f.features,mode=this._mode,_145=[],_146=this.objectIdField,_147,oid;if(_143){for(i=0;i<_144.length;i++){_147=_144[i];oid=_147.attributes[_146];var _148=mode._addFeatureIIf(oid,_147);_145.push(_148);this._selectFeatureIIf(oid,_148,mode);}}else{for(i=0;i<_144.length;i++){_147=_144[i];oid=_147.attributes[_146];this._unSelectFeatureIIf(oid,mode);var _149=mode._removeFeatureIIf(oid);_145.push(_149||_147);}}if(this._isSelOnly){mode._applyTimeFilter(true);}this._resolve([_145,_140,_13f.exceededTransferLimit?{queryLimitExceeded:true}:null],"onSelectionComplete",_141,dfd);if(_13f.exceededTransferLimit){this.onQueryLimitExceeded();}},_selectFeatureIIf:function(oid,_14a,mode){var _14b=this._selectedFeatures,_14c=_14b[oid];if(!_14c){mode._incRefCount(oid);_14b[oid]=_14a;if(!this._isTable){this._setSelectSymbol(_14a);}}return _14c||_14a;},_unSelectFeatureIIf:function(oid,mode){var _14d=this._selectedFeatures[oid];if(_14d){mode._decRefCount(oid);delete this._selectedFeatures[oid];if(!this._isTable){this._setUnSelectSymbol(_14d);}}return _14d;},_isSelected:function(_14e){},_setSelectSymbol:function(_14f){var _150=this._selectionSymbol;if(_150&&!this._isSelOnly){_14f.setSymbol(_150);}},_setUnSelectSymbol:function(_151){var _152=this._selectionSymbol;if(_152&&!this._isSelOnly){if(_152===_151.symbol){_151.setSymbol(null,true);}}},_getOutFields:function(){var _153=dojo.filter([this.objectIdField,this.typeIdField,this.creatorField,this._startTimeField,this._endTimeField,this._trackIdField].concat(this._rendererFields),function(_154,_155,arr){return !!_154&&(dojo.indexOf(arr,_154)===_155);});var _156=dojo.clone(this._outFields);if(_156){if(dojo.indexOf(_156,"*")!==-1){return _156;}dojo.forEach(_153,function(_157){if(dojo.indexOf(_156,_157)===-1){_156.push(_157);}});return _156;}else{return _153;}},_checkFields:function(_158){var _159=_158||this._getOutFields();dojo.forEach(_159,function(_15a){if(_15a==="*"){return;}if(!this._getField(_15a)){console.debug("esri.layers.FeatureLayer: "+esri.substitute({url:this.url,field:_15a},esri.bundle.layers.FeatureLayer.fieldNotFound));}},this);if(!_158&&!this._isTable&&!this._fserver&&!this._collection){var _15b=dojo.some(this.fields,function(_15c){return (_15c&&_15c.type==="esriFieldTypeGeometry")?true:false;});if(!_15b){console.debug("esri.layers.FeatureLayer: "+esri.substitute({url:this.url},esri.bundle.layers.FeatureLayer.noGeometryField));}}},_fixRendererFields:function(){var _15d=this.renderer;if(_15d&&this.fields.length>0){var _15e=dojo.filter([_15d,_15d.observationRenderer,_15d.latestObservationRenderer,_15d.trackRenderer],esri._isDefined);var _15f=[];dojo.forEach(_15e,function(rnd){var _160,_161;_161=rnd.attributeField;if(_161){_160=!this._getField(_161)&&this._getField(_161,true);if(_160){rnd.attributeField=_160.name;}}_161=rnd.attributeField2;if(_161){_160=!this._getField(_161)&&this._getField(_161,true);if(_160){rnd.attributeField2=_160.name;}}_161=rnd.attributeField3;if(_161){_160=!this._getField(_161)&&this._getField(_161,true);if(_160){rnd.attributeField3=_160.name;}}_15f.push(rnd.attributeField);_15f.push(rnd.attributeField2);_15f.push(rnd.attributeField3);},this);this._rendererFields=dojo.filter(_15f,esri._isDefined);}},_getField:function(_162,_163){var _164=this.fields;if(_164.length===0){return null;}var _165;if(_163){_162=_162.toLowerCase();}dojo.some(_164,function(_166){var _167=false;if(_163){_167=(_166&&_166.name.toLowerCase()===_162)?true:false;}else{_167=(_166&&_166.name===_162)?true:false;}if(_167){_165=_166;}return _167;});return _165;},_getDateOpts:function(){if(!this._dtOpts){var _168=dojo.map(dojo.filter(this.fields,function(_169){return !!(_169&&_169.type==="esriFieldTypeDate");}),function(_16a){return _16a.name;});this._dtOpts={properties:_168};}return this._dtOpts;},_applyNormalized:function(_16b,_16c){if(_16b&&_16c){dojo.forEach(_16b,function(_16d,_16e){if(_16d&&_16c[_16e]){_16d.setGeometry(_16c[_16e]);}});}},_editHandler:function(_16f,adds,_170,_171,_172,dfd){var _173=_16f.addResults,_174=_16f.updateResults,_175=_16f.deleteResults,i,_176,oid,_177,attr,_178=this.objectIdField,mode=this._mode,_179=this._isTable;var _17a=this.editFieldsInfo,_17b=this._getOutFields()||[],_17c=_17a&&_17a.creatorField,_17d=_17a&&_17a.creationDateField,_17e=_17a&&_17a.editorField,_17f=_17a&&_17a.editDateField,_180=_17a&&_17a.realm;if(dojo.indexOf(_17b,"*")===-1){if(_17c&&dojo.indexOf(_17b,_17c)===-1){_17c=null;}if(_17d&&dojo.indexOf(_17b,_17d)===-1){_17d=null;}if(_17e&&dojo.indexOf(_17b,_17e)===-1){_17e=null;}if(_17f&&dojo.indexOf(_17b,_17f)===-1){_17f=null;}}var _181=(_17d||_17f)?(new Date()).getTime():null,_182=(_17c||_17e)?this.getUserId():undefined;if(_182&&_180){_182=_182+"@"+_180;}if(_173){for(i=0;i<_173.length;i++){_173[i]=new esri.layers.FeatureEditResult(_173[i]);if(_179){continue;}_176=_173[i];if(_176.success){oid=_176.objectId;_177=adds[i];var gl=_177._graphicsLayer;if(gl&&gl!==this){gl.remove(_177);}attr=_177.attributes||{};attr[_178]=oid;if(_17c){attr[_17c]=_182;}if(_17e){attr[_17e]=_182;}if(_17d){attr[_17d]=_181;}if(_17f){attr[_17f]=_181;}_177.setAttributes(attr);mode.drawFeature(_177);}}}if(_174){for(i=0;i<_174.length;i++){_174[i]=new esri.layers.FeatureEditResult(_174[i]);if(_179){continue;}_176=_174[i];if(_176.success){oid=_176.objectId;_177=_170[oid];var _183=mode._getFeature(oid);if(_183){if(_183.geometry!==_177.geometry){_183.setGeometry(esri.geometry.fromJson(_177.geometry.toJson()));}this._repaint(_183,oid);}_177=_183||_177;attr=_177.attributes||{};if(_17e){attr[_17e]=_182;}if(_17f){attr[_17f]=_181;}_177.setAttributes(attr);}}}if(_175){var _184=[];for(i=0;i<_175.length;i++){_175[i]=new esri.layers.FeatureEditResult(_175[i]);if(_179){continue;}_176=_175[i];if(_176.success){oid=_176.objectId;_177=mode._getFeature(oid);if(_177){if(this._unSelectFeatureIIf(oid,mode)){_184.push(_177);}_177._count=0;mode._removeFeatureIIf(oid);}}}if(_184.length>0){this.onSelectionComplete(_184,this.constructor.SELECTION_SUBTRACT);}}this._resolve([_173,_174,_175],"onEditsComplete",_171,dfd);},_sendAttachment:function(type,_185,_186,_187,_188){var _189=(type==="add")?"addAttachment":"updateAttachment",url=this._url.path+"/"+_185+"/"+_189,self=this;var dfd=esri.request({url:url,form:_186,content:dojo.mixin(this._url.query,{f:"json",token:this._getToken()||undefined}),callbackParamName:"callback.html",handleAs:"json"}).addCallback(function(_18a){var _18b=(type==="add")?"addAttachmentResult":"updateAttachmentResult",_18c=(type==="add")?"onAddAttachmentComplete":"onUpdateAttachmentComplete",_18d=new esri.layers.FeatureEditResult(_18a[_18b]);_18d.attachmentId=_18d.objectId;_18d.objectId=_185;self._resolve([_18d],_18c,_187);return _18d;}).addErrback(function(_18e){self._resolve([_18e],null,_188,null,true);});return dfd;},_repaint:function(_18f,oid,_190){oid=esri._isDefined(oid)?oid:_18f.attributes[this.objectIdField];if(!(oid in this._selectedFeatures)||!this._selectionSymbol){_18f.setSymbol(_18f.symbol,_190);}},_getKind:function(_191){var _192=this._trackManager;if(_192){return _192.isLatestObservation(_191)?1:0;}return 0;}});dojo.mixin(esri.layers.FeatureLayer,{MODE_SNAPSHOT:0,MODE_ONDEMAND:1,MODE_SELECTION:2,SELECTION_NEW:3,SELECTION_ADD:4,SELECTION_SUBTRACT:5,POPUP_NONE:"esriServerHTMLPopupTypeNone",POPUP_HTML_TEXT:"esriServerHTMLPopupTypeAsHTMLText",POPUP_URL:"esriServerHTMLPopupTypeAsURL"});esri._createWrappers("esri.layers.FeatureLayer");dojo.declare("esri.layers.FeatureType",null,{constructor:function(json){if(json&&dojo.isObject(json)){this.id=json.id;this.name=json.name;var _193=json.symbol;if(_193){this.symbol=esri.symbol.fromJson(_193);}var _194=json.domains,_195,i;var _196=this.domains={};for(_195 in _194){if(_194.hasOwnProperty(_195)){var _197=_194[_195];switch(_197.type){case "range":_196[_195]=new esri.layers.RangeDomain(_197);break;case "codedValue":_196[_195]=new esri.layers.CodedValueDomain(_197);break;case "inherited":_196[_195]=new esri.layers.InheritedDomain(_197);break;}}}var _198=json.templates;if(_198){var _199=this.templates=[];for(i=0;i<_198.length;i++){_199.push(new esri.layers.FeatureTemplate(_198[i]));}}}},toJson:function(){var json={id:this.id,name:this.name,symbol:this.symbol&&this.symbol.toJson()};var _19a,_19b=this.domains,_19c=this.templates,_19d=esri._sanitize;if(_19b){var _19e=json.domains={};for(_19a in _19b){if(_19b.hasOwnProperty(_19a)){_19e[_19a]=_19b[_19a]&&_19b[_19a].toJson();}}_19d(_19e);}if(_19c){json.templates=dojo.map(_19c,function(_19f){return _19f.toJson();});}return _19d(json);}});dojo.declare("esri.layers.FeatureTemplate",null,{constructor:function(json){if(json&&dojo.isObject(json)){this.name=json.name;this.description=json.description;this.drawingTool=json.drawingTool;var _1a0=json.prototype;this.prototype=new esri.Graphic(_1a0.geometry,null,_1a0.attributes);}},toJson:function(){return esri._sanitize({name:this.name,description:this.description,drawingTool:this.drawingTool,prototype:this.prototype&&this.prototype.toJson()});}});dojo.mixin(esri.layers.FeatureTemplate,{TOOL_AUTO_COMPLETE_POLYGON:"esriFeatureEditToolAutoCompletePolygon",TOOL_CIRCLE:"esriFeatureEditToolCircle",TOOL_ELLIPSE:"esriFeatureEditToolEllipse",TOOL_FREEHAND:"esriFeatureEditToolFreehand",TOOL_LINE:"esriFeatureEditToolLine",TOOL_NONE:"esriFeatureEditToolNone",TOOL_POINT:"esriFeatureEditToolPoint",TOOL_POLYGON:"esriFeatureEditToolPolygon",TOOL_RECTANGLE:"esriFeatureEditToolRectangle",TOOL_ARROW:"esriFeatureEditToolArrow",TOOL_TRIANGLE:"esriFeatureEditToolTriangle",TOOL_LEFT_ARROW:"esriFeatureEditToolLeftArrow",TOOL_RIGHT_ARROW:"esriFeatureEditToolRightArrow",TOOL_UP_ARROW:"esriFeatureEditToolUpArrow",TOOL_DOWN_ARROW:"esriFeatureEditToolDownArrow"});dojo.declare("esri.layers.FeatureEditResult",null,{constructor:function(json){if(json&&dojo.isObject(json)){this.objectId=json.objectId;this.success=json.success;if(!json.success){var err=json.error;this.error=new Error();this.error.code=err.code;this.error.message=err.description;}}}});dojo.declare("esri.layers._RenderMode",null,{constructor:function(){this._prefix="jsonp_"+(dojo._scopeName||"dojo")+"IoScript";},initialize:function(map){},propertyChangeHandler:function(type){},destroy:function(){},drawFeature:function(_1a1){},suspend:function(){},resume:function(){},refresh:function(){},_incRefCount:function(oid){var _1a2=this._featureMap[oid];if(_1a2){_1a2._count++;}},_decRefCount:function(oid){var _1a3=this._featureMap[oid];if(_1a3){_1a3._count--;}},_getFeature:function(oid){return this._featureMap[oid];},_addFeatureIIf:function(oid,_1a4){var fmap=this._featureMap,_1a5=fmap[oid],_1a6=this.featureLayer;if(!_1a5){fmap[oid]=_1a4;_1a6._add(_1a4);_1a4._count=0;}return _1a5||_1a4;},_removeFeatureIIf:function(oid){var _1a7=this._featureMap[oid],_1a8=this.featureLayer;if(_1a7){if(_1a7._count){return;}delete this._featureMap[oid];_1a8._remove(_1a7);}return _1a7;},_clearIIf:function(){var i,_1a9=this.featureLayer,_1aa=_1a9.graphics,_1ab=_1a9._selectedFeatures,_1ac=_1a9.objectIdField;for(i=_1aa.length-1;i>=0;i--){var _1ad=_1aa[i];var oid=_1ad.attributes[_1ac];if(oid in _1ab){_1ad._count=1;continue;}_1ad._count=0;this._removeFeatureIIf(oid);}},_isPending:function(id){var dfd=dojo.io.script[this._prefix+id];return dfd?true:false;},_cancelPendingRequest:function(dfd,id){dfd=dfd||dojo.io.script[this._prefix+id];if(dfd){try{dfd.cancel();dojo.io.script._validCheck(dfd);}catch(e){}}},_purgeRequests:function(){dojo.io.script._validCheck(null);},_toggleVisibility:function(show){var _1ae=this.featureLayer,_1af=_1ae.graphics,_1b0=show?"show":"hide",i,len=_1af.length;show=show&&_1ae._ager;for(i=0;i<len;i++){var _1b1=_1af[i];_1b1[_1b0]();if(show){_1ae._repaint(_1b1);}}},_applyTimeFilter:function(_1b2){var _1b3=this.featureLayer;if(!_1b3.timeInfo||_1b3._suspended){return;}if(!_1b2){_1b3._fireUpdateStart();}var _1b4=_1b3._trackManager;if(_1b4){_1b4.clearTracks();}var defn=_1b3.getTimeDefinition(),_1b5=_1b3._getOffsettedTE(_1b3._mapTimeExtent);if(_1b5){_1b5=_1b3._getTimeOverlap(defn,_1b5);if(_1b5){var _1b6=_1b3._filterByTime(_1b3.graphics,_1b5.startTime,_1b5.endTime);if(_1b4){_1b4.addFeatures(_1b6.match);}dojo.forEach(_1b6.match,function(_1b7){var _1b8=_1b7._shape;if(!_1b7.visible){_1b7.show();_1b8=_1b7._shape;_1b8&&_1b8._moveToFront();}if(_1b3._ager&&_1b8){_1b3._repaint(_1b7);}});dojo.forEach(_1b6.noMatch,function(_1b9){if(_1b9.visible){_1b9.hide();}});}else{this._toggleVisibility(false);}}else{if(_1b4){_1b4.addFeatures(_1b3.graphics);}this._toggleVisibility(true);}if(_1b4){_1b4.moveLatestToFront();_1b4.drawTracks();}if(!_1b2){_1b3._fireUpdateEnd();}}});dojo.declare("esri.layers._SelectionMode",[esri.layers._RenderMode],{constructor:function(_1ba){this.featureLayer=_1ba;this._featureMap={};},initialize:function(map){this.map=map;this._init=true;},propertyChangeHandler:function(type){if(this._init&&type===0){this._applyTimeFilter();}},destroy:function(){this._init=false;},resume:function(){this.propertyChangeHandler(0);}});dojo.declare("esri.layers._SnapshotMode",[esri.layers._RenderMode],{constructor:function(_1bb){this.featureLayer=_1bb;this._featureMap={};this._drawFeatures=dojo.hitch(this,this._drawFeatures);this._queryErrorHandler=dojo.hitch(this,this._queryErrorHandler);},initialize:function(map){this.map=map;var _1bc=this.featureLayer;if(_1bc._collection){this._applyTimeFilter();}else{this._fetchAll();}this._init=true;},propertyChangeHandler:function(type){if(this._init){if(type){this._fetchAll();}else{this._applyTimeFilter();}}},destroy:function(){this._init=false;},drawFeature:function(_1bd){var _1be=this.featureLayer,_1bf=_1be.objectIdField,oid=_1bd.attributes[_1bf];this._addFeatureIIf(oid,_1bd);this._incRefCount(oid);},resume:function(){this.propertyChangeHandler(0);},refresh:function(){var _1c0=this.featureLayer;if(_1c0._collection){_1c0._fireUpdateStart();_1c0._refresh(true);_1c0._fireUpdateEnd();}else{this._fetchAll();}},_getRequestId:function(_1c1){var id="_"+_1c1.name+_1c1.layerId+_1c1._ulid;return id.replace(/[^a-zA-Z0-9\_]+/g,"_");},_fetchAll:function(){var _1c2=this.featureLayer;if(_1c2._collection){return;}_1c2._fireUpdateStart();this._clearIIf();this._sendRequest();},_sendRequest:function(){var map=this.map,_1c3=this.featureLayer,_1c4=_1c3.getDefinitionExpression();var _1c5=new esri.tasks.Query();_1c5.outFields=_1c3._getOutFields();_1c5.where=_1c4||"1=1";_1c5.returnGeometry=true;_1c5.outSpatialReference=new esri.SpatialReference(map.spatialReference.toJson());_1c5.timeExtent=_1c3.getTimeDefinition();_1c5.maxAllowableOffset=_1c3._maxOffset;if(_1c3._ts){_1c5._ts=(new Date()).getTime();}var _1c6;if(_1c3._usePatch){_1c6=this._getRequestId(_1c3);this._cancelPendingRequest(null,_1c6);}_1c3._task.execute(_1c5,this._drawFeatures,this._queryErrorHandler,_1c6);},_drawFeatures:function(_1c7){this._purgeRequests();var _1c8=_1c7.features,_1c9=this.featureLayer,_1ca=_1c9.objectIdField,i,len=_1c8.length,_1cb,oid;for(i=0;i<len;i++){_1cb=_1c8[i];oid=_1cb.attributes[_1ca];this._addFeatureIIf(oid,_1cb);this._incRefCount(oid);}this._applyTimeFilter(true);_1c9._fireUpdateEnd(null,_1c7.exceededTransferLimit?{queryLimitExceeded:true}:null);if(_1c7.exceededTransferLimit){_1c9.onQueryLimitExceeded();}},_queryErrorHandler:function(err){this._purgeRequests();var _1cc=this.featureLayer;_1cc._errorHandler(err);_1cc._fireUpdateEnd(err);}});dojo.declare("esri.layers._OnDemandMode",[esri.layers._RenderMode],{constructor:function(_1cd){this.featureLayer=_1cd;this._featureMap={};this._queryErrorHandler=dojo.hitch(this,this._queryErrorHandler);},initialize:function(map){this.map=map;this._initialize();this._init=true;},propertyChangeHandler:function(type){if(this._init){if(type<2){this._zoomHandler();}}},destroy:function(){this._disableConnectors();this._init=false;},drawFeature:function(_1ce){var _1cf=this._gridLayer,geom=_1ce.geometry,_1d0=[];if(!geom){return;}_1d0=_1cf.getCellsInExtent((geom.type==="point")?{xmin:geom.x,ymin:geom.y,xmax:geom.x,ymax:geom.y}:geom.getExtent(),false).cells;var _1d1=this._cellMap,i,cell,oid=_1ce.attributes[this.featureLayer.objectIdField],_1d2,row,col;for(i=0;i<_1d0.length;i++){cell=_1d0[i];_1d2=cell.latticeID;row=cell.row;col=cell.col;if(_1d2){cell=(_1d1[_1d2]=(_1d1[_1d2]||cell));}else{_1d1[row]=_1d1[row]||{};cell=(_1d1[row][col]=(_1d1[row][col]||cell));}cell.features=cell.features||[];cell.features.push(_1ce);this._addFeatureIIf(oid,_1ce);this._incRefCount(oid);}},suspend:function(){if(!this._init){return;}this._disableConnectors();},resume:function(){if(!this._init){return;}this._enableConnectors();this._zoomHandler();},refresh:function(){this._zoomHandler();},_initialize:function(){var map=this.map,_1d3=this.featureLayer;var _1d4=_1d3._srInfo;this._gridLayer=new esri.layers._GridLayout(new esri.geometry.Point(_1d4?_1d4.valid[0]:map.extent.xmin,map.extent.ymax,map.spatialReference),{width:_1d3._tileWidth,height:_1d3._tileHeight},{width:map.width,height:map.height},_1d4);this._ioQueue=[];if(!_1d3._suspended){this._zoomHandler();this._enableConnectors();}},_enableConnectors:function(){var map=this.map;this._zoomConnect=dojo.connect(map,"onZoomEnd",this,this._zoomHandler);this._panConnect=dojo.connect(map,"onPanEnd",this,this._panHandler);this._resizeConnect=dojo.connect(map,"onResize",this,this._panHandler);},_disableConnectors:function(){dojo.disconnect(this._zoomConnect);dojo.disconnect(this._panConnect);dojo.disconnect(this._resizeConnect);},_zoomHandler:function(){this._processIOQueue(true);var _1d5=this.featureLayer,map=this.map;if(_1d5._suspended){return;}_1d5._fireUpdateStart();this._clearIIf();var _1d6=_1d5._trackManager;if(_1d6){_1d6.clearTracks();}this._cellMap={};this._gridLayer.setResolution(map.extent);this._sendRequest();},_panHandler:function(){this.featureLayer._fireUpdateStart();this._sendRequest(this.featureLayer._resized&&arguments[0]);},_getRequestId:function(_1d7,cell){var id="_"+_1d7.name+_1d7.layerId+_1d7._ulid+"_"+cell.resolution+"_"+(cell.latticeID||(cell.row+"_"+cell.col));return id.replace(/[^a-zA-Z0-9\_]+/g,"_");},_sendRequest:function(_1d8){this._exceeds=false;var _1d9=this.featureLayer,map=this.map,_1da=_1d8||map.extent,_1db=this._gridLayer.getCellsInExtent(_1da,_1d9.latticeTiling),_1dc=_1db.cells;if(!_1d9._editable){var _1dd=this._cellMap;_1dc=dojo.filter(_1dc,function(cell){if(cell.lattice){if(_1dd[cell.latticeID]){return false;}}else{if(_1dd[cell.row]&&_1dd[cell.row][cell.col]){return false;}}return true;});}var _1de=_1d9._getOutFields(),_1df=_1d9.getDefinitionExpression(),time=_1d9._getOffsettedTE(_1d9._mapTimeExtent),_1e0=_1d9._usePatch,_1e1=this._ioQueue,i,self=this,func=this._drawFeatures,cell,_1e2,_1e3;this._pending=this._pending||0;for(i=0;i<_1dc.length;i++){cell=_1dc[i];_1e2=new esri.tasks.Query();_1e2.geometry=cell.extent||cell.lattice;_1e2.outFields=_1de;_1e2.where=_1df;if(_1d9.latticeTiling&&cell.extent){_1e2.spatialRelationship=esri.tasks.Query.SPATIAL_REL_CONTAINS;}_1e2.returnGeometry=true;_1e2.timeExtent=time;_1e2.maxAllowableOffset=_1d9._maxOffset;if(_1d9._ts){_1e2._ts=(new Date()).getTime();}_1e3=null;if(_1e0){_1e3=this._getRequestId(_1d9,cell);if(this._isPending(_1e3)){continue;}}this._pending++;_1e1.push(_1d9._task.execute(_1e2,function(){var _1e4=cell;return function(_1e5){func.apply(self,[_1e5,_1e4]);};}.call(this),this._queryErrorHandler,_1e3));}this._removeOldCells(_1da);this._endCheck();},_drawFeatures:function(_1e6,cell){this._exceeds=this._exceeds||_1e6.exceededTransferLimit;this._finalizeIO();var _1e7=this.featureLayer,map=this.map,_1e8=map.extent,_1e9=cell.extent,row=cell.row,col=cell.col,_1ea=_1e7.objectIdField,_1eb=_1e6.features,_1ec=this._gridLayer,_1ed=this._cellMap,i,len,_1ee=cell.latticeID,_1ef=_1ee?_1ed[_1ee]:(_1ed[row]&&_1ed[row][col]);if((cell.resolution!=_1ec._resolution)||(_1ee?(_1ee!==_1ec.getLatticeID(_1e8)):(!_1ec.intersects(_1e9,_1e8)))){if(_1ef){this._removeCell(row,col,_1ee);}}else{if(_1ef){this._updateCell(_1ef,_1eb);}else{cell.features=_1eb;if(_1ee){_1ed[_1ee]=cell;}else{_1ed[row]=_1ed[row]||{};_1ed[row][col]=cell;}len=_1eb.length;for(i=0;i<len;i++){var _1f0=_1eb[i];var oid=_1f0.attributes[_1ea];this._addFeatureIIf(oid,_1f0);this._incRefCount(oid);}}}this._endCheck();},_queryErrorHandler:function(err){this._finalizeIO();this.featureLayer._errorHandler(err);this._endCheck(true);},_finalizeIO:function(){this._purgeRequests();this._pending--;},_endCheck:function(_1f1){if(this._pending===0){this._processIOQueue();var _1f2=this.featureLayer,_1f3=_1f2._trackManager;if(_1f3){_1f3.clearTracks();_1f3.addFeatures(_1f2.graphics);if(_1f2._ager){dojo.forEach(_1f2.graphics,function(_1f4){if(_1f4._shape){_1f2._repaint(_1f4);}});}_1f3.moveLatestToFront();_1f3.drawTracks();}this.featureLayer._fireUpdateEnd(_1f1&&new Error("FeatureLayer: "+esri.bundle.layers.FeatureLayer.updateError),this._exceeds?{queryLimitExceeded:true}:null);if(this._exceeds){_1f2.onQueryLimitExceeded();}}},_processIOQueue:function(_1f5){this._ioQueue=dojo.filter(this._ioQueue,function(dfd){var keep=dfd.fired>-1?false:true;return keep;});if(_1f5){dojo.forEach(this._ioQueue,this._cancelPendingRequest);}},_removeOldCells:function(_1f6){var _1f7=this._cellMap,_1f8=this._gridLayer,_1f9,_1fa;for(_1f9 in _1f7){if(_1f7[_1f9]){var row=_1f7[_1f9],_1fb=row.latticeID,_1fc=0,_1fd=0;if(_1fb){_1fc++;if(_1fb!==_1f8.getLatticeID(_1f6)){this._removeCell(null,null,_1fb);_1fd++;}}else{for(_1fa in row){if(row[_1fa]){_1fc++;var _1fe=row[_1fa].extent;if(!_1f8.intersects(_1fe,_1f6)){this._removeCell(_1f9,_1fa);_1fd++;}}}}if(_1fd===_1fc){delete _1f7[_1f9];}}}},_updateCell:function(cell,_1ff){var _200=this.featureLayer,_201=_200.objectIdField,_202=_200._selectedFeatures,i,len=_1ff.length;cell.features=cell.features||[];for(i=0;i<len;i++){var _203=_1ff[i];var oid=_203.attributes[_201];var _204=this._addFeatureIIf(oid,_203);if(_204===_203){this._incRefCount(oid);cell.features.push(_204);}else{if(!(oid in _202)){_204.setGeometry(_203.geometry);_204.setAttributes(_203.attributes);}}}},_removeCell:function(row,col,_205){var _206=this._cellMap,_207=this.featureLayer,_208=_207.objectIdField;var cell=_205?_206[_205]:(_206[row]&&_206[row][col]);if(cell){if(_205){delete _206[_205];}else{delete _206[row][col];}var _209=cell.features,i;for(i=0;i<_209.length;i++){var _20a=_209[i];var oid=_20a.attributes[_208];this._decRefCount(oid);if(oid in _207._selectedFeatures){continue;}this._removeFeatureIIf(oid);}}}});dojo.declare("esri.layers._GridLayout",null,{constructor:function(_20b,_20c,_20d,_20e){this.origin=_20b;this.cellWidth=_20c.width;this.cellHeight=_20c.height;this.mapWidth=_20d.width;this.mapHeight=_20d.height;this.srInfo=_20e;},setResolution:function(_20f){this._resolution=(_20f.xmax-_20f.xmin)/this.mapWidth;if(this.srInfo){var _210=Math.round((2*this.srInfo.valid[1])/this._resolution),_211=Math.round(_210/this.cellWidth);this._frameStats=[_211,0,_211-1];}},getCellCoordinates:function(_212){var res=this._resolution,_213=this.origin;return {row:Math.floor((_213.y-_212.y)/(this.cellHeight*res)),col:Math.floor((_212.x-_213.x)/(this.cellWidth*res))};},normalize:function(col){var _214=this._frameStats;if(_214){var _215=_214[0],m180=_214[1],p180=_214[2];if(col<m180){col=col%_215;col=col<m180?col+_215:col;}else{if(col>p180){col=col%_215;}}}return col;},intersects:function(_216,_217){var _218=this.srInfo;if(_218){return dojo.some(_217._getParts(_218),function(_219){return _216.intersects(_219.extent);});}else{return _216.intersects(_217);}},getCellExtent:function(row,col){var res=this._resolution,_21a=this.origin,_21b=this.cellWidth,_21c=this.cellHeight;return new esri.geometry.Extent((col*_21b*res)+_21a.x,_21a.y-((row+1)*_21c*res),((col+1)*_21b*res)+_21a.x,_21a.y-(row*_21c*res),new esri.SpatialReference(_21a.spatialReference.toJson()));},getLatticeID:function(_21d){var _21e=this.getCellCoordinates({x:_21d.xmin,y:_21d.ymax}),_21f=this.getCellCoordinates({x:_21d.xmax,y:_21d.ymin}),_220=_21e.row,_221=_21f.row,_222=this.normalize(_21e.col),_223=this.normalize(_21f.col);return _220+"_"+_221+"_"+_222+"_"+_223;},sorter:function(a,b){return (a<b)?-1:1;},getCellsInExtent:function(_224,_225){var _226=this.getCellCoordinates({x:_224.xmin,y:_224.ymax}),_227=this.getCellCoordinates({x:_224.xmax,y:_224.ymin}),_228=_226.row,_229=_227.row,_22a=_226.col,_22b=_227.col,_22c=[],i,j,nj,_22d=[],_22e=[],len,xmin,xmax,ymin,ymax,_22f=[],_230,_231;for(i=_228;i<=_229;i++){for(j=_22a;j<=_22b;j++){nj=this.normalize(j);_224=this.getCellExtent(i,nj);_22c.push({row:i,col:nj,extent:_224,resolution:this._resolution});if(_225){_22d.push(_224.xmin,_224.xmax);_22e.push(_224.ymin,_224.ymax);}}}_22a=this.normalize(_22a);_22b=this.normalize(_22b);_22d.sort(this.sorter);_22e.sort(this.sorter);len=_22d.length;for(i=len-1;i>=0;i--){if(i<(len-1)){if(_22d[i]===_22d[i+1]){_22d.splice(i,1);}}}len=_22e.length;for(i=len-1;i>=0;i--){if(i<(len-1)){if(_22e[i]===_22e[i+1]){_22e.splice(i,1);}}}if(_22d.length&&_22e.length){xmin=_22d[0];xmax=_22d[_22d.length-1];ymin=_22e[0];ymax=_22e[_22e.length-1];len=_22d.length;for(i=0;i<len;i++){_22f.push([[_22d[i],ymax],[_22d[i],ymin]]);}len=_22e.length;for(i=0;i<len;i++){_22f.push([[xmin,_22e[i]],[xmax,_22e[i]]]);}_230=new esri.geometry.Polyline({paths:_22f,spatialReference:this.origin.spatialReference.toJson()});_231=_228+"_"+_229+"_"+_22a+"_"+_22b;_22c.push({latticeID:_231,lattice:_230,resolution:this._resolution});}return {minRow:_228,maxRow:_229,minCol:_22a,maxCol:_22b,cells:_22c};}});dojo.declare("esri.layers._TrackManager",null,{constructor:function(_232){this.layer=_232;this.trackMap={};},initialize:function(map){this.map=map;var _233=this.layer,_234=_233.renderer.trackRenderer;if(_234&&(_233.geometryType==="esriGeometryPoint")){var _235=(this.container=new esri.layers._GraphicsLayer({id:_233.id+"_tracks",_child:true}));_235._setMap(map,_233._div);_235.setRenderer(_234);}},addFeatures:function(_236){var tkid,_237=this.trackMap,_238=this.layer,_239=_238._trackIdField;dojo.forEach(_236,function(_23a){var _23b=_23a.attributes;tkid=_23b[_239];var ary=(_237[tkid]=(_237[tkid]||[]));ary.push(_23a);});var _23c=_238._startTimeField,_23d=_238.objectIdField;var _23e=function(a,b){var _23f=a.attributes[_23c],_240=b.attributes[_23c];if(_23f===_240){return (a.attributes[_23d]<b.attributes[_23d])?-1:1;}else{return (_23f<_240)?-1:1;}};for(tkid in _237){_237[tkid].sort(_23e);}},drawTracks:function(){var _241=this.container;if(!_241){return;}var _242=this.trackMap,sr=this.map.spatialReference,tkid,ary,path,i,_243;for(tkid in _242){ary=_242[tkid];path=[];for(i=ary.length-1;i>=0;i--){_243=ary[i].geometry;if(_243){path.push([_243.x,_243.y]);}}if(path.length>0){_241.add(new esri.Graphic(new esri.geometry.Polyline({paths:[path],spatialReference:sr})));}}},moveLatestToFront:function(){dojo.forEach(this.getLatestObservations(),function(_244){var _245=_244._shape;_245&&_245._moveToFront();this._repaint(_244,null,true);},this.layer);},getLatestObservations:function(){var _246=[];if(!this.layer.renderer.latestObservationRenderer){return _246;}var _247=this.trackMap,tkid;for(tkid in _247){var ary=_247[tkid];_246.push(ary[ary.length-1]);}return _246;},clearTracks:function(){var _248=this.getLatestObservations();this.trackMap={};var _249=this.container;if(_249){_249.clear();}dojo.forEach(_248,function(_24a){this._repaint(_24a,null,true);},this.layer);},isLatestObservation:function(_24b){var _24c=this.layer._trackIdField;var _24d=this.trackMap[_24b.attributes[_24c]];if(_24d){return (_24d[_24d.length-1]===_24b);}return false;},destroy:function(){var _24e=this.container;if(_24e){_24e.clear();_24e._unsetMap(this.map,this.layer._div);this.container=null;}this.map=null;this.layer=null;this.trackMap=null;}});}