// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/tasks/FeatureSet","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/has ../kernel ../lang ../graphic ../SpatialReference ../graphicsUtils ../geometry/jsonUtils ../symbols/jsonUtils".split(" "),function(m,r,x,y,z,A,B,C,D,q,E){m=m(null,{declaredClass:"esri.tasks.FeatureSet",constructor:function(a){if(a){r.mixin(this,a);var b=this.features,e=a.spatialReference,t=q.getGeometryType(a.geometryType),e=this.spatialReference=new C(e);this.geometryType=a.geometryType;a.fields&&(this.fields=
a.fields);x.forEach(b,function(a,c){var n=a.geometry&&a.geometry.spatialReference;b[c]=new B(t&&a.geometry?new t(a.geometry):null,a.symbol&&E.fromJson(a.symbol),a.attributes);b[c].geometry&&!n&&b[c].geometry.setSpatialReference(e)});this._hydrate()}else this.features=[]},displayFieldName:null,geometryType:null,spatialReference:null,fieldAliases:null,toJson:function(a){var b={};this.displayFieldName&&(b.displayFieldName=this.displayFieldName);this.fields&&(b.fields=this.fields);this.spatialReference?
b.spatialReference=this.spatialReference.toJson():this.features[0]&&this.features[0].geometry&&(b.spatialReference=this.features[0].geometry.spatialReference.toJson());this.features[0]&&(this.features[0].geometry&&(b.geometryType=q.getJsonType(this.features[0].geometry)),b.features=D._encodeGraphics(this.features,a));b.geometryType=b.geometryType||this.geometryType;b.exceededTransferLimit=this.exceededTransferLimit;b.transform=this.transform;return A.fixJson(b)},_hydrate:function(){var a=this.transform,
b=this.geometryType;if(a&&b)for(var e=this.features,t=a.translate[0],m=a.translate[1],c=a.scale[0],n=a.scale[1],w=function(a,b,l){if("esriGeometryPoint"===a)return function(a){a.x=b(a.x);a.y=l(a.y)};if("esriGeometryPolyline"===a||"esriGeometryPolygon"===a)return function(a){a=a.rings||a.paths;var u,h,d,f,k,g,v,c;u=0;for(h=a.length;u<h;u++)for(k=a[u],d=0,f=k.length;d<f;d++)g=k[d],0<d?(v+=g[0],c+=g[1]):(v=g[0],c=g[1]),g[0]=b(v),g[1]=l(c)};if("esriGeometryEnvelope"===a)return function(a){a.xmin=b(a.xmin);
a.ymin=l(a.ymin);a.xmax=b(a.xmax);a.ymax=l(a.ymax)};if("esriGeometryMultipoint"===a)return function(a){a=a.points;var c,h,d,f,k;c=0;for(h=a.length;c<h;c++)d=a[c],0<c?(f+=d[0],k+=d[1]):(f=d[0],k=d[1]),d[0]=b(f),d[1]=l(k)}}(b,function(a){return a*c+t},function(a){return m-a*n}),a=0,b=e.length;a<b;a++)e[a].geometry&&w(e[a].geometry);this.transform=null},quantize:function(a){if(!this.geometryType)return this.transform=null,this;var b=a.translate[0],e=a.translate[1],m=a.scale[0],r=a.scale[1],c=this.features,
n=function(a,b,c){var h,d,f,k,g,l,e=[];h=0;for(d=a.length;h<d;h++)if(f=a[h],0<h){if(l=b(f[0]),f=c(f[1]),l!==k||f!==g)e.push([l-k,f-g]),k=l,g=f}else k=b(f[0]),g=c(f[1]),e.push([k,g]);return 0<e.length?e:null},w=function(a,b,c){if("esriGeometryPoint"===a)return function(a){a.x=b(a.x);a.y=c(a.y);return a};if("esriGeometryPolyline"===a||"esriGeometryPolygon"===a)return function(a){var d,f,h,g,e;h=a.rings||a.paths;e=[];d=0;for(f=h.length;d<f;d++)g=h[d],(g=n(g,b,c))&&e.push(g);return 0<e.length?(a.rings?
a.rings=e:a.paths=e,a):null};if("esriGeometryMultipoint"===a)return function(a){var d;d=n(a.points,b,c);return 0<d.length?(a.points=d,a):null};if("esriGeometryEnvelope"===a)return function(a){return a}}(this.geometryType,function(a){return Math.round((a-b)/m)},function(a){return Math.round((e-a)/r)}),p,q;p=0;for(q=c.length;p<q;p++)c[p].geometry&&(w(c[p].geometry)||c[p].setGeometry(null));this.transform=a;return this}});y("extend-esri")&&r.setObject("tasks.FeatureSet",m,z);return m});