Example #1
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);
            }
        }
Example #2
0
 ///<summary>获取指定经纬高的点在三维场景中的坐标</summary>
 public VECTOR3D getScene3DCoordinate(double jd, double wd, double hd)
 {
     return(MapHelper.JWHToPoint(jd, wd, hd, earth.earthManager.earthpara));
 }