Example #1
0
        private void makearea()
        {
            // 経度緯度を調べるには 地理院地図の白地図が便利
            LonLat point_st = new LonLat(0.00, 0.00);
            LonLat point_en = new LonLat(0.00, 0.00);

            for (int level = 2; level <= 16; level++)
            {
                Point tilepoint_st = lonlat2pix(point_st, level);
                Point tilepoint_en = lonlat2pix(point_en, level);

                tilepoint_en.X += 1;
                tilepoint_en.Y += 1;

                tileareas.Add(new TileArea(level, tilepoint_st, tilepoint_en));
            }

            return;
        }
Example #2
0
        private Point lonlat2pix(LonLat lonlat, int zoom_level)
        {
            // Lは緯度の描画上限
            const double L  = 85.05112878;
            Point        pt = new Point(0, 0);


            // lon:経度 lat:緯度
            // 緯度経度からピクセル座標に ref:http://www.trail-note.net/tech/coordinate/
            // 経度:longitude
            double px = Math.Pow(2, (zoom_level + 7)) * (lonlat.lon / 180 + 1);
            // 緯度:latitiude ※ Atanhはtanhの逆数
            double py = Math.Pow(2, (zoom_level + 7)) / Math.PI *
                        (-1 * Atanh(Math.Sin(Math.PI / 180 * lonlat.lat)) +
                         Atanh(Math.Sin(Math.PI / 180 * L)));

            // ピクセル座標からタイル座標を
            pt.Y = (int)(py / 256);
            pt.X = (int)(px / 256);


            return(pt);
        }