SQL Server单位问题 [英] SQL Server units question

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

问题描述

这可能是一个非常愚蠢的问题,但是...

This may be a really dumb question, but...

Geography.STLength返回什么单位? MSDN官方页面没有对返回的单元进行任何说明,和此博客条目在这里说STLength() returns a float indicating the length of the instance in units.是的,没错,它说会以单位的形式返回它.

What units does Geography.STLength return? The official MSDN page doesn't say anything about the units returned, and this blog entry here says STLength() returns a float indicating the length of the instance in units. Yes, that's right, it says it returns it in units.

有人可以阐明STLength返回的单位吗?脚?米?英寸?救命!

Can anyone shed some light on what units STLength returns? Feet? Meters? Inches? Help!

推荐答案

单位完全取决于所使用的地理/几何数据的空间参考ID(SRID).按照惯例,如果所有数据都在同一单位系统中,则通常将SRID设置为"0"用于几何类型.

The units are entirely dependent on the Spatial Reference ID (SRID) of the geography/geometry data being used. By convention, you would generally use an SRID of "0" for geometry types if all the data is in the same unit system.

但是,通常地理类型使用的SRID为4326,这是纬度/经度椭球地球坐标系(称为WGS 84)的参考ID.在此系统中指定点坐标时,它的角度为纬度和经度,而不是到原点的距离.此参考系统中点的长度和面积计算将返回与完全相同的点位置上的几何计算完全不同的结果(例如,

However, usually the geography type uses an SRID of 4326, which is the reference ID of the latitude/longitude ellipsoidal earth coordinate system known as WGS 84. When you specify point coordinates in this system, it is in degrees of angle of latitude and longitude, rather than some distance from an origin. Length and area calculations on points in this reference system will return completely different results from geometric calculations on the exact same point positions (for a great example see Differences between Geography and Geometry here, and as for why this happens, see here).

因此,如果您创建的数据列的SRID为"0",则系统被定义为无单位,并且您将需要有关数据模型的一些元数据来找出单位.如果它们是使用真实的SRID定义的,则可以使用以下查询:

So if your data columns were created with an SRID of "0", then the system is defined to be unitless and you would need some metadata about the data model to figure out the units. If they were defined with a real SRID, then you can use this query:

SELECT spatial_reference_id
   , well_known_text
   , unit_of_measure
   , unit_conversion_factor
FROM sys.spatial_reference_systems

检查SRID代表什么单位.多数人在米处,但有些人在脚上.

to check what units the SRID represents. Most are in metres, but a few are in feet.

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

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