AGSGeometryEngine normalizeCentralMeridianOfGeometry does not work with cached layer

522
2
09-26-2011 11:51 AM
EddieJesinsky
New Contributor
Example usage of this is in the FeatureLayerEditing sample and the OnlineOfflineEditing sample:

I noticed today that after caching a layer (and then loading it from JSON), I was getting null geometries when calling AGSGeometryEngine's normalizeCentralMeridianOfGeometry on anything.

For example (taken from FeatureLayerEditingSample):
popup.graphic.geometry = [[AGSGeometryEngine defaultGeometryEngine]simplifyGeometry:popup.graphic.geometry];
popup.graphic.geometry = [[AGSGeometryEngine defaultGeometryEngine]normalizeCentralMeridianOfGeometry:popup.graphic.geometry];


This code works fine when online, but when loading from JSON, the second line gets null geometry.
I got around it by just taking out the second line, but if anyone knows what is causing it I'd appreciate it.

Here's the json representation of popup.graphic.geometry while it is online:
{"x":-8936932.302947983,"y":4691798.109359831,"spatialReference":{"wkid":102100}}


Here's the json representation of popup.graphic.geometry after it is cached:
{"x":562370.4708862299,"y":4293844.423522947,"spatialReference":{"wkt":"PROJCS[\"NAD_1983_UTM_Zone_17N\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",500000.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-81.0],PARAMETER[\"Scale_Factor\",0.9996],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0],AUTHORITY[\"EPSG\",26917]]","wkid":26917}}


I also would like to know why the json representation changes so drastically when loaded offline?
0 Kudos
2 Replies
NimeshJarecha
Esri Regular Contributor
The normalizeCentralMeridianOfGeometry of AGSGeometryEngine works only if the geometry is either in WGS1984 (4326) or Web Mercator (102100, 3857 etc.). The JSON representation of popup.graphic.geometry while online is in Web Mercator (102100). Hence, it works. When you cache the feature the geometry has feature layers spatial reference (not WGS1984 or Web Mercator). Hence, you are getting the null geometry from normalizeCentralMeridianOfGeometry.

Hope this helps!

Regards,
Nimesh
0 Kudos
EddieJesinsky
New Contributor
The normalizeCentralMeridianOfGeometry of AGSGeometryEngine works only if the geometry is either in WGS1984 (4326) or Web Mercator (102100, 3857 etc.). The JSON representation of popup.graphic.geometry while online is in Web Mercator (102100). Hence, it works. When you cache the feature the geometry has feature layers spatial reference (not WGS1984 or Web Mercator). Hence, you are getting the null geometry from normalizeCentralMeridianOfGeometry.

Hope this helps!

Regards,
Nimesh


Got it, thanks! I noticed someone else had a similar issue, so it might help to have the spatial reference requirements in the documentation.
0 Kudos