Skip to content

Commit 11cea37

Browse files
committed
added validation
1 parent 44a16af commit 11cea37

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/PolylineAlgorithm/PolylineDecoder.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public PolylineDecoder(PolylineEncodingOptions<Coordinate> options) {
4242
/// <returns>A <see cref="Coordinate"/> instance.</returns>
4343
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4444
protected override Coordinate CreateCoordinate(double latitude, double longitude) {
45+
if (!Options.Validator.IsValidLatitude(latitude)) {
46+
throw new ArgumentOutOfRangeException(nameof(latitude), latitude, "Latitude must be between -90 and 90 degrees.");
47+
}
48+
49+
if (!Options.Validator.IsValidLongitude(longitude)) {
50+
throw new ArgumentOutOfRangeException(nameof(longitude), longitude, "Longitude must be between -180 and 180 degrees.");
51+
}
52+
4553
return new Coordinate(latitude, longitude);
4654
}
4755

0 commit comments

Comments
 (0)