SQL Server 地理点

发布于 2024-09-30 16:01:28 字数 187 浏览 5 评论 0原文

我最近一直在研究 SQL Server 空间数据类型,并决定尝试将我的长纬度点存储在地理字段中。

但是我不知道如何将数据插入到字段中,我尝试使用“POINT(double, double), 0”之类的东西和类似的奇怪的东西,但没有成功。

我也很好奇地理函数中指定的 ID 参数的目的是什么。

谢谢, 亚历克斯.

I have recently been researching the SQL Server spatial data types and have decided to try and store my long, lat points in a geography field.

However I cannot figure out how to insert the data into the field, I have tried using stuff like "POINT(double, double), 0" and weird stuff like that, but no success.

Also im curious as to what the purpose of the ID argument specified in the geography functions.

Thanks,
Alex.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安稳善良 2024-10-07 16:01:28

你看过MSDN上的例子吗?

来自地理 (Transact-SQL)

IF OBJECT_ID ( 'dbo.SpatialTable', 'U' ) IS NOT NULL 
    DROP TABLE dbo.SpatialTable;
GO

CREATE TABLE SpatialTable 
    ( id int IDENTITY (1,1),
    GeogCol1 geography, 
    GeogCol2 AS GeogCol1.STAsText() );
GO

INSERT INTO SpatialTable (GeogCol1)
VALUES (geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656 )', 4326));

INSERT INTO SpatialTable (GeogCol1)
VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));
GO

并来自

DECLARE @g geometry;
SET @g = geometry::STGeomFromText('POINT (3 4)', 0);
SET @g = geometry::Parse('POINT(3 4 7 2.5)');

Have you looked at the examples from MSDN?

From geography (Transact-SQL):

IF OBJECT_ID ( 'dbo.SpatialTable', 'U' ) IS NOT NULL 
    DROP TABLE dbo.SpatialTable;
GO

CREATE TABLE SpatialTable 
    ( id int IDENTITY (1,1),
    GeogCol1 geography, 
    GeogCol2 AS GeogCol1.STAsText() );
GO

INSERT INTO SpatialTable (GeogCol1)
VALUES (geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656 )', 4326));

INSERT INTO SpatialTable (GeogCol1)
VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));
GO

And from Point:

DECLARE @g geometry;
SET @g = geometry::STGeomFromText('POINT (3 4)', 0);
SET @g = geometry::Parse('POINT(3 4 7 2.5)');
淡笑忘祈一世凡恋 2024-10-07 16:01:28
DECLARE @g geography;  
SET @g = geography::Point(4, 3, 4326);

注意:与上面的 POINT 语法相比,Lat 和 Long 是相反的。

DECLARE @g geography;  
SET @g = geography::Point(4, 3, 4326);

Notice: Lat and Long are the other way around, compared to the POINT syntax above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文