Select to view content in your preferred language

?oordinate transformation in Silverlight API

862
5
03-17-2014 12:34 AM
AnatoliiTerentiev
Deactivated User
Dear Gurus!
Can't anybody say how to transformate X,Y  of the point to lon,lat value?
I have previously used (when working with arcgis engine)   ESRI.ArcGIS.Geometry primitives as follows:
        private void initPcsGcs()
        {
            ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
            // GCS to project from 
            ISpatialReference gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
            ISpatialReference pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_Pulkovo1942GK_6);


            sr1 = gcs;
            sr1.SetFalseOriginAndUnits(-180, -90, 1000000);
            //Projected Coordinate System to project into
            pcs.SetFalseOriginAndUnits(0, 0, 1000);
            sr2 = pcs;
        } 

        public void LonLatToXY(double lon, double lat, out double X, out double Y)
        {

            initPcsGcs();
            IPoint point = new PointClass() as IPoint;
            point.PutCoords(lon, lat);
            IGeometry geometry;
            geometry = point;
            geometry.SpatialReference = sr1;
            geometry.Project(sr2);
            point = geometry as IPoint;
            point.QueryCoords(out X, out Y);
        }

        public bool xyTOlonLat(double X, double Y, out double lon, out double lat)
        {

            ISpatialReferenceFactory srFactory;


            srFactory = new SpatialReferenceEnvironmentClass();
            IGeographicCoordinateSystem gcs;
            IProjectedCoordinateSystem pcs;

            gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
            pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_Pulkovo1942GK_6);

            IPoint point = new PointClass() as IPoint;
            point.PutCoords(X, Y);
            IGeometry geometry;
            geometry = point;
            geometry.SpatialReference = sr2;

            geometry.Project(sr1);
            point = geometry as IPoint;

            point.QueryCoords(out lon, out lat);
            return true;
        }
0 Kudos
5 Replies
AnatoliiTerentiev
Deactivated User
X,Y coordinate in 

EPSG:28406

Pulkovo 1942 / Gauss-Kruger zone 6
0 Kudos
AhmedEl-Sisi
Deactivated User
You should use Geometry service for coordinate transformation.
0 Kudos
AnatoliiTerentiev
Deactivated User
Thank you very much! But now  I am wondering how to do it in the intranet? Do I need to write my own service?
0 Kudos
AhmedEl-Sisi
Deactivated User
If you have access to ArcGIS Server in your network you should have a Geometry Service.
If not, you can write your Arcobjects code inside a web service and consume it in your silverlight Application.
0 Kudos
AnatoliiTerentiev
Deactivated User
Yes, I see, thank you very much!
0 Kudos