纬度和经度的最大长度是多少?

本文详细探讨了经纬度的有效范围、精度表示以及不同格式下的坐标表示方法,包括十进制度和度-分-秒表示法,同时介绍了在SQL Server中存储经纬度值的理想数据类型。
部署运行你感兴趣的模型镜像

本文翻译自:What is the maximum length of latitude and longitude?

How long can latitude and longitude be? 经度和纬度能达到多长时间?

I am getting very long lengths sent by a Windows Phone device: Windows Phone设备发送的长度越来越长:

Latitude=-63572375290155
Longitude=106744840359415

This is exceeding my table column size and I am getting errors. 这超出了我的表列大小,并且出现错误。


#1楼

参考:https://stackoom.com/question/14ZgG/纬度和经度的最大长度是多少


#2楼

The valid range of latitude in degrees is -90 and +90 for the southern and northern hemisphere respectively. 南半球和北半球的有效纬度范围分别是-90和+90 Longitude is in the range -180 and +180 specifying coordinates west and east of the Prime Meridian, respectively. 经度在-180和+180范围内,分别指定本初子午线以西和以东的坐标。

For reference, the Equator has a latitude of 0°, the North pole has a latitude of 90° north (written 90° N or +90°), and the South pole has a latitude of -90°. 作为参考, 赤道的纬度为0°, 北极的纬度为北90°(写为90°N或+ 90°), 南极的纬度为-90°。

The Prime Meridian has a longitude of 0° that goes through Greenwich, England. 本初子午线经英格兰格林威治的经度为0°。 The International Date Line (IDL) roughly follows the 180° longitude. 国际日期变更线(IDL)大致遵循180度经度。 A longitude with a positive value falls in the eastern hemisphere and negative value falls in the western hemisphere. 东半球为正值的经度,西半球为负值的经度。

Decimal degrees precision 小数度精度

Six (6) decimal places precision in coordinates using decimal degrees notation is at a 10 cm (or 0.1 meter) resolution. 使用十进制度数表示法的坐标中六(6)个小数位精度为10 cm(或0.1米)。 Each .000001 difference in coordinate decimal degree is approximately 10 cm in length. 坐标十进制度的每个.000001差异长度约为10厘米。 For example, the imagery of Google Earth and Google Maps is typically at the 1 meter resolution, and some places have a higher resolution of 1 inch per pixel. 例如,“ Google地球”和“ Google地图”的图像通常为1米的分辨率,有些地方的分辨率为每像素1英寸。 One meter resolution can be represented using 5 decimal places so more than 6 decimal places is extraneous for that resolution. 一米的分辨率可以使用5个小数位表示,因此该分辨率不需要6个小数位。 The distance between longitudes at the equator is the same as latitude, but the distance between longitudes reaches zero at the poles as the lines of meridian converge at that point. 赤道上的经度距离与纬度相同,但是当子午线在该点收敛时,经度之间的距离在极点处达到零。

If Latitude value is reported as -6.3572375290155 or -63.572375290155 then you could round-off and store up to 6 decimal places for 10 cm (or 0.1 meter) precision. 如果纬度值报告为-6.3572375290155或-63.572375290155,则可以四舍五入并存储最多6个小数位,精度为10 cm(或0.1米)。

For millimeter (mm) precision then represent lat/lon with 8 decimal places in decimal degrees format. 对于毫米(mm)精度,则以十进制度数表示小数点后8位的经/纬度。 Since most applications don't need that level of precision 6 decimal places is sufficient for most cases. 由于大多数应用程序不需要那种精确度的小数点后6位就可以满足大多数情况。

In the other direction, whole decimal degrees represents a distance of ~111 km (or 60 nautical miles) and a 0.1 decimal degree difference represents a ~11 sq. Km area. 在另一个方向上,整个十进制度表示的距离约为111公里(或60海里),而十进制度差的0.1表示面积约为11平方公里。

Here is a table of # decimal places difference in latitude with the delta degrees and the estimated distance in meters using 0,0 as the starting point. 这是一张#纬度差异的小数位数表格,其中以度数为单位,以0,0为起点的估算距离(以米为单位)。

decimal  decimal     distance
places   degrees    (in meters)
-------  ---------  -----------
  1      0.1000000  11,057.43      11 km
  2      0.0100000   1,105.74       1 km
  3      0.0010000     110.57
  4      0.0001000      11.06
  5      0.0000100       1.11
  6      0.0000010       0.11      11 cm
  7      0.0000001       0.01       1 cm

Degrees-minute-second (DMS) representation 度-分-秒(DMS)表示

For DMS notation 1 arc second = 1/60/60 degree = ~30 meter length and 0.1 arc sec delta is ~3 meters. 对于DMS表示法,1弧秒= 1/60/60度=约30米长,0.1弧秒增量为〜3米。

Example: 例:

  • 0° 0' 0" W, 0° 0' 0" N -> 0° 0' 0" W, 0° 0' 1" N => 30.715 meters 0°0'0“ W,0°0'0” N-> 0°0'0“ W,0°0'1” N => 30.715米
  • 0° 0' 0" W, 0° 0' 0" N -> 0° 0' 0" W, 0° 0' 0.1" N => 3.0715 meters 0°0'0“ W,0°0'0” N-> 0°0'0“ W,0°0'0.1” N => 3.0715米

1 arc minute = 1/60 degree = ~2000m (2km) 1弧分= 1/60度=〜2000m(2km)

UPDATE: Here is an amusing blog post about coordinate precision. 更新:这是一篇有关坐标精度的有趣博客文章


#3楼

  • Latitude : max/min +90 to -90 纬度 :最大/最小+90-90

  • Longitude : max/min +180 to -180 经度 :最高/最低+180-180


#4楼

Latitude maximum in total is: 9 (12.3456789), longitude 10 (123.4567890), they both have maximum 7 decimals chars (At least is what i can find in Google Maps ), 纬度最大值总计为:9(12.3456789),经度10(123.4567890),它们都具有最大7个小数点字符(至少是我在Google Maps中可以找到的字符),

For example, both columns in Rails and Postgresql looks something like this: 例如,Rails和Postgresql中的两列都看起来像这样:

t.decimal :latitude, precision: 9, scale: 7
t.decimal :longitude, precision: 10, scale: 7

#5楼

Valid longitudes are from -180 to 180 degrees. 有效经度为-180至180度。

Latitudes are supposed to be from -90 degrees to 90 degrees, but areas very near to the poles are not indexable. 纬度应该在-90度到90度之间,但是极点附近的区域无法转位。

So exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following: 因此,EPSG:900913 / EPSG:3785 / OSGEO:41001指定的确切限制如下:

  • Valid longitudes are from -180 to 180 degrees. 有效经度为-180至180度。
  • Valid latitudes are from -85.05112878 to 85.05112878 degrees. 有效纬度为-85.05112878至85.05112878度。

#6楼

The ideal datatype for storing Lat Long values in SQL Server is decimal(9,6) 在SQL Server中存储Lat Long值的理想数据类型是十进制(9,6)

As others have said, this is at approximately 10cm precision, whilst only using 5 bytes of storage. 正如其他人所说,这大约是10厘米的精度,而仅使用5字节的存储空间。

eg CAST(123.456789 as decimal(9,6)) as [LatOrLong] 例如CAST(123.456789 as decimal(9,6)) as [LatOrLong]

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

<think>好的,用户现在问的是关于GPRMC帧的最大长度多少字节。首先,我需要回忆一下NMEA 0183协议的相关规范。GPRMC是NMEA协议中的一个标准语句,主要用于推荐最小特定GNSS数据。根据之前的交流,用户可能是在处理GPS数据解析,特别是校验计算,现在可能遇到了数据长度的问题,或者想要优化缓冲区的大小。 首先,我需要确认NMEA协议中对语句长度的规定。根据NMEA 0183标准,每条语句的最大长度通常限制为82个字符,包括起始的'$'终止的换行符。不过具体到GPRMC语句,可能还需要具体分析其字段构成。GPRMC包含时间、状态、纬度经度、速度、航向、日期、磁偏角等字段,各字段之间用逗号分隔。每个字段的长度不同,比如纬度可能占用最多12个字符(如DDMM.MMMMM),经度类似,日期是六数字,速度可能有五等。将这些字段长度加起来,再加上分隔符校验,可以估算出总长度。 不过要注意,协议中是否有明确的长度限制。查阅资料确认,NMEA 0183 v4.10版本中确实规定了每条语句的最大长度不超过82字符。例如,起始符$占1,语句体最多到*之前是80,然后*加上两校验,最后是<CR><LF>,总共82。但实际中有些实现可能不包括换行符,所以可能看到的最大长度是80左右。 另外,用户可能关心实际应用中遇到的GPRMC帧是否有可能接近这个最大长度,或者是否需要为缓冲区分配足够的空间。例如,如果用户正在编写接收GPS数据的程序,需要确保缓冲区足够大以容纳最长的GPRMC帧,避免截断。此外,之前提供的示例代码中使用了字符串处理函数,如果帧长度超过预期可能导致溢出,需要确认代码是否有缓冲区溢出的风险。 用户的问题可能源于实际开发中的需求,比如定义数组大小时需要知道最大可能的长度。因此,给出明确的数字并解释依据是很重要的。同时,提醒用户注意不同版本协议的可能差异,以及实际设备可能存在的特殊情况,比如某些字段的扩展或附加信息导致长度超出常规情况,但根据标准,最大长度应不超过82字节。 总结回答时需要分点说明:协议规定的最大长度、GPRMC各字段的可能长度总、示例计算以及实际应用中的建议。确保用户不仅知道最大长度,还能理解背后的原因,从而做出合适的设计决策。</think>根据NMEA 0183协议标准,**$GPRMC语句的最大长度为82字节**(包含所有符号控制字符)。以下是具体分析: --- ### **核心规范** 1. **协议定义** - NMEA 0183 v4.10规定:每条语句的最大长度不超过 **82字节** - 包含以下部分: - 起始符 `$`(1字节) - 语句体(最多80字节) - 校验符 `*`(1字节) - 校验(2字节) - 终止符 `<CR><LF>`(2字节,实际传输中可能省略) 2. **$GPRMC典型结构示例** ```plaintext $GPRMC,<时间>,<状态>,<纬度>,<纬度半球>,<经度>,<经度半球>,<速度>,<航向>,<日期>,<磁偏角>,<磁偏角方向>,*<校验> ``` - **最长情况**:字段全填充时约 **70-78字节**(具体因设备实现而异) --- ### **字段长度估算** | 字段 | 最大字节数 | 示例值 | |------------------|------------|---------------------------| | 时间(UTC) | 9 | `083015.000` | | 纬度 | 12 | `3112.3456789` (带小数) | | 经度 | 12 | `12130.7890123` (带小数) | | 速度(节) | 6 | `123.45` | | 航向(度) | 6 | `359.99` | | 日期(DDMMYY) | 6 | `260324` | | 磁偏角 | 5 | `12.34` | | **合计** | ~56字节 | +逗号分隔符后约 **70字节** | --- ### **实际应用建议** 1. **缓冲区设置** - 建议预留 **82字节** 的接收缓冲区(例如 `char buffer[82]`) - 代码示例: ```c #define NMEA_MAX_LEN 82 char gprmc_buffer[NMEA_MAX_LEN + 1]; // +1为字符串结束符'\0' ``` 2. **验证逻辑** - 在解析前检查长度,避免溢出: ```c if (strlen(nmea_sentence) > NMEA_MAX_LEN) { // 错误处理:丢弃超长数据 } ``` --- ### **例外情况** - 部分设备可能省略终止符 `<CR><LF>`,此时实际长度约为 **80字节** - 若包含厂商扩展字段(如 `,A*`),可能接近协议上限 --- ### **协议依据** 参考NMEA 0183官方文档: > "Each sentence shall contain a maximum of 82 characters including the `$` and `*` characters and `<CR><LF>`." > —— NMEA 0183 Standard v4.10, Section 5.3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值