GeoTileCover 1.0.0

dotnet add package GeoTileCover --version 1.0.0
                    
NuGet\Install-Package GeoTileCover -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GeoTileCover" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GeoTileCover" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="GeoTileCover" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GeoTileCover --version 1.0.0
                    
#r "nuget: GeoTileCover, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GeoTileCover@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GeoTileCover&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=GeoTileCover&version=1.0.0
                    
Install as a Cake Tool

GeoTileCover

Find the Web Mercator XYZ tiles covered by a NetTopologySuite geometry or a set of existing tiles. Supports points, lines, polygons, multi-geometries, and geometry collections at zooms 0–25.

Installation

dotnet add package GeoTileCover

Quick start

Use WGS84 coordinates in longitude, latitude order.

using System;
using System.Threading;
using GeoTileCover;
using NetTopologySuite.Geometries;

var geometry = new GeometryFactory().CreatePoint(new Coordinate(105.8342, 21.0278));
var cover = new TileCover(geometry);

foreach (var tile in cover.GetTiles(10))
{
    Console.WriteLine(tile); // 10/813/450
}

Each TileId has Z (zoom), X (column, increasing eastward), and Y (row, increasing southward). The examples below reuse cover.

A TileCover snapshots its input. Later changes to the source geometry or tile collection have no effect. Reuse the instance to benefit from cached results.

Methods

Method Result
GetTiles(zoom) All covered tiles at one zoom.
GetTiles(minZoom, maxZoom) Covered tiles at every zoom in the inclusive range.
TryGetTiles(zoom, maxTiles, out tiles, cancellationToken) Complete coverage at one zoom if it fits the limit; the cancellation token is optional.
GetMinimalTiles(minZoom, maxZoom) The smallest mixed-zoom set preserving coverage at maxZoom.

Results are deduplicated and ordered by Z, then Y, then X. Zoom ranges must satisfy TileCover.MinZoom <= minZoom <= maxZoom <= TileCover.MaxZoom (currently 0–25). Returned arrays can be modified without affecting later results.

GetTiles computes the complete result before returning and has no tile-count limit. LINQ Take() does not limit that work; use TryGetTiles for large or unpredictable inputs.

Bounded results

using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(5));

if (cover.TryGetTiles(12, maxTiles: 100_000, out var tiles, cancellationToken: cancellation.Token))
{
    Console.WriteLine($"Covered tiles: {tiles.Length}");
}
else
{
    Console.WriteLine("The cover exceeds 100,000 tiles.");
}

true returns the complete result; false returns an empty array when the limit is exceeded. maxTiles must be nonnegative; zero accepts only an empty cover. The limit also applies to cached results.

Cancellation throws OperationCanceledException. It is cooperative and cannot interrupt an individual NetTopologySuite operation, so a deadline is not a hard timeout. The tile limit does not bound geometry complexity or total computation time.

Minimal cover

TileId[] minimal = cover.GetMinimalTiles(minZoom: 10, maxZoom: 12);

Complete groups of four siblings are replaced by their parent, stopping at minZoom. For example, 2/0/0, 2/1/0, 2/0/1, and 2/1/1 reduce to 1/0/0 if zoom 1 is allowed.

Expanding the result to maxZoom reproduces GetTiles(maxZoom). This preserves coverage at that tile resolution; a single point remains a tile at maxZoom. This method has no tile-count limit or cancellation parameter.

Existing tiles

Pass an IEnumerable<TileId> to cover the union of complete tile areas. Inputs may mix zoom levels, overlap, or repeat.

var restored = new TileCover(new[] { new TileId(1, 0, 0), new TileId(2, 2, 0) });

var zoom2Tiles = restored.GetTiles(2); // Four children of 1/0/0, plus 2/2/0: five tiles.
var compactTiles = restored.GetMinimalTiles(0, 2); // 1/0/0 and 2/2/0.

Finer zooms include all descendants of source tiles; coarser zooms include their ancestors.

TileId

An immutable value type with equality based on Z, X, and Y, suitable for dictionary keys and sets.

var tileId = new TileId(10, 813, 450);

long id = tileId.Id;                   // Unique 64-bit ID including zoom.
int packedXY = tileId.PackedXY;        // Unique within a zoom level.
string xyz = tileId.ToString();        // "10/813/450"
TileId parent = tileId.Parent();       // 9/406/225
Envelope bounds = tileId.ToEnvelope(); // Geographic bounds in degrees.

TileId fromId = new TileId(id);        // Same tile.

ToEnvelope() returns bounds in degrees: MinX/MaxX are west/east longitudes and MinY/MaxY are south/north latitudes. Parent() throws InvalidOperationException at zoom 0.

Id is a stable, unique 64-bit identifier across supported zooms. Use it for storage; GetHashCode() is for in-memory collections. For JSON clients without exact 64-bit integer support, send Id as a string or send Z, X, and Y.

PackedXY stores X/Y in an int for zooms 0–16 (TileId.PackedXYMaxZoom). It is unique within a zoom level, but values can repeat across zooms. Store the pair (z, packedXY) and restore with new TileId(z, packedXY). Negative values are valid at zoom 16. Above zoom 16, TryGetPackedXY(out var packedXY) returns false, while PackedXY throws InvalidOperationException.

Input rules

  • Coordinates: X = longitude, Y = latitude, in degrees. SRID must be 0 (interpreted as WGS84) or 4326. Coordinates are not reprojected.
  • Bounds: coordinates must be finite; longitude within −180° to 180°, latitude within ±85.0511287798066°. Out-of-range coordinates are rejected.
  • Antimeridian: split crossings first. Segments with a longitude change greater than 180° throw NotSupportedException.
  • Topology: the caller supplies valid geometry. The library does not validate or repair topology; geometry-operation exceptions may propagate. Use NetTopologySuite's IsValid or IsValidOp when validation is needed.
  • Empty/null: empty geometries and tile collections return no tiles; null inputs are rejected.

Boundaries

  • Points and lines on internal edges belong to the eastern or southern tile. A point at an internal corner belongs to the southeastern tile.
  • A polygon boundary or line endpoint merely touching a neighboring tile does not include it.
  • Outer world boundaries belong to the outermost tiles, including longitude 180° and the southern latitude limit.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 86 9/29/2026
0.1.0-preview.2 121 9/14/2026
0.1.0-preview.1 94 8/18/2026