SQL Server地理位置 [英] SQL Server Geography Point

查看:138
本文介绍了SQL Server地理位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

但是我无法弄清楚如何将数据插入到字段中,我曾尝试使用"POINT(double,double),0"之类的东西和类似的东西,但没有成功.

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.

对于地理功能中指定的ID参数的用途也很好奇.

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

谢谢, 亚历克斯.

推荐答案

您是否看过MSDN中的示例?

Have you looked at the examples from MSDN?

来自 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

并且来自 Point :

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

这篇关于SQL Server地理位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆