public void Test18()
 {
     SphericalTileMath.LatLongToPixelXY(testLatitude, testLongitude, 18, out testX, out testY);
     Assert.True(testX == 42481857 && testY == 20685094);
     testTile = TileMathBase.PixelXY2TileXY(testX, testY);
     Assert.True(testTile.X == 165944 && testTile.Y == 80801);
 }
 public void Test19()
 {
     SphericalTileMath.LatLongToPixelXY(testLatitude, testLongitude, 19, out testX, out testY);
     Assert.True(testX == 84963713 && testY == 41370188);
     testTile = TileMathBase.PixelXY2TileXY(testX, testY);
     Assert.True(testTile.X == 331889 && testTile.Y == 161602);
 }
 public void Test3()
 {
     SphericalTileMath.LatLongToPixelXY(testLatitude, testLongitude, 3, out testX, out testY);
     Assert.True(testX == 1296 && testY == 631);
     testTile = TileMathBase.PixelXY2TileXY(testX, testY);
     Assert.True(testTile.X == 5 && testTile.Y == 2);
 }
 public void Test4()
 {
     SphericalTileMath.LatLongToPixelXY(testLatitude, testLongitude, 4, out testX, out testY);
     Assert.True(testX == 2593 && testY == 1263);
     testTile = TileMathBase.PixelXY2TileXY(testX, testY);
     Assert.True(testTile.X == 10 && testTile.Y == 4);
 }
 public void Test2()
 {
     SphericalTileMath.LatLongToPixelXY(testLatitude, testLongitude, 2, out testX, out testY);
     Assert.True(testX == 648 && testY == 316);
     testTile = TileMathBase.PixelXY2TileXY(testX, testY);
     Assert.True(testTile.X == 2 && testTile.Y == 1);
 }
 public void Test1()
 {
     SphericalTileMath.LatLongToPixelXY(testLatitude, testLongitude, 1, out testX, out testY);
     Assert.True(testX == 324 && testY == 158);
     testTile = TileMathBase.PixelXY2TileXY(testX, testY);
     Assert.True(testTile.X == 1 && testTile.Y == 0);
 }
Exemple #7
0
        public TileReplace TileFromWgs84ToSpherical(int wgs84TileIndexX, int wgs84TileIndexY, int zoom)
        {
            var leftTop = TileMathBase.TileXY2PixelXY(wgs84TileIndexX, wgs84TileIndexY);
            var latlon  = Wgs84TileMath.PixelXYToLatLong(leftTop.X, leftTop.Y, zoom);

            SphericalTileMath.LatLongToPixelXY(latlon.X, latlon.Y, zoom, out int pixelX, out int pixelY);
            return(FindReplace(wgs84TileIndexX, wgs84TileIndexY, zoom, new Point(pixelX, pixelY)));
        }
Exemple #8
0
        public TileReplace TileFromSphericalToWgs84(int sphericalTileIndexX, int sphericalTileIndexY, int zoom)
        {
            var leftTop = TileMathBase.TileXY2PixelXY(sphericalTileIndexX, sphericalTileIndexY);

            SphericalTileMath.PixelXYToLatLong(leftTop.X, leftTop.Y, zoom, out double latitude, out double longitude);
            var resultXY = Wgs84TileMath.LatLongToPixelXY(latitude, longitude, zoom);

            return(FindReplace(sphericalTileIndexX, sphericalTileIndexY, zoom, resultXY));
        }
Exemple #9
0
        private TileReplace FindReplace(int sphericalTileIndexX, int sphericalTileIndexY, int zoom, Point resultXY)
        {
            var tileXYindex = TileMathBase.PixelXY2TileXY(resultXY.X, resultXY.Y);

            var xShift = resultXY.X % TileMathBase.TileSize;
            var yShift = resultXY.Y % TileMathBase.TileSize;

            if (xShift == 0 && yShift == 0)
            {
                //just copy.
                var result1 = new TileReplace(tileXYindex.X, tileXYindex.Y, zoom);
                result1.NeedTileIndex.Add(new Point(sphericalTileIndexX, sphericalTileIndexY));
                result1.Shift = new Point(0, 0);
                return(result1);
            }
            else if (xShift == 0 && yShift != 0)
            {
                //can try to create Y+1 tile.
                var result2 = new TileReplace(tileXYindex.X, tileXYindex.Y + 1, zoom);
                result2.NeedTileIndex.Add(new Point(sphericalTileIndexX, sphericalTileIndexY));
                result2.NeedTileIndex.Add(new Point(sphericalTileIndexX, sphericalTileIndexY + 1));
                result2.Shift = new Point(0, yShift);
                return(result2);
            }
            else
            {
                //need 4 tiles to create a one new.
                var result3 = new TileReplace(tileXYindex.X + 1, tileXYindex.Y + 1, zoom);
                result3.NeedTileIndex.Add(new Point(sphericalTileIndexX, sphericalTileIndexY));
                result3.NeedTileIndex.Add(new Point(sphericalTileIndexX, sphericalTileIndexY + 1));
                result3.NeedTileIndex.Add(new Point(sphericalTileIndexX + 1, sphericalTileIndexY));
                result3.NeedTileIndex.Add(new Point(sphericalTileIndexX + 1, sphericalTileIndexY + 1));
                result3.Shift = new Point(xShift, yShift);
                return(result3);
            }
        }