Skip to content

Commit

Permalink
- coordinates are not validated against geographic coordinate bounds,…
Browse files Browse the repository at this point in the history
… can now be any numeric

- assembly file version matching nuget package version
  • Loading branch information
xfischer committed Feb 27, 2019
1 parent 88e1d52 commit ab6fad4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/GeoJSON.Net/GeoJSON.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard1.1;net35;net40;net45;</TargetFrameworks>
<AssemblyName>GeoJSON.Net</AssemblyName>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<AssemblyVersion>1.1.72</AssemblyVersion>
<FileVersion>1.1.72</FileVersion>
<Description>.Net types for the GeoJSON RFC to be used with Json.Net</Description>
<Authors></Authors>
<Company>GeoJSON.Net</Company>
Expand Down
33 changes: 12 additions & 21 deletions src/GeoJSON.Net/Geometry/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,12 @@ public class Position : IPosition, IEqualityComparer<Position>, IEquatable<Posit
/// <summary>
/// Initializes a new instance of the <see cref="Position" /> class.
/// </summary>
/// <param name="latitude">The latitude.</param>
/// <param name="longitude">The longitude.</param>
/// <param name="latitude">The latitude, or Y coordinate.</param>
/// <param name="longitude">The longitude or X coordinate.</param>
/// <param name="altitude">The altitude in m(eter).</param>
public Position(double latitude, double longitude, double? altitude = null)
{
// Yes I hate commented out code to, but this needs to go right now
//if (Math.Abs(latitude) > 90)
//{
// throw new ArgumentOutOfRangeException(nameof(latitude), "Latitude must be a proper lat (+/- double) value between -90 and 90.");
//}

//if (Math.Abs(longitude) > 180)
//{
// throw new ArgumentOutOfRangeException(nameof(longitude), "Longitude must be a proper lon (+/- double) value between -180 and 180.");
//}

// TODO Coordinate range validation should be performed only when CRS is supplied
Latitude = latitude;
Longitude = longitude;
Altitude = altitude;
Expand All @@ -41,11 +31,12 @@ public Position(double latitude, double longitude, double? altitude = null)
/// <summary>
/// Initializes a new instance of the <see cref="Position" /> class.
/// </summary>
/// <param name="latitude">The latitude, e.g. '38.889722'.</param>
/// <param name="longitude">The longitude, e.g. '-77.008889'.</param>
/// <param name="latitude">The latitude, or Y coordinate e.g. '38.889722'.</param>
/// <param name="longitude">The longitude, or X coordinate e.g. '-77.008889'.</param>
/// <param name="altitude">The altitude in m(eters).</param>
public Position(string latitude, string longitude, string altitude = null)
{
// TODO Coordinate range validation should be performed only when CRS is supplied
if (string.IsNullOrEmpty(latitude))
{
throw new ArgumentOutOfRangeException(nameof(latitude), "May not be empty.");
Expand All @@ -56,14 +47,14 @@ public Position(string latitude, string longitude, string altitude = null)
throw new ArgumentOutOfRangeException(nameof(longitude), "May not be empty.");
}

if (!double.TryParse(latitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double lat) || Math.Abs(lat) > 90)
if (!double.TryParse(latitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double lat))
{
throw new ArgumentOutOfRangeException(nameof(latitude), "Latitude must be a proper lat (+/- double) value between -90 and 90.");
throw new ArgumentOutOfRangeException(nameof(altitude), "Latitude representation must be a numeric.");
}

if (!double.TryParse(longitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double lon) || Math.Abs(lon) > 180)
if (!double.TryParse(longitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double lon))
{
throw new ArgumentOutOfRangeException(nameof(longitude), "Longitude must be a proper lon (+/- double) value between -180 and 180.");
throw new ArgumentOutOfRangeException(nameof(altitude), "Longitude representation must be a numeric.");
}

Latitude = lat;
Expand All @@ -86,12 +77,12 @@ public Position(string latitude, string longitude, string altitude = null)
public double? Altitude { get; }

/// <summary>
/// Gets the latitude.
/// Gets the latitude or Y coordinate
/// </summary>
public double Latitude { get; }

/// <summary>
/// Gets the longitude.
/// Gets the longitude or X coordinate
/// </summary>
public double Longitude { get; }

Expand Down

1 comment on commit ab6fad4

@xfischer
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine with #111

Please sign in to comment.