几何列:STGeomFromText 和 SRID(什么是 SRID?)

2022-01-14 00:00:00 geometry sql-server-2008 sql-server

我正在使用 SQL Server 2008 中的新地理列和 STGeomFromText 函数.这是我的代码(适用于 AdventureWorks2008)

I'm playing with the new geography column in SQL Server 2008 and the STGeomFromText function. Here is my code (works with AdventureWorks2008)

DECLARE @region geography;
set @region = geography::STGeomFromText('POLYGON((
        -80.0 50.0, -90.0 50.0,
        -90.0 25.0, -80.0 25.0,
        -80.0 50.0))', 4326);

SELECT @region;

我的问题是关于代码中的 4326.它应该是一个空间参考 ID.当我去 MSDN 时,它并没有太多内容.如果我将值更改为 56,我会收到一条错误消息,告诉我该值必须在 sys.spatial_reference_systems 表中.

My question is about the 4326 in the code. It is supposed to be a spacial Reference ID. When I go to MSDN there isn't a lot on it. If I change the value to 56 I get an error telling me the value must be in the sys.spatial_reference_systems table.

您可以通过执行以下命令查看该表:

You can look at that table by executing:

select * from sys.spatial_reference_systems 

该表中有一个 well_known_text 列,但它并没有告诉我太多信息.4326 的值为:

There is a well_known_text column in that table, but it doesn't tell me much. The value for 4326 is:

GEOGCS["WGS 84", DATUM["World Geodetic System 1984", ELLIPSOID["WGS 84", 6378137, 298.257223563]], PRIMEM["Greenwich", 0], UNIT["Degree", 0.0174532925199433]]

谁能向我解释这个谜团?什么是 SRID?

Can anyone explain this mystery to me? What is the SRID?

推荐答案

所以我昨天最终与一位前军人交谈,他是一名雷达/测绘专家.基本上,他确切地知道那个数字(4326)是什么,它来自哪里,以及它为什么在那里.

So I ended up talking with an ex-military guy yesterday who was a radar/mapping specialist. Basically, he knew exactly what that number (4326) was, where it came from, and why it is there.

它是计算地理的行业标准.问题是地球不是一个完美的球体(它在中间凸出),而 SRID 4326 说明了这一点.

It is an industry standard for computing geography. The problem is that the earth is not a perfect sphere (it bulges in the middle), and SRID 4326 accounts for that.

正如我所说,表 sys.spatial_reference_systems 列出了所有代码及其内容.但简而言之,除非您有非常具体的理由使用不同的东西,否则您实际上只会使用 4326.

As I stated, the table sys.spatial_reference_systems lists all of the code and what they are. But the short version is that you are really only going to use 4326 unless you have a very specific reason to use something different.

相关文章