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,可为空)
1 z, Nullable
1米)
在Microsoft.SqlServer.Types类型.验证程序.BeginFigure(双x,双y,可为空)
1 z,可为空
在Microsoft.SqlServer.Types类型ForwardingGeoDataSink.BeginFigure文件(双x,双y,可为空)
1 z,可为空
在Microsoft.SqlServer.Types类型.坐标反转geodatasink.BeginFigure(双x,双y,可为空)
1 z,可为空
在Microsoft.SqlServer.Types类型.WellKnownTextReader.ParsePointText文件(布尔括号)
在Microsoft.SqlServer.Types类型.WellKnownTextReader.ParseTaggedText文件(OpenGisType类型)
在Microsoft.SqlServer.Types类型.WellKnownTextReader。读(OpenGisType,Int32 srid)
在Microsoft.SqlServer.Types类型.SqlGeography.ParseText文件(OpenGisType类型,SqlChars taggedText,Int32 srid)
.