Skip to content

Commit c77deea

Browse files
chgennar-zzmatt-lethargic
authored andcommitted
Adding Lat/Lon Validation to Position Constructor (#108)
Range validation was missing from one of the constructors for Position.
1 parent 8552a16 commit c77deea

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/GeoJSON.Net/Geometry/Position.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ public class Position : IPosition, IEqualityComparer<Position>, IEquatable<Posit
2222
/// <param name="altitude">The altitude in m(eter).</param>
2323
public Position(double latitude, double longitude, double? altitude = null)
2424
{
25+
if (Math.Abs(latitude) > 90)
26+
{
27+
throw new ArgumentOutOfRangeException(nameof(latitude), "Latitude must be a proper lat (+/- double) value between -90 and 90.");
28+
}
29+
30+
if (Math.Abs(longitude) > 180)
31+
{
32+
throw new ArgumentOutOfRangeException(nameof(longitude), "Longitude must be a proper lon (+/- double) value between -180 and 180.");
33+
}
34+
2535
Latitude = latitude;
2636
Longitude = longitude;
2737
Altitude = altitude;

0 commit comments

Comments
 (0)