纬度和经度的哪种数据类型? [英] Which data type for latitude and longitude?

查看:419
本文介绍了纬度和经度的哪种数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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?

推荐答案

您可以使用数据类型

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

或将其设为 float (= float8double 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

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手册.

这篇关于纬度和经度的哪种数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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