Exemplo n.º 1
0
 internal void Split() //进行切分
 {
     if (earthmanager.earthpara.SceneMode == ESceneMode.地球)
     {
         addNewSub(this.idxx * 2, this.idxy * 2);
         addNewSub(this.idxx * 2 + 1, this.idxy * 2);
         addNewSub(this.idxx * 2, this.idxy * 2 + 1);
         addNewSub(this.idxx * 2 + 1, this.idxy * 2 + 1);
     }
     else if (earthmanager.earthpara.SceneMode == ESceneMode.局部平面)
     {
         if (layer + 1 <= earthmanager.earthpara.StartLayer) //小于初始层设置时的判断
         {
             Rect orgrect = new Rect(earthmanager.earthpara.StartLocation.Longitude, earthmanager.earthpara.StartLocation.Latitude, earthmanager.earthpara.EndLocation.Longitude - earthmanager.earthpara.StartLocation.Longitude, earthmanager.earthpara.EndLocation.Latitude - earthmanager.earthpara.StartLocation.Latitude);
             Rect tmp     = Helpler.GetTileJW(layer + 1, idxx * 2, idxy * 2);
             if (tmp.IntersectsWith(orgrect))
             {
                 addNewSub(this.idxx * 2, this.idxy * 2);
             }
             tmp = Helpler.GetTileJW(layer + 1, idxx * 2 + 1, idxy * 2);
             if (tmp.IntersectsWith(orgrect))
             {
                 addNewSub(this.idxx * 2 + 1, this.idxy * 2);
             }
             tmp = Helpler.GetTileJW(layer + 1, idxx * 2, idxy * 2 + 1);
             if (tmp.IntersectsWith(orgrect))
             {
                 addNewSub(this.idxx * 2, this.idxy * 2 + 1);
             }
             tmp = Helpler.GetTileJW(layer + 1, idxx * 2 + 1, idxy * 2 + 1);
             if (tmp.IntersectsWith(orgrect))
             {
                 addNewSub(this.idxx * 2 + 1, this.idxy * 2 + 1);
             }
         }
         else
         {
             addNewSub(this.idxx * 2, this.idxy * 2);
             addNewSub(this.idxx * 2 + 1, this.idxy * 2);
             addNewSub(this.idxx * 2, this.idxy * 2 + 1);
             addNewSub(this.idxx * 2 + 1, this.idxy * 2 + 1);
         }
     }
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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);
            }
        }