Table of Contents

Interface IPolylineDecoder<TPolyline, TValue>

Namespace
PolylineAlgorithm.Abstraction
Assembly
PolylineAlgorithm.dll

Defines a contract for decoding an encoded polyline into a sequence of geographic coordinates.

public interface IPolylineDecoder<TPolyline, out TValue>

Type Parameters

TPolyline

The type that represents the encoded polyline input. Common implementations use String, but custom wrapper types are allowed to carry additional metadata.

TValue

The coordinate type returned by the decoder. Typical implementations return a struct or class that contains latitude and longitude (for example a LatLng type or a ValueTuple<double,double>).

Methods

Decode(TPolyline, CancellationToken)

Decodes the specified encoded polyline into an ordered sequence of geographic coordinates. The sequence preserves the original vertex order encoded by the polyline.

IEnumerable<out TValue> Decode(TPolyline polyline, CancellationToken cancellationToken = default)

Parameters

polyline TPolyline

The TPolyline instance containing the encoded polyline to decode. Implementations SHOULD validate the input and may throw ArgumentException or FormatException for invalid formats.

cancellationToken CancellationToken

A CancellationToken to observe while decoding. If cancellation is requested, implementations SHOULD stop work and throw an OperationCanceledException.

Returns

IEnumerable<TValue>

An IEnumerable<T> of TValue representing the decoded latitude/longitude pairs (or equivalent coordinates) in the same order they were encoded.

Remarks

Implementations commonly follow the Google Encoded Polyline Algorithm Format, but this interface does not mandate a specific encoding. Consumers should rely on a concrete decoder's documentation to understand the exact encoding supported.

Exceptions

OperationCanceledException

Thrown when the provided cancellationToken requests cancellation.