예제 #1
0
        static void Get_TileBBox(double lat1, double lon1, double lat2, double lon2, int level)
        {
            int pixelX1, pixelY1, pixelX2, pixelY2;
            int tileX1, tileY1, tileX2, tileY2;

            TileSystem.LatLongToPixelXY(lat1, lon1, level, out pixelX1, out pixelY1);
            TileSystem.LatLongToPixelXY(lat2, lon2, level, out pixelX2, out pixelY2);
            TileSystem.PixelXYToTileXY(pixelX1, pixelY1, out tileX1, out tileY1);
            TileSystem.PixelXYToTileXY(pixelX2, pixelY2, out tileX2, out tileY2);


            TileSystem.TileXYToPixelXY(tileX1, tileY1, out pixelX1, out pixelY1);
            TileSystem.TileXYToPixelXY(tileX2 + 1, tileY2 + 1, out pixelX2, out pixelY2);


            double olat1, olon1, olat2, olon2;

            TileSystem.PixelXYToLatLong(pixelX1, pixelY1, level, out olat1, out olon1);
            TileSystem.PixelXYToLatLong(pixelX2, pixelY2, level, out olat2, out olon2);

            Console.WriteLine(olon1 + "," + olat1);
            Console.WriteLine(olon2 + "," + olat2);
        }
예제 #2
0
        static void Download_sateimg(double lat1, double lon1, double lat2, double lon2, int level)
        {
            int pixelX1, pixelY1, pixelX2, pixelY2;

            Get_TileBBox(lat1, lon1, lat2, lon2, level);

            outputPath = outputPath + "_" + lat1 + "_" + lon1 + "_" + lat2 + "_" + lon2;
            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }
            TileSystem.LatLongToPixelXY(lat1, lon1, level, out pixelX1, out pixelY1);
            TileSystem.LatLongToPixelXY(lat2, lon2, level, out pixelX2, out pixelY2);
            int tileX1, tileY1, tileX2, tileY2;

            TileSystem.PixelXYToTileXY(pixelX1, pixelY1, out tileX1, out tileY1);
            TileSystem.PixelXYToTileXY(pixelX2, pixelY2, out tileX2, out tileY2);

            for (int i = tileX1; i < tileX2; i++)
            {
                for (int j = tileY1; j < tileY2; j++)
                {
                    try
                    {
                        string quadKey = TileSystem.TileXYToQuadKey(i, j, level);
                        Download(quadKey);
                        int pixelX, pixelY;
                        TileSystem.TileXYToPixelXY(i, j, out pixelX, out pixelY);
                        Console.WriteLine(quadKey + " " + i + " " + j + " " + pixelX + " " + pixelY);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
        }