Преобразование координат в arcgis silverlight API

ArcGIS 8.x,9.x,10.x (Arcview, ArcEditor, Arcinfo).
Ответить
Tereha
Завсегдатай
Сообщения: 423
Зарегистрирован: 15 май 2010, 06:13
Репутация: 7

Преобразование координат в arcgis silverlight API

Сообщение Tereha » 17 мар 2014, 11:40

Уважаемые Гуру!
Возможно кто-то подскажет как преобразовать X,Y координаты в широту, долготу при использовании silverlight API.
Ранее, когда я работал в среде arcgis engine я использовал следующие процедуры:

Код: Выделить всё

        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 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;
        }

Код: Выделить всё

        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);
        }

Tereha
Завсегдатай
Сообщения: 423
Зарегистрирован: 15 май 2010, 06:13
Репутация: 7

Re: Преобразование координат в arcgis silverlight API

Сообщение Tereha » 17 мар 2014, 14:09

Геодезическая СК - Pulkovo 1942 zone 6

Tereha
Завсегдатай
Сообщения: 423
Зарегистрирован: 15 май 2010, 06:13
Репутация: 7

Re: Преобразование координат в arcgis silverlight API

Сообщение Tereha » 18 мар 2014, 10:45

С помощью сервиса геометрии arcgisonline.com - работает такой код:

Код: Выделить всё

        public void LonLatToXY()
        {

            geometryService = new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.ProjectCompleted += geometryService_ProjectCompleted;
            geometryService.Failed += geometryService_Failed;

            MapPoint inputMapPoint = new MapPoint(34.36, 61.78, new SpatialReference(4326));

            geometryService.ProjectAsync(new List<Graphic>() { new Graphic() { Geometry = inputMapPoint } }, new SpatialReference(28406), inputMapPoint);


        }

        void geometryService_ProjectCompleted(object sender, GraphicsEventArgs e)
        {
            double x, y;
            Graphic resultGraphic = e.Results[0];

            if (resultGraphic.Geometry.Extent != null)
            {
                MapPoint resultMapPoint = resultGraphic.Geometry as MapPoint;
                x = resultMapPoint.X;
                y = resultMapPoint.Y;
                messageBox.Show("x = "+x.toString()+ "  y = "+ y.toString());

            }
            else
            {
                MessageBox.Show("Invalid input coordinate, unable to project.");
            }

        }

        void geometryService_Failed(object sender, TaskFailedEventArgs e)
        {
            MessageBox.Show("Geometry Service error: " + e.Error);
        }
А вот если без доступа к сервису ESRI, то, возможно, нужно написать свой сервис.

Ответить

Вернуться в «ArcGIS»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 3 гостя