Soenneker.Dtos.Coordinates
11.0.27
Prefix Reserved
dotnet add package Soenneker.Dtos.Coordinates --version 11.0.27
NuGet\Install-Package Soenneker.Dtos.Coordinates -Version 11.0.27
<PackageReference Include="Soenneker.Dtos.Coordinates" Version="11.0.27" />
<PackageVersion Include="Soenneker.Dtos.Coordinates" Version="11.0.27" />
<PackageReference Include="Soenneker.Dtos.Coordinates" />
paket add Soenneker.Dtos.Coordinates --version 11.0.27
#r "nuget: Soenneker.Dtos.Coordinates, 11.0.27"
#:package Soenneker.Dtos.Coordinates@11.0.27
#addin nuget:?package=Soenneker.Dtos.Coordinates&version=11.0.27
#tool nuget:?package=Soenneker.Dtos.Coordinates&version=11.0.27
Soenneker.Dtos.Coordinates
Defines an immutable WGS84 latitude/longitude value with JSON mapping, bounds inspection, and invariant formatting.
Installation
dotnet add package Soenneker.Dtos.Coordinates
Usage
using Soenneker.Dtos.Coordinates;
var chicago = new Coordinate(
latitude: 41.8781,
longitude: -87.6298);
if (!chicago.IsValid)
{
throw new InvalidOperationException("Coordinate is outside WGS84 bounds.");
}
string text = chicago.ToString(); // 41.8781, -87.6298
Constructor and formatted output order is latitude first, longitude second. GeoJSON coordinate arrays use longitude first, so swap deliberately when adapting to or from GeoJSON.
Validation
IsValid is true when latitude is between -90 and 90 and longitude is between -180 and 180, inclusive. NaN and infinity are invalid. Construction and deserialization do not reject invalid values; inspect IsValid at the boundary where invalid coordinates must be refused.
default(Coordinate) represents 0, 0 and is valid. Do not use the default value as an “unset” sentinel; use Coordinate? when absence must be represented.
Serialization and formatting
System.Text.Json serializes the value as:
{
"latitude": 41.8781,
"longitude": -87.6298
}
IsValid is ignored by System.Text.Json.
ToString() always uses invariant culture and produces latitude, longitude. The ISpanFormattable overload applies the same numeric format and provider to both values:
string rounded = chicago.ToString("F2", CultureInfo.InvariantCulture);
// 41.88, -87.63
Span<char> buffer = stackalloc char[64];
bool formatted = chicago.TryFormat(buffer, out int written, "F4", CultureInfo.InvariantCulture);
When the destination is too small, TryFormat returns false and sets written to zero.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Dtos.Coordinates:
| Package | Downloads |
|---|---|
|
Soenneker.Geo.Coordinates
High-performance geographic coordinate utilities. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.27 | 143 | 11/18/2026 |
| 11.0.26 | 254 | 11/11/2026 |
| 11.0.25 | 400 | 10/26/2026 |
| 4.0.24 | 267 | 10/14/2026 |
| 4.0.23 | 120 | 10/14/2026 |
| 4.0.21 | 126 | 10/13/2026 |
| 4.0.18 | 107 | 10/12/2026 |
| 4.0.17 | 117 | 10/12/2026 |
| 4.0.16 | 134 | 10/11/2026 |
| 4.0.15 | 236 | 9/30/2026 |
| 4.0.14 | 157 | 9/24/2026 |
| 4.0.13 | 262 | 9/15/2026 |
| 4.0.12 | 181 | 9/12/2026 |
| 4.0.11 | 228 | 9/7/2026 |
| 4.0.10 | 234 | 8/30/2026 |
| 4.0.8 | 321 | 8/18/2026 |
| 4.0.7 | 365 | 7/27/2026 |
| 4.0.6 | 363 | 7/16/2026 |
| 4.0.5 | 568 | 6/19/2026 |
| 4.0.4 | 374 | 6/5/2026 |
Configure .NET CI defaults and daily source scans