AGSIdentifyParameters not receiving according to order on Server, always get in Ascending Order.

4005
10
Jump to solution
08-11-2015 10:53 AM
PritiBose
New Contributor II

hello,

This is very strange , as from my Server site i have below Parameters for one of the Layers...

Fields:

FID (Type: esriFieldTypeOID, Alias: FID)

Shape (Type: esriFieldTypeGeometry, Alias: Shape)

APN (Type: esriFieldTypeString, Alias: APN, Length: 11 )

PREVIOUSAP (Type: esriFieldTypeString, Alias: PREVIOUSAP, Length: 200 )

AREA (Type: esriFieldTypeDouble, Alias: AREA)

ACRES (Type: esriFieldTypeDouble, Alias: ACRES)

ZONING (Type: esriFieldTypeString, Alias: ZONING, Length: 25 )

VAC (Type: esriFieldTypeString, Alias: VAC, Length: 1 )

EVAC (Type: esriFieldTypeString, Alias: EVAC, Length: 5 )

FIRE (Type: esriFieldTypeString, Alias: FIRE, Length: 5 )

ZMASK (Type: esriFieldTypeString, Alias: ZMASK, Length: 16 )

PERIMETER (Type: esriFieldTypeDouble, Alias: PERIMETER)

PC_LANDUSE (Type: esriFieldTypeString, Alias: PC_LANDUSE, Length: 2 )

TRACT (Type: esriFieldTypeString, Alias: TRACT, Length: 16 )

BOOK (Type: esriFieldTypeString, Alias: BOOK, Length: 3 )

TIF (Type: esriFieldTypeString, Alias: TIF, Length: 40 )

LOTNO (Type: esriFieldTypeString, Alias: LOTNO, Length: 5 )

TEMP (Type: esriFieldTypeString, Alias: TEMP, Length: 6 )

CENSUS (Type: esriFieldTypeString, Alias: CENSUS, Length: 9 )

GP (Type: esriFieldTypeString, Alias: GP, Length: 25 )

Type ID Field: N/A

i can access all the parameters or GIS Attributes from my iPAD app with below code...

            self.m_identifyParams.layerIds=arrLayerIDs; // Layer ID

            self.m_identifyParams.tolerance = 3;

            self.m_identifyParams.geometry =  env;

            self.m_identifyParams.size = self.m_mapView.bounds.size;

            self.m_identifyParams.mapEnvelope = self.m_mapView.visibleArea.envelope;

            self.m_identifyParams.returnGeometry = YES;

            self.m_identifyParams.layerOption = AGSIdentifyParametersLayerOptionAll;

            self.m_identifyParams.spatialReference = self.m_mapView.spatialReference;

           

            [self.m_identifyTask executeWithParameters:self.m_identifyParams];

- (void)identifyTask:(AGSIdentifyTask *)m_identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results

but what i am getting IdentifyResults is as in below Order Ascending Order:

    ACRES = "15.59";

    APN = "038-240-022";

    AREA = "678953.526";

    BOOK = 038;

    CENSUS = "";

    EVAC = "";

    FID = 5221;

    FIRE = "";

    GP = "ULDR - 2 DU/Ac CD/OSP";

    LOTNO = "";

    "PC_LANDUSE" = 00;

    PERIMETER = "4375.32";

    PREVIOUSAP = "";

    Shape = Polygon;

    TEMP = "";

    TIF = "http://gis/data/mapbks/bk038/03824.00";

    TRACT = "056-037";

    VAC = P;

    ZMASK = "Placer County";

    ZONING = "Placer County";

but i wish to get in same order as above from server Fields: , starting from FID, Shape ETC...

Tags (3)
1 Solution

Accepted Solutions
GagandeepSingh
Occasional Contributor II

AGSField is an object and not a dictionary. So if you access either of the 53 objects, cast it to AGSField and print the `name` property you should see the right values.

Refer to AGSField object.

This is what I got:

(lldb) po ((AGSField*)((AGSFeatureLayer*)layer).fields[0]).name

OBJECTID

View solution in original post

10 Replies
GagandeepSingh
Occasional Contributor II

Is that the list of attributes on a feature/graphic returned by identifyTask? If yes, then since `allAttributes` property is an `NSDictionary`, you cannot preserve the order. Otherwise, can you elaborate on how you are accessing these properties?

0 Kudos
PritiBose
New Contributor II

yes, it is identifyTask. i access 'allAttributes' which is NSDictionary, from - (void)identifyTask:(AGSIdentifyTask *)m_identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results

callback return on success method.

so in iPad(IOS SDK of ESRI) it is not possible. and i will always get in Ascending order....... and not according on attributes on a feature/graphic Layer.

it was requirement to display attributes as it is..from server...   if possible any workaround...

0 Kudos
GagandeepSingh
Occasional Contributor II

One workaround I can think of is creating an array of ordered keys : ["FID", "Shape", "APN", .... ]. Then looping through the array and getting the value corresponding to each key.

0 Kudos
PritiBose
New Contributor II

sorry that won't be possible as different Layers will have diff, Attributes...also no. of attributes differs.... also diff clients have different MAPs....so i guess i have to go ahead with Order what i get...

0 Kudos
PritiBose
New Contributor II

Hello,

there is no way even to access Layers Fields name...?

there should be method to access simple Layers Fields name.... and those will give me in proper order ....

0 Kudos
GagandeepSingh
Occasional Contributor II

AGSFeatureLayer has a property `fields` you can use to get the fields in the right order. Simply create a feature layer using the URL and inside layerDidLoad, you should have the fields in the right order.

Let me know if this helps.

Gagan

0 Kudos
PritiBose
New Contributor II

sorry, i tried Esri sample example itself.... GenerateRendererSample .... with all possible ways..but fields getting 0 key element...it does show 53 elements but all are 0

initWithString:FEATURE_SERVICE_URL = http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2

    //initialize the feature layer and assign the delegate

    self.featureLayer = [[AGSFeatureLayer alloc] initWithURL:[[NSURL alloc] initWithString:FEATURE_SERVICE_URL] mode:AGSFeatureLayerModeSnapshot];

    self.featureLayer.delegate = self;

    //using definition expression to get counties(features) for just California

With below code commented or without commented

    self.featureLayer.definitionExpression = @"state_name = 'California'";

    self.featureLayer.outFields = @[@"*"];

    [self.mapView addMapLayer:self.featureLayer];

-(void)layerDidLoad:(AGSLayer *)layer {

    //once the feature layer gets loaded

    //assign the layer's fields to the legend view controller

    self.legendViewController.classificationFields = self.featureLayer.fields;

}

layer.field ==> 0 key/value pair for all 53 fields

self.featureLayer.fields==> 0 key/value pair for all 53 fields

0 Kudos
PritiBose
New Contributor II

fields.png

0 Kudos
GagandeepSingh
Occasional Contributor II

AGSField is an object and not a dictionary. So if you access either of the 53 objects, cast it to AGSField and print the `name` property you should see the right values.

Refer to AGSField object.

This is what I got:

(lldb) po ((AGSField*)((AGSFeatureLayer*)layer).fields[0]).name

OBJECTID