//计算总的瓦片数
        private void initTask(int zoomIndex)
        {
            mZ = zoomIndex;

            mLeftBottomTile = MapTool.lngLatToTile(mLeftBottomPoint.lng, mLeftBottomPoint.lat, mZoomArray[mZ]);
            mRightTopTile   = MapTool.lngLatToTile(mrightTopPoint.lng, mrightTopPoint.lat, mZoomArray[mZ]);

            mX = mLeftBottomTile.x;
            mY = mLeftBottomTile.y;
        }
Beispiel #2
0
        static public PointF lngLatToPoint(double lng, double lat)
        {
            PointGeo pt = new PointGeo();

            pt.lng = MapTool.ft(lng, -180, 180);  // lng: 120.26007
            pt.lat = MapTool.lt(lat, -74, 74);    // lat: 31.554487


            //b = new F(a.lng, a.lat);            // b: lat: 31.554487  lng: 120.26007

            double[] c = null;
            //北纬
            for (int d = 0; d < MapTool.Wm.Length; d++)
            {
                if (pt.lat >= MapTool.Wm[d])
                {
                    // Wm: [75, 60, 45, 30, 15, 0] (常量)
                    c = MapTool.bv[d];                 // bv: 10*6的二维数组(常量)
                    break;
                }
            }

            //南纬
            if (c == null || c.Length <= 0)
            {
                for (int d = MapTool.Wm.Length - 1; 0 <= d; d--)
                {
                    if (pt.lat <= -MapTool.Wm[d])
                    {
                        c = MapTool.bv[d];
                        break;
                    }
                }
            }

            PointF fpt = MapTool.Sx(pt, c); //a:  lat: 31.554487   lng: 120.26007,   c = this.bv[d];  (d = 3)

            return(new PointF(Convert.ToDouble(fpt.x.ToString("0.00")), Convert.ToDouble(fpt.y.ToString("0.00"))));
            //DecimalFormat df = new DecimalFormat("#.00");
            //return new PointF(Double.parseDouble(df.format(fpt.x)), Double.parseDouble(df.format(fpt.y))); // a: lat: 3682405.23  lng: 13387435.42
        }