PolylineAlgorithm 1.0.58-preview.2161
This is a prerelease version of PolylineAlgorithm.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package PolylineAlgorithm --version 1.0.58-preview.2161
NuGet\Install-Package PolylineAlgorithm -Version 1.0.58-preview.2161
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="PolylineAlgorithm" Version="1.0.58-preview.2161" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PolylineAlgorithm" Version="1.0.58-preview.2161" />
<PackageReference Include="PolylineAlgorithm" />
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 PolylineAlgorithm --version 1.0.58-preview.2161
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PolylineAlgorithm, 1.0.58-preview.2161"
#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 PolylineAlgorithm@1.0.58-preview.2161
#: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=PolylineAlgorithm&version=1.0.58-preview.2161&prerelease
#tool nuget:?package=PolylineAlgorithm&version=1.0.58-preview.2161&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PolylineAlgorithm for .NET
A modern, fully compliant Google Encoded Polyline Algorithm library for .NET Standard 2.1+, supporting strong input validation, extensibility for custom coordinate types, and robust performance.
Features
- Google-compliant polyline encoding/decoding for geographic coordinates
- Extensible APIs for custom coordinate and polyline types (
AbstractPolylineEncoder<TCoordinate, TPolyline>,AbstractPolylineDecoder<TPolyline, TCoordinate>) - Extension methods for encoding from
List<T>and arrays (PolylineEncoderExtensions) - Robust input validation and descriptive exceptions
- Configurable with
PolylineEncodingOptions(precision, buffer size, logging) - Thread-safe, stateless APIs
- Low-level utilities via static
PolylineEncodingclass (Normalize, Denormalize, TryReadValue, TryWriteValue, ValidateFormat, etc.) - Benchmarks and unit tests for correctness and performance
- Auto-generated API docs (API Reference)
- Supports .NET Core, .NET 5+, Xamarin, Unity, Blazor via
netstandard2.1
Installation
dotnet add package PolylineAlgorithm
or via NuGet PMC:
Install-Package PolylineAlgorithm
Quick Start
The library provides abstract base classes to build your own encoder and decoder for any coordinate and polyline type.
Implement a custom encoder
using PolylineAlgorithm;
using PolylineAlgorithm.Abstraction;
public sealed class MyPolylineEncoder : AbstractPolylineEncoder<(double Latitude, double Longitude), string> {
protected override double GetLatitude((double Latitude, double Longitude) coordinate) => coordinate.Latitude;
protected override double GetLongitude((double Latitude, double Longitude) coordinate) => coordinate.Longitude;
protected override string CreatePolyline(ReadOnlyMemory<char> polyline) => polyline.ToString();
}
Encode coordinates
using PolylineAlgorithm.Extensions;
var coordinates = new List<(double Latitude, double Longitude)>
{
(48.858370, 2.294481),
(51.500729, -0.124625)
};
var encoder = new MyPolylineEncoder();
string encoded = encoder.Encode(coordinates); // extension method for List<T>
Console.WriteLine(encoded);
Implement a custom decoder
using PolylineAlgorithm;
using PolylineAlgorithm.Abstraction;
public sealed class MyPolylineDecoder : AbstractPolylineDecoder<string, (double Latitude, double Longitude)> {
protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude) => (latitude, longitude);
protected override ReadOnlyMemory<char> GetReadOnlyMemory(in string polyline) => polyline.AsMemory();
}
Decode polyline
string encoded = "yseiHoc_MwacOjnwM";
var decoder = new MyPolylineDecoder();
IEnumerable<(double Latitude, double Longitude)> decoded = decoder.Decode(encoded);
Advanced Usage
- Pass a
PolylineEncodingOptions(built viaPolylineEncodingOptionsBuilder) to the encoder/decoder constructor for custom precision, stack-alloc limit, and logging. - Use static methods on
PolylineEncodingfor low-level normalization, validation, and bit-level read/write operations.
See API Reference for full documentation.
FAQ
- What coordinate ranges are valid?
Latitude: -90..90, Longitude: -180..180 (throwsArgumentOutOfRangeExceptionfor invalid input) - What .NET versions are supported?
Any environment supportingnetstandard2.1 - How do I customize encoder options?
UsePolylineEncodingOptionsBuilderand pass the built options to the encoder or decoder constructor. - Where can I get help?
GitHub issues
License
MIT License © Pete Sramek
| Product | Versions 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | 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.
-
.NETStandard 2.1
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0 && < 11.0.0)
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.63-preview.2163 | 36 | 4/4/2026 |
| 1.0.60-preview.2162 | 36 | 4/4/2026 |
| 1.0.58-preview.2161 | 36 | 4/4/2026 |
| 1.0.39-preview.9 | 230 | 9/11/2025 |
Loading failed