Hello,
I have a problem to decode the shape attribute for adding the feature.geometry on a graphic layer.
Code for iOS :
-(void)resultatRecherche{
//on affiche le quartier qui est associé au nom recherche
featureForArray = [arrayQuartierRechercher objectAtIndex:0];
NSLog(@"feature rechercher : %@", featureForArray);
//NSLog(@"Geometry : %@", featureForArray.geometry.ags_JSONRepresentation);
//on essaye de redefinir les infos de shape
//NSString *shape = [featureForArray valueForKey:@"shape"];
//NSString* jsonPointAsString = @"{ \"x\" : -118.4 , \"y\" : -45.2 , \"spatialReference\" : {\"wkid\" : 4326} }";
//NSDictionary *json = [jsonPointAsString AGSJSONValue];
//AGSPoint* point = [[AGSPoint alloc] initWithJSON:json];
//AGSGeometry *testGeo = [featureForArray valueForKey:@"shape"];
//featureForArray.geometry = testGeo;
AGSSimpleFillSymbol *innerSymbol = [AGSSimpleFillSymbol simpleFillSymbol];
innerSymbol.color = [[UIColor redColor] colorWithAlphaComponent:0.80];
innerSymbol.outline = nil;
//graphicSelect = [AGSGraphic graphicWithGeometry:featureForArray.geometry symbol:innerSymbol attributes:nil];
//[myGraphicsLayer addGraphic:graphicSelect];
}
Result on iPad logs :
2015-03-02 16:55:40.587 CM 99[3226:951335] feature rechercher : {
"code_insee" = "'97117'";
date = "'2008-10-24 00:00:00'";
"ident_section" = "'97117AR'";
nom = "'Loreal'";
"numero_section" = "'AR'";
objectid = "\\n'12'";
origine = "'URBIS'";
shape = "'050300007C000000080010006C7F0000AD0B000001000000BFFBAFF9AF038EBFD9B0EF06A7F32CE2D376B4BE12C2FE8901FFF507F0993700C5D631F5C80AC1FF44B4BE12DDFD44B3FC23F6BC0F87F808C6EC03B5CC4CCAA308A4DF3C8E840BBFAA47CAA3088ABB37009BA40597B129FFF507BE932CB6C80A85D6319AA40585D631A3C70AA6F62EB6C80A94D026B1AA22BF8916BBFE24BF8916A8816782F52E82983283E1028C8467C3E102B09632CD8E2184AC22EEA408949932BCA813BFF50785D63190ED0FBABC3FF4BE12BE932CA4D10286D6318FE317BBA813B2B85C808A16A7F32CCBA308A6903AF08F2195FC24CBA308B9EA3483EB18999A0DBF8916BFF5078AAD1ED99A0D89AD1ECDCF2781FF44F6D20293D026B5C80A8ECF1B999A0D9FE9188ED91F83EB18BA8267B08F21A7F32CC3E102AA871DF8C710B2AA22CD8E2188D844CF8350B3B41AE38B16AB911587C205BCE117A38B16E4D1028D8E21A4D1028D8E2186B61A81F52E88A305B7DB3CFEEB0F86CC1BF2AA2295C610D38F3ABAB229D38F3A91EF23CFE317CE840BE4DF3C8E840BDEC62FCBA308FAF42C9FB429FEF507808A16F4BE128AA308DA9A0DC4E102FFF50791EF23FFF50782EB18CEE31786CC1BE9FD24BF8916CDD91F87C205EB9115D1E50DEA871DC1FF44CEE317C7C205D7861DC3E102EA871DBCA813AB911587C20598901594C610B2AA22B8C710999A0D86CC1BB7D2028AAD1E9AA405ADAE1EEB9B0D8AAD1EB6D20289AD1EF5C80A90EF23D9901597FC39CEE31798A713CED91FB5E60DF3B41A8AAD1ED89015B1850BCBEC3496BB3FCCCF2790F939C29832AEA408F3B41AC3EB18C6B61AC3E102E9871D8AA308F3B41A8E840BCED91FABC305DFE5298F1FEC991DF2D30AEBF0109BA405ECB708EBDD1FC9AF1EF6B238D48620C3E326EBF010D0B91AE7CE17F2F516F7F116DFE51FBBE609FBCD4DEDE805F99D12D1FA8201F8CD2DF7BE71D7BD24F09A5AD9B821B0C50EDAAE1BEAF642F5DC36E4A777DD9F12C0D54BFD8E09EBC71BF4B10EAAE808CFD324A5E934FAC59A019EC62FF8DA81019FD027D0F87E83A22AEFAD63'";
"source_geometrique" = "'-pci_dxf'";
x = "'677087.24670071'";
y = "'1805011.62693986'";
}
with this code the app crash :
-(void)resultatRecherche{
//on affiche le quartier qui est associé au nom recherche
featureForArray = [arrayQuartierRechercher objectAtIndex:0];
NSLog(@"feature rechercher : %@", featureForArray);
//NSLog(@"Geometry : %@", featureForArray.geometry.ags_JSONRepresentation);
//on essaye de redefinir les infos de shape
//NSString *shape = [featureForArray valueForKey:@"shape"];
//NSString* jsonPointAsString = @"{ \"x\" : -118.4 , \"y\" : -45.2 , \"spatialReference\" : {\"wkid\" : 4326} }";
//NSDictionary *json = [jsonPointAsString AGSJSONValue];
//AGSPoint* point = [[AGSPoint alloc] initWithJSON:json];
//AGSGeometry *testGeo = [featureForArray valueForKey:@"shape"];
//featureForArray.geometry = testGeo;
AGSSimpleFillSymbol *innerSymbol = [AGSSimpleFillSymbol simpleFillSymbol];
innerSymbol.color = [[UIColor redColor] colorWithAlphaComponent:0.80];
innerSymbol.outline = nil;
graphicSelect = [AGSGraphic graphicWithGeometry:featureForArray.geometry symbol:innerSymbol attributes:nil];
[myGraphicsLayer addGraphic:graphicSelect];
}
with this logs :
2015-03-02 16:42:44.378 CM 99[3188:948468] -[__NSDictionaryI geometry]: unrecognized selector sent to instance 0x1781a9760
2015-03-02 16:42:44.381 CM 99[3188:948468] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI geometry]: unrecognized selector sent to instance 0x1781a9760'
*** First throw call stack:
(0x186e25e48 0x197a740e4 0x186e2cf14 0x186e29cc4 0x186d2ec1c 0x1000e35bc 0x1000e395c 0x197f0fca0 0x187cfedb8 0x187cfef44 0x1000e3430 0x1000e82a4 0x187cdb508 0x187c2cc94 0x187c1c61c 0x187cde26c 0x1018ccdf0 0x1018d175c 0x186ddd6a0 0x186ddb748 0x186d091f4 0x18fe835a4 0x18b63a784 0x1000e95b8 0x1980e2a08)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any idea ?
Stephane
From the stack trace it appears that your featureForArray is in fact an NSDictionary
That is why the app crashes when you try to access the geometry as featureForArray.geometry
You should instead get the X & Y values out of the dictionary and create an AGSPoint with those values and the appropriate spatial reference