Ejemplo n.º 1
0
        ///<summary>动画移动相机查看指定位置, 按经纬坐标, timerFactor: 速度系数, 为0则无动画直接刷新</summary>
        public void aniLookGeo(double yjd, double xwd, double gd, double speedFactor = 1)
        {
            Vector3 tmp = Helpler.JWHToPoint(yjd, xwd, gd, earth.earthManager.earthpara);

            aniLook(new VECTOR3D(tmp.X, tmp.Y, tmp.Z), speedFactor);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 自动调整相机距离以显示指定范围
        /// </summary>
        public void adjustCameraRange(System.Windows.Rect rect)
        {
            double minjd, maxjd, minwd, maxwd;

            minwd = rect.Left; maxwd = rect.Right; minjd = rect.Top; maxjd = rect.Bottom;
            List <VECTOR3D> corners = new List <VECTOR3D>();
            VECTOR3D        lefttop, righttop, leftbottom, rightbottom, center;

            System.Windows.Media.Media3D.Vector3D lt, rt, lb, rb;
            lefttop     = MapHelper.JWHToPoint(minjd, maxwd, 0, earth.earthManager.earthpara); corners.Add(lefttop); lt = Helpler.vecD3DToWpf(lefttop);
            righttop    = MapHelper.JWHToPoint(maxjd, maxwd, 0, earth.earthManager.earthpara); corners.Add(righttop); rt = Helpler.vecD3DToWpf(righttop);
            leftbottom  = MapHelper.JWHToPoint(minjd, minwd, 0, earth.earthManager.earthpara); corners.Add(leftbottom); lb = Helpler.vecD3DToWpf(leftbottom);
            rightbottom = MapHelper.JWHToPoint(maxjd, minwd, 0, earth.earthManager.earthpara); corners.Add(rightbottom); rb = Helpler.vecD3DToWpf(rightbottom);
            System.Windows.Media.Media3D.Vector3D cent = new System.Windows.Media.Media3D.Vector3D((corners.Max(p => p.x) + corners.Min(p => p.x)) / 2, (corners.Max(p => p.y) + corners.Min(p => p.y)) / 2, (corners.Max(p => p.z) + corners.Min(p => p.z)) / 2);
            if (earth.earthManager.earthpara.SceneMode == ESceneMode.地球)
            {
                cent   = cent * Para.Radius / cent.Length;
                center = new VECTOR3D(cent.X, cent.Y, cent.Z);
            }
            else  //zh注:还未验证
            {
                center = new VECTOR3D(cent.X, cent.Y, 0);
            }
            double width, height;

            width  = Math.Max((rt - lt).Length, (rb - lb).Length) * 1.5;
            height = Math.Max((lb - lt).Length, (rb - rt).Length) * 1.5;
            double distance;

            if (width / height > earth.global.ScreenWidth / earth.global.ScreenHeight) //以宽度来计算
            {
                distance = width * earth.global.ScreenHeight / earth.global.ScreenWidth / 2 / Math.Atan(FieldOfView / 2);
            }
            else //以高度来计算
            {
                distance = height / 2 / Math.Atan(FieldOfView / 2);
            }

            aniLook(center);
            adjustCameraDistance((float)distance);
        }
Ejemplo n.º 3
0
 ///<summary>计算获得指定层和指定纬度序号的块高度</summary>
 internal double getTileWidth(int layer, int idxy)
 {
     System.Windows.Rect rect12 = Helpler.GetTileJW(12, 0, 0);
     System.Windows.Rect rect   = Helpler.GetTileJW(layer, 0, idxy);
     return(rect.Height / rect12.Height);
 }
Ejemplo n.º 4
0
 public void setBackground(System.Windows.Media.Color color)
 {
     background = Helpler.ColorToUInt(color);
 }
Ejemplo n.º 5
0
        ///<summary>计算局部平面场景模式下的相关参数,设置相关参数后调用</summary>
        public void calPlaneModePara()
        {
            if (tileReadMode == ETileReadMode.内置瓦片服务 || tileReadMode == ETileReadMode.自定义Web瓦片)
            {
                //计算最合适的对应层,再加2层作为起始层
                double minjd = StartLocation.Longitude;
                double minwd = StartLocation.Latitude;
                double maxjd = EndLocation.Longitude;
                double maxwd = EndLocation.Latitude;
                double spanjd = maxjd - minjd;
                double spanwd = maxwd - minwd;
                int    ycount; double angle, tileLength, xStart, xEnd, yStart, yEnd;
                int    si = 0; double cz = double.PositiveInfinity;
                for (int i = 0; i < 18; i++)
                {
                    int idxx = 0; int idxy = 0;
                    ycount     = (int)Math.Pow(2, i);
                    angle      = MapHelper.DegToRad(360.0 / ycount);
                    tileLength = 2.0 * Math.PI / Math.Pow(2, i);                                                             //2*pi/power(2,layer)  假定半径为1, 平面地图坐标系下该层划分块的长和宽度
                    xStart     = (idxx * angle - Math.PI) / Math.PI * 180;                                                   //  指定索引号块的起始经度
                    xEnd       = ((idxx + 1) * angle - Math.PI) / Math.PI * 180;                                             //  指定索引号块的起始经度
                    yStart     = (Math.Atan(Math.Exp(Math.PI - (idxy + 1) * tileLength)) * 2 - Math.PI / 2) / Math.PI * 180; //指定索引号块的结束纬度
                    yEnd       = (Math.Atan(Math.Exp(Math.PI - idxy * tileLength)) * 2 - Math.PI / 2) / Math.PI * 180;       //atan(exp(PI-idxy*2*pi/power(2,layer)))*2-pi/2  指定索引号块的起始纬度
                    double tmp = Math.Abs(xEnd - xStart - spanjd) + Math.Abs(yStart - yEnd - spanwd);
                    if (tmp < cz)
                    {
                        cz = tmp; si = i;
                    }
                }
                StartLayer = si + 2;

                //计算合适的瓦片序号
                ycount     = (int)Math.Pow(2, StartLayer);
                angle      = MapHelper.DegToRad(360.0 / ycount);
                StartIdxX  = (int)((minjd / 180 * Math.PI + Math.PI) / angle);
                tileLength = 2.0 * Math.PI / Math.Pow(2, StartLayer); //2*pi/power(2,layer)  假定半径为1, 平面地图坐标系下该层划分块的长和宽度
                StartIdxY  = (int)((Math.PI - Math.Log(Math.Tan((minwd / 180 * Math.PI + Math.PI / 2) / 2))) / tileLength);

                EndIdxX    = (int)((maxjd / 180 * Math.PI + Math.PI) / angle);
                tileLength = 2.0 * Math.PI / Math.Pow(2, StartLayer); //2*pi/power(2,layer)  假定半径为1, 平面地图坐标系下该层划分块的长和宽度
                EndIdxY    = (int)((Math.PI - Math.Log(Math.Tan((maxwd / 180 * Math.PI + Math.PI / 2) / 2))) / tileLength);
                //计算新的准确的起止经纬
                System.Windows.Rect tmprect = Helpler.GetTileJW(StartLayer, StartIdxX, StartIdxY);
                StartLocation = new GeoPoint(tmprect.Bottom, tmprect.Left);
                tmprect       = Helpler.GetTileJW(StartLayer, EndIdxX, EndIdxY);
                EndLocation   = new GeoPoint(tmprect.Top, tmprect.Right);

                //以12,0,赤道为基准计算单位转换坐标
                System.Windows.Rect rect12 = Helpler.GetTileJW(12, 0, (int)Math.Pow(2, 11));
                UnitLongLen = 1 / rect12.Width;
                UnitLatLen  = 1 / rect12.Height * AdjustAspect;
            }
            else  //自定义瓦片
            {
                StartLayer  = 0;
                StartIdxX   = 0;
                StartIdxY   = 0;
                EndIdxX     = 1;
                EndIdxY     = 1;
                UnitLatLen  = 100 / (EndLocation.Latitude - StartLocation.Latitude);
                UnitLongLen = 100 / (EndLocation.Longitude - StartLocation.Longitude);
            }
        }