Skip to content

Commit c8852a7

Browse files
committed
refactored PolylineEncodingOptions
1 parent a0233fe commit c8852a7

2 files changed

Lines changed: 5 additions & 18 deletions

File tree

src/PolylineAlgorithm.Abstraction/PolylineEncoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public TPolyline Encode(IEnumerable<TCoordinate> coordinates) {
5656
int consumed = 0;
5757
int length = count * Defaults.Polyline.MaxEncodedCoordinateLength;
5858

59-
if (length > Options.GetMaxCharCount()) {
60-
length = Options.GetMaxCharCount();
59+
if (length > Options.MaxCharCount) {
60+
length = Options.MaxCharCount;
6161
}
6262

6363
Span<char> buffer = stackalloc char[length];

src/PolylineAlgorithm.Abstraction/PolylineEncodingOptions.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace PolylineAlgorithm.Abstraction;
77

8-
using PolylineAlgorithm.Abstraction.Internal;
98
using PolylineAlgorithm.Abstraction.Validation;
109
using PolylineAlgorithm.Abstraction.Validation.Abstraction;
1110

@@ -19,26 +18,14 @@ public class PolylineEncodingOptions<TCoordinate> {
1918
/// </summary>
2019
public int MaxBufferSize { get; } = 64_000;
2120

22-
/// <summary>
23-
/// Gets the validator used to validate coordinates, latitude, and longitude values.
24-
/// </summary>
25-
public Validator<TCoordinate> Validator { get; } = new NullValidator<TCoordinate>();
26-
2721
/// <summary>
2822
/// Gets the maximum number of characters that can be used in the encoding buffer.
2923
/// </summary>
3024
/// <returns>The maximum character count based on the buffer size.</returns>
31-
internal int GetMaxCharCount() => MaxBufferSize / sizeof(char);
25+
public int MaxCharCount => MaxBufferSize / sizeof(char);
3226

3327
/// <summary>
34-
/// Validates the encoding options to ensure they are within acceptable limits.
28+
/// Gets the validator used to validate coordinates, latitude, and longitude values.
3529
/// </summary>
36-
/// <exception cref="ArgumentException">
37-
/// Thrown if <see cref="MaxBufferSize"/> is less than the minimum required buffer size.
38-
/// </exception>
39-
internal void Validate() {
40-
if (MaxBufferSize < Defaults.Polyline.MaxEncodedCoordinateLength * sizeof(char)) {
41-
throw new ArgumentException();
42-
}
43-
}
30+
public Validator<TCoordinate> Validator { get; } = new NullValidator<TCoordinate>();
4431
}

0 commit comments

Comments
 (0)