Пример #1
0
        private void TryConvertGeoCoord2PrjCoord(Feature fet)
        {
            /*
             * 1.调用地图服务中的坐标转换接口进行地理坐标到投影坐标的转换
             * 2.在异步转换事件中,生成XamlObject,往画布中添加
             */
            GeoShape geometry = fet.Geometry;

            if (fet.Geometry == null)
            {
                return;
            }
            IProjectableArguments arguments = fet.Geometry as IProjectableArguments;

            if (arguments == null)
            {
                throw new NotImplementedException("几何类型\"" + geometry.GetType().ToString() + "\"未实现IProjectableArguments,无法进行投影转换。");
            }
            //
            if ((arguments.Points == null && arguments.Points.Length == 0) &&
                (arguments.SingleValues == null && arguments.SingleValues.Length == 0))
            {
                return;
            }
            List <AgileMapServiceProxy.PointF> points = new List <AgileMapServiceProxy.PointF>();

            if (arguments.Points != null)
            {
                foreach (GeoPoint pt in arguments.Points)
                {
                    AgileMapServiceProxy.PointF ptf = new AgileMapServiceProxy.PointF();
                    ptf.x = (float)pt.X;
                    ptf.y = (float)pt.Y;
                    points.Add(ptf);
                }
            }
            int valueCount = 0;

            if (arguments.SingleValues != null)
            {
                valueCount = arguments.SingleValues.Length;
                foreach (double v in arguments.SingleValues)
                {
                    AgileMapServiceProxy.PointF ptf = new AgileMapServiceProxy.PointF();
                    ptf.x = (float)v;
                    ptf.y = 0;
                    points.Add(ptf);
                }
            }
            //
            _map.ServerAgent.MapServiceClient.Geo2PrjAsync(new ObservableCollection <AgileMapServiceProxy.PointF>(points),
                                                           new FeatureUserState(fet, Id));
        }