【发布时间】:2019-02-13 19:41:23
【问题描述】:
我正在使用地理数据类型来计算最短距离。
CREATE TABLE Landmark (
Id int,
Latitude FLOAT,
Longitude FLOAT
)
INSERT Landmark VALUES
(1, 49.242458, -123.153465),
(2, 49.249381, -122.866683)
WITH GeographyLandmark AS
(
SELECT Id, geography::STPointFromText('POINT(' + CAST(Latitude AS VARCHAR(20)) + ' ' + CAST(Longitude AS VARCHAR(20)) + ')', 4326) Location
FROM Landmark
)
--this query calculates distance between point and localizations in meters
SELECT Id, geography::STPointFromText('POINT(' + CAST(49.2424566 AS VARCHAR(20)) + ' ' + CAST(-123.1534623 AS VARCHAR(20)) + ')', 4326).STDistance(Location) Distance
FROM GeographyLandmark
但我收到此错误:
在执行用户定义的例程或聚合“地理”期间发生 .NET Framework 错误: System.FormatException:24201:纬度值必须在 -90 到 90 度之间。 System.FormatException: 在 Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(双 x,双 y,Nullable
1 z, Nullable1 m) 在 Microsoft.SqlServer.Types.Validator.BeginFigure(双 x,双 y,Nullable1 z, Nullable1 m) 在 Microsoft.SqlServer.Types.ForwardingGeoDataSink.BeginFigure(双 x,双 y,Nullable1 z, Nullable1 m) 在 Microsoft.SqlServer.Types.CoordinateReversingGeoDataSink.BeginFigure(双 x,双 y,Nullable1 z, Nullable1 m) 在 Microsoft.SqlServer.Types.WellKnownTextReader.ParsePointText(布尔 parseParentheses) 在 Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType 类型) 在 Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType 类型,Int32 srid) 在 Microsoft.SqlServer.Types.SqlGeography.ParseText(OpenGisType 类型,SqlChars taggedText,Int32 srid) 在 Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType 类型,SqlChars taggedText,Int32 srid) .
这里有什么问题?
【问题讨论】: