Skip to content

Commit 8f81232

Browse files
committed
Merge pull request #1814 from niemyjski/master
Added a null check to GeoLocation and updated ToString()
2 parents 92bf3f7 + 0823949 commit 8f81232

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/Nest/QueryDsl/Geo/GeoLocation.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static GeoLocation TryCreate(double latitude, double longitude)
8282

8383
public override string ToString()
8484
{
85-
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", _latitude, _longitude);
85+
return _latitude.ToString("#0.0#######") + "," + _longitude.ToString("#0.0#######");
8686
}
8787

8888
public bool Equals(GeoLocation other)
@@ -112,6 +112,9 @@ public override int GetHashCode() =>
112112

113113
public static implicit operator GeoLocation(string latLon)
114114
{
115+
if (string.IsNullOrEmpty(latLon))
116+
throw new ArgumentNullException(nameof(latLon));
117+
115118
var parts = latLon.Split(',');
116119
if (parts.Length != 2) throw new ArgumentException("Invalid format: string must be in the form of lat,lon");
117120
double lat;

0 commit comments

Comments
 (0)