AGSGeometry envelope property

2533
4
04-06-2010 07:26 AM
ChanceYohman
New Contributor
Line 59 of AGSBufferParameterViewController.m:

AGSEnvelope *env=[geometry envelope];

The above lines compiles without warning or errors, but causes this runtime error:

2010-04-06 11:24:49.894 AGSBufferParameter[1758:207] *** -[AGSGeometry envelope]: unrecognized selector sent to instance 0x3e07e30
2010-04-06 11:24:49.894 AGSBufferParameter[1758:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AGSGeometry envelope]: unrecognized selector sent to instance 0x3e07e30'
2010-04-06 11:24:49.896 AGSBufferParameter[1758:207] Stack: (
    31052891,
    2566046985,
    31434811,
    31004278,
    30856898,
    11194,
    3753794,
    9453,
    3237323,
    3275190,
    3263284,
    3245695,
    3272801,
    39148889,
    30837632,
    30833736,
    3239445,
    3276719,
    9368,
    9222
)

Why?
0 Kudos
4 Replies
NimeshJarecha
Esri Regular Contributor
The geometries you are creating in following code line are empty geometries and you are trying to get the envelope of an empty geometry. Hence, it throws an error.

geometries=[NSArray arrayWithObjects:[[AGSGeometry alloc] initWithSpatialReference:bSR],[[AGSGeometry alloc] initWithSpatialReference:bSR],[[AGSGeometry alloc] initWithSpatialReference:bSR],nil];

Instead, create few point geometries and create array as following.

geometries=[NSArray arrayWithObjects: point1,point2,nil];

Hope this  helps!
0 Kudos
ChanceYohman
New Contributor
I made that change and it didn't work.
0 Kudos
NimeshJarecha
Esri Regular Contributor
After making the following change it works. Please see result below.

Change,
NSLog(@"Envelope %i's Simple Representation: %@", [env simpleRepresentation]);
As,
NSLog(@"Envelope %i's Simple Representation: %@", i, [env simpleRepresentation]);

Result in Debug window:

[Session started at 2010-04-15 18:23:00 -0700.]
2010-04-15 18:23:02.327 AGSBufferParameter[4390:207] bSR's wkid: 4326 wkt: GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
2010-04-15 18:23:02.328 AGSBufferParameter[4390:207] Buffer Distances
2010-04-15 18:23:02.328 AGSBufferParameter[4390:207] 1.000000
2010-04-15 18:23:02.329 AGSBufferParameter[4390:207] 3.141590
2010-04-15 18:23:02.329 AGSBufferParameter[4390:207] Test Envelope
2010-04-15 18:23:02.330 AGSBufferParameter[4390:207] Test Envelope's xmin: -180.000000 ymin: -90.000000 xmax: 180.000000 ymax:90.000000 Center's X: 0.000000 Center's Y: 0.000000 Width: 360.000000 Height: 180.000000
2010-04-15 18:23:02.331 AGSBufferParameter[4390:207] Test Envelope Path == path2: 1
2010-04-15 18:23:02.331 AGSBufferParameter[4390:207] Test Envelope Path == path3: 0
2010-04-15 18:23:02.331 AGSBufferParameter[4390:207] Test Envelope's Bounding Box Origin x: -180.000000 y: -90.000000 width: 360.000000 height: 180.000000
2010-04-15 18:23:02.332 AGSBufferParameter[4390:207] Test Envelope's CGRect Origin x: -180.000000 y: -90.000000 width: 360.000000 height: 180.000000
2010-04-15 18:23:02.332 AGSBufferParameter[4390:207] Inside Pt is 1
2010-04-15 18:23:02.333 AGSBufferParameter[4390:207] Outside Pt is 0
2010-04-15 18:23:02.334 AGSBufferParameter[4390:207] Envelope's Simple Representation is -180.00000000,-90.00000000,180.00000000,90.00000000
2010-04-15 18:23:02.334 AGSBufferParameter[4390:207] Outside Envelope is 0
2010-04-15 18:23:02.335 AGSBufferParameter[4390:207] Inside Envelope is 1
2010-04-15 18:23:02.335 AGSBufferParameter[4390:207] The envelope is nil.
2010-04-15 18:23:02.336 AGSBufferParameter[4390:207] Intersection Envelope: 180.00000000,-90.00000000,180.00000000,-90.00000000
2010-04-15 18:23:02.338 AGSBufferParameter[4390:207] Geometry 1
2010-04-15 18:23:02.339 AGSBufferParameter[4390:207] Spatial Reference 1's wkid: 4326 wkt: GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
2010-04-15 18:23:02.340 AGSBufferParameter[4390:207] Envelope 1's Simple Representation: 0.00000000,0.00000000,0.00000000,0.00000000
2010-04-15 18:23:02.341 AGSBufferParameter[4390:207] Geometry 2
2010-04-15 18:23:02.341 AGSBufferParameter[4390:207] Spatial Reference 2's wkid: 4326 wkt: GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
2010-04-15 18:23:02.342 AGSBufferParameter[4390:207] Envelope 2's Simple Representation: -180.00000000,91.00000000,-180.00000000,91.00000000
2010-04-15 18:23:02.342 AGSBufferParameter[4390:207] bOSR's wkid: 3395 wkt: PROJCS["WGS 84 / World Mercator",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]
2010-04-15 18:23:02.343 AGSBufferParameter[4390:207] Union Results: 1
2010-04-15 18:23:02.343 AGSBufferParameter[4390:207] Union Results: 0
2010-04-15 18:23:02.343 AGSBufferParameter[4390:207] Unit: 9001
0 Kudos
ChanceYohman
New Contributor
My bad. 😮 Thanks.
0 Kudos