SQL Server地理纬度经度错误

时间:2018-09-08 21:56:25

标签: sql-server sqlgeography

我正在使用地理数据类型来计算最短距离。

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(Double x,Double y,Nullable 1 z, Nullable 1 m)        在Microsoft.SqlServer.Types.Validator.BeginFigure(Double x,Double y,Nullable 1 z, Nullable 1 m)        在Microsoft.SqlServer.Types.ForwardingGeoDataSink.BeginFigure(Double x,Double y,Nullable 1 z, Nullable 1 m)        在Microsoft.SqlServer.Types.CoordinateReversingGeoDataSink.BeginFigure(Double x,Double y,Nullable 1 z, Nullable 1 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标记文本,Int32 srid)        在Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType类型,SqlChars带标记的文本,Int32 srid)     

  

这是什么问题?

0 个答案:

没有答案