我是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手册.
更多推荐
纬度和经度的哪种数据类型?
发布评论