Hi,I am working in an application that have to label some polygons. I was wondering why some of the labels was not showing, until after tracing the bug I found that for the specific polygons where the label was not rendered the labelPointForPolygon function of the AGSGeometryEngine return a point with a valid X but with a Y totally outside of the world boundaries. I think that maybe the issue is related with the projection that I am using, some how. There is the code that reproduce the bug:
NSString* wtkNAN83HARNWashintongNort = [NSString stringWithString:@"PROJCS[""NAD_1983_HARN_StatePlane_Washington_North_FIPS_4601_Feet"",GEOGCS[""GCS_North_American_1983_HARN"",DATUM[""D_North_American_1983_HARN"",SPHEROID[""GRS_1980"",6378137.0,298.257222101]],PRIMEM[""Greenwich"",0.0],UNIT[""Degree"",0.0174532925199433]],PROJECTION[""Lambert_Conformal_Conic""],PARAMETER[""False_Easting"",1640416.666666667],PARAMETER[""False_Northing"",0.0],PARAMETER[""Central_Meridian"",-120.8333333333333],PARAMETER[""Standard_Parallel_1"",47.5],PARAMETER[""Standard_Parallel_2"",48.73333333333333],PARAMETER[""Latitude_Of_Origin"",47.0],UNIT[""Foot_US"",0.3048006096012192]]"];
AGSSpatialReference* originalProjection = [AGSSpatialReference spatialReferenceWithWKT:wtkNAN83HARNWashintongNort];
AGSGeometryEngine * geoEngine = [AGSGeometryEngine defaultGeometryEngine];
AGSMutablePolygon* polygone = [[AGSMutablePolygon alloc] initWithSpatialReference:originalProjection];
[polygone addRingToPolygon];
[polygone addPointToRing:[AGSPoint pointWithX:1301118.94 y:191402.517 spatialReference:nil]];
[polygone addPointToRing:[AGSPoint pointWithX:1301118.94 y:191415.36 spatialReference:nil]];
[polygone addPointToRing:[AGSPoint pointWithX:1301131.732 y:191415.365 spatialReference:nil]];
[polygone addPointToRing:[AGSPoint pointWithX:1301131.732 y:191402.517 spatialReference:nil]];
[polygone addPointToRing:[AGSPoint pointWithX:1301118.94 y:191402.517 spatialReference:nil]];
AGSPoint* pointForLabel = [geoEngine labelPointForPolygon:polygone];
NSLog(@"Point for label X: %f", pointForLabel.x); // the x is a nomal value between 1301118.94 and 1301131.732
NSLog(@"Point for label Y: %f", pointForLabel.y); // the y is a very wrong. it like 8888888889898888888888888888888888888888888 that is the bug....
// user a symbol like this to you can see the in the map that the polygon is visible but the text is not.
AGSCompositeSymbol* myMarkerPolySymbol = [[AGSCompositeSymbol alloc] init];
AGSTextSymbol* textSymbol = [AGSTextSymbol textSymbolWithTextTemplate:@"this text don't appear" color:[UIColor redColor]];
AGSSimpleFillSymbol* fill = [AGSSimpleFillSymbol simpleFillSymbol];
fill.color = [UIColor colorWithRed:0.8 green:0.3 blue:0.3 alpha:0.2];
fill.outline.color = [UIColor redColor];
fill.style = AGSSimpleFillSymbolStyleBackwardDiagonal;
[myMarkerPolySymbol.symbols addObject:fill];
[myMarkerPolySymbol.symbols addObject:textSymbol];
// if copy this code please note that I don't add the release for any of the alloc's and I am not adding (in this code) the polygon to any graphic layer, just using the NSLog to see the values.