adunlap

Project Issue after Passing Military Grid System into Ipoint

Discussion created by adunlap on Sep 19, 2013
Latest reply on Sep 20, 2013 by adunlap
Hi all,

I'm using ArcGIS Server 10.0 sp5 .NET WebADF and NITK toolkit.  I made a simple button to zoom to MGRS coordinates and would like the resulting X & Y values in UTM WGS84 14.  Executing PutCoordsFromMGRS (from the IConversionMGRS class) always returns a Lat/Long for a X,Y value.

When I go to project the value back to UTM WGS84 14N, I get no change....what am I missing?

private void ZoomToMGRSCoordinate(string MGRSValue)
        {
            //We finally get to start the conversion of MGRS to Points

            IServerContext serverContext = null;
            GISServerConnection serverConnection = new GISServerConnection();
            serverConnection.Connect("LocalHost");
            IServerObjectManager serverManager = serverConnection.ServerObjectManager;
            //Get GeometryServer Context
            serverContext = serverManager.CreateServerContext("Geometry",
                "GeometryServer");

            ISpatialReferenceFactory3 pSRF = serverContext.CreateObject(
                "esriGeometry.SpatialReferenceEnvironment") as ISpatialReferenceFactory3;

            ISpatialReference utmSpatialReference = pSRF.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_WGS1984UTM_14N);
            ISpatialReference ddSpatialReference = pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);

            ESRI.ArcGIS.Geometry.IPoint pnt = new PointClass();

            if (Map.PrimaryMapResource.ToString() == "FSC" || Map.PrimaryMapResource.ToString() == "FSR")
            {
              pnt.SpatialReference = ddSpatialReference;
              IConversionMGRS convertpnt = pnt as IConversionMGRS;
              convertpnt.PutCoordsFromMGRS(MGRSValue, esriMGRSModeEnum.esriMGRSMode_USNG);
           
              ESRI.ArcGIS.Geometry.IPoint pnt2 = new PointClass();
              pnt2.SpatialReference = ddSpatialReference;
              pnt2 = convertpnt as IPoint;
                
              pnt2.Project(utmSpatialReference);
              pnt2.SnapToSpatialReference();

              ESRI.ArcGIS.ADF.Web.Geometry.Point wpn = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Local.Converter.FromIPoint(pnt2)
             
              MapZoomer mapZoomer = new MapZoomer(Map, PointZoomFactor);
              mapZoomer.ZoomToGeometry(wpn);
              
           }

Outcomes