Skip to content

Commit c7aa231

Browse files
committed
Merge pull request #1846 from niemyjski/patch-1
Fixed an issue with implicit conversion and culture formatting of geo coordinates
2 parents a5789c7 + 47c2123 commit c7aa231

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Nest/QueryDsl/Geo/GeoLocation.cs

Lines changed: 5 additions & 3 deletions
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 _latitude.ToString("#0.0#######") + "," + _longitude.ToString("#0.0#######");
85+
return _latitude.ToString("#0.0#######", CultureInfo.InvariantCulture) + "," + _longitude.ToString("#0.0#######", CultureInfo.InvariantCulture);
8686
}
8787

8888
public bool Equals(GeoLocation other)
@@ -128,7 +128,9 @@ public static implicit operator GeoLocation(string latLon)
128128

129129
public static implicit operator GeoLocation(double[] lonLat)
130130
{
131-
if (lonLat.Length != 2) throw new ArgumentException("Invalid lon,lat array, must have a length of 2");
131+
if (lonLat.Length != 2)
132+
return null;
133+
132134
return new GeoLocation(lonLat[1], lonLat[0]);
133135
}
134136
}
@@ -151,4 +153,4 @@ public static implicit operator GeoCoordinate(double[] coordinates)
151153
return new GeoCoordinate(coordinates[0], coordinates[1]);
152154
}
153155
}
154-
}
156+
}

0 commit comments

Comments
 (0)