Get Fields Types of a map service layer  (AGSFeatureLayer)

2103
2
08-16-2010 12:48 PM
MarcoBrugna
New Contributor II
Hi,

I'm looking for a way to get the fields types of a map service layer.
I've found inside the AGSFeatureLayer class (undocumented) that there are the properties that can solve my problem, but I don't know to use it.

I just want to read the types of the fields because I have to sum the numeric fields.
When I do a query task the resulting NSDictionary has all strings, but I know that some of them are numeric.

I have to do a url request to get the json representation of the layer? Or I can use the AGSFeatureLayer?

Thanks
Marco
0 Kudos
2 Replies
HarikantJammi
New Contributor
Once you have your queryTask dictionary, you could do something like this ,

NSString * s= [MyDictionary objectForKey : @"NUMBER_DATA"] ;
double myNumber = [s floatValue] ;  or [s intvalue] ;

Is this what you are trying to do ??
0 Kudos
MarcoBrugna
New Contributor II
Once you have your queryTask dictionary, you could do something like this ,

NSString * s= [MyDictionary objectForKey : @"NUMBER_DATA"] ;
double myNumber = [s floatValue] ;  or [s intvalue] ;

Is this what you are trying to do ??


Well, yes  and no 🙂
The fact is that I don't know which are the fields that have numeric values, and I can't use your method because I may have a field with some unique codes like 1/2/3 or L1/L2/L3 together.
So I have to check all rows to be sure that all are numeric.

Actually I did a workaround.
I do a request with f=json to the mapservice. I also have seen that ArcGIS library implements SBJson library to parse the json to NSDictionary.
I can then use the JSONValue method from the NSString object and finally get the "fields" attribute from the json data.
With the fields list I filer only those with type like
esriFieldTypeDouble, esriFieldTypeInteger , esriFieldTypeSmallInteger,esriFieldTypeSingle
.

And now I can present a list with only the fields that I'm sure have only numbers.
0 Kudos