AnsweredAssumed Answered

ArcObjects GCS to PCS

Question asked by shaningesri on May 15, 2015
Latest reply on May 15, 2015 by shaningesri

I have a point FC in a mxd file in WGS_1984_Web_Mercator_Auxiliary_Sphere, and displays in Decimal Degrees (Long/Lat).  I published it as a mapservice, and retrieved the features in my SOE project.  However, the features' Extent are not in Long/Lat.  Then, I used the piece of code below to convert the X/Y from GCS to PCS (in meters) but it does not work. What's wrong in my code?  Thanks if you can help.

public IPoint CoordinateConvert(IPoint point, string[] srID)  {
ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
ISpatialReference srTo;
IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem(Convert.ToInt32(srID[0]));
srTo = pcs;
IGeometry geometry;
geometry = point;
geometry.SpatialReference = point.SpatialReference;
point = geometry as IPoint;
double x, y;
point.QueryCoords(out x, out y);
System.Diagnostics.Debug.Print("X: " + x.ToString());
System.Diagnostics.Debug.Print("Y: " + y.ToString());
return point;