public void TestTileCreation() { // 51.27056&lon=4.78849 // http://tile.deltamedia.local/tile/16/33639/21862.png Tile tile = new Tile(33639, 21862, 16); Tile tile2 = Tile.CreateAroundLocation(tile.Box.Center, 16); Assert.AreEqual(tile.X, tile.X); Assert.AreEqual(tile.Y, tile.Y); Assert.AreEqual(tile.Zoom, tile.Zoom); }
public void TestTileBox() { Tile tile = new Tile(33639, 21862, 16); for (double longitude = tile.Box.MinLon; longitude < tile.Box.MaxLon; longitude = longitude + tile.Box.DeltaLon / 100) { for (double latitude = tile.Box.MinLat; latitude < tile.Box.MaxLat; latitude = latitude + tile.Box.DeltaLon / 100) { Tile tile2 = Tile.CreateAroundLocation(new GeoCoordinate( latitude, longitude), tile.Zoom); Assert.AreEqual(tile.X, tile.X); Assert.AreEqual(tile.Y, tile.Y); Assert.AreEqual(tile.Zoom, tile.Zoom); } } }
public string Get(DataOperation request) { try { // parse the zoom, x and y. int x, y, zoom; if (!int.TryParse(request.X, out x)) { // invalid x. throw new InvalidCastException("Cannot parse x-coordinate!"); } if (!int.TryParse(request.Y, out y)) { // invalid y. throw new InvalidCastException("Cannot parse y-coordinate!"); } if (!int.TryParse(request.Zoom, out zoom)) { // invalid zoom. throw new InvalidCastException("Cannot parse zoom!"); } // create the filter. var tile = new Tile(x, y, zoom); // invert the y-coordinate, system of HOT-tasking manager is inverted. tile = tile.InvertY(); // execute the request. return (new DataService()).RequestData(request.File, tile.Box); } catch (Exception ex) { base.Response.StatusCode = (int)HttpStatusCode.BadRequest; return string.Empty; } }