纬度和经度的哪种数据类型?

编程入门 行业动态 更新时间:2024-10-27 04:38:34
本文介绍了纬度和经度的哪种数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是PostgreSQL和PostGIS的新手.我想将纬度和经度值存储在PostgreSQL 9.1.1数据库表中.我将计算两个点之间的距离,并使用此位置值找到更近的点.

I am newbie to PostgreSQL and PostGIS. I want to store latitude and longitude values in PostgreSQL 9.1.1 database table. I will calculate distance between two points, find nearer points by using this location values.

经纬度应使用哪种数据类型?

Which data type should I use for latitude and longitude?

推荐答案

您可以使用数据类型 point -组合(x,y)可以作为您的经/纬度.占用16个字节:内部2个float8数字.

You can use the data type point - combines (x,y) which can be your lat / long. Occupies 16 bytes: 2 float8 numbers internally.

或将其设为 float (= float8或double precision).每个8字节. 或 real (= float4)(如果不需要其他精度).每个4个字节. 甚至 numeric > ,如果您需要绝对精度.每组4位数字2个字节,外加3-8个字节的开销.

Or make it two columns of type float (= float8 or double precision). 8 bytes each. Or real (= float4) if additional precision is not needed. 4 bytes each. Or even numeric if you need absolute precision. 2 bytes for each group of 4 digits, plus 3 - 8 bytes overhead.

阅读有关数字类型和几何类型.

geometry 和 geography 数据类型由附加模块 PostGIS 和占据表中的 one 列.每个点占用32个字节.那里有一些额外的开销,例如SRID.这些类型存储(long/lat),而不存储(lat/long).

The geometry and geography data types are provided by the additional module PostGIS and occupy one column in your table. Each occupies 32 bytes for a point. There is some additional overhead like an SRID in there. These types store (long/lat), not (lat/long).

在此处开始阅读 PostGIS手册.

更多推荐

纬度和经度的哪种数据类型?

本文发布于:2023-10-19 07:21:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1506782.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:经度   纬度   哪种   数据类型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!