Skip to content

Commit

Permalink
Added try at location.
Browse files Browse the repository at this point in the history
  • Loading branch information
xivk committed Jul 27, 2023
1 parent dbfe45f commit 23c97ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/TilesMath/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private Tile(int x, int y, byte zoom)
/// <summary>
/// The tile boundaries.
/// </summary>
public TileBounds Boundaries => TileGeo.BoundariesFor(this);

public TileBounds Boundaries => TileGeo.BoundariesFor(this);

/// <summary>
/// The neighbours.
/// </summary>
Expand Down Expand Up @@ -161,8 +161,24 @@ public static Tile AtLocation(double longitude, double latitude, int zoom)
return new Tile(x, y, (byte)zoom);
}

/// <summary>
/// Creates the tile at the given WGS84 coordinates and zoom level.
/// </summary>
/// <param name="longitude">The longitude.</param>
/// <param name="latitude">The latitude.</param>
/// <param name="zoom">The zoom-level.</param>
/// <returns>The tile at the given location and zoom level.</returns>
public static Tile? TryAtLocation(double longitude, double latitude, int zoom)
{
var result = TileGeo.TryForLocation(longitude, latitude, zoom);
if (result == null) return null;

var (x, y) = result.Value;
return new Tile(x, y, (byte)zoom);
}

/// <summary>
/// Creates an empty tile.
/// </summary>
public static Tile Empty = new Tile(-1, -1, 0);
}
}
2 changes: 1 addition & 1 deletion src/TilesMath/TilesMath.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageVersion>0.0.3</PackageVersion>
<PackageVersion>0.0.4</PackageVersion>
<Title>TilesMath</Title>
<Authors>ANYWAYS BV</Authors>
<Description>A tiny library for tiles math.</Description>
Expand Down

0 comments on commit 23c97ba

Please sign in to comment.