diff --git a/GetIntoTeachingApi/Adapters/GeocodeClientAdapter.cs b/GetIntoTeachingApi/Adapters/GeocodeClientAdapter.cs index f45ab31ae..d61b8efde 100644 --- a/GetIntoTeachingApi/Adapters/GeocodeClientAdapter.cs +++ b/GetIntoTeachingApi/Adapters/GeocodeClientAdapter.cs @@ -1,9 +1,11 @@ using System.Linq; using System.Threading.Tasks; using GeocodeSharp.Google; +using GetIntoTeachingApi.Database; using GetIntoTeachingApi.Services; using GetIntoTeachingApi.Utils; using Microsoft.Extensions.Logging; +using NetTopologySuite; using NetTopologySuite.Geometries; namespace GetIntoTeachingApi.Adapters @@ -41,10 +43,12 @@ public async Task GeocodePostcodeAsync(string postcode) return null; } - _metrics.GoogleApiCalls.WithLabels(postcode, "success").Inc(); - + _metrics.GoogleApiCalls.WithLabels(postcode, "success").Inc(); + var location = result.Geometry.Location; - return new Point(new Coordinate(location.Longitude, location.Latitude)); + var geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: DbConfiguration.Wgs84Srid); + + return geometryFactory.CreatePoint(new Coordinate(location.Longitude, location.Latitude)); } } }