我正在使用postgreSQL,将long / lat转换为point,并且还希望与该点保持一致

时间:2017-04-01 14:11:40

标签: postgresql postgis

我正在使用postgreSQL将long / lat转换为point并且还希望与该点进行对齐

onRequestPermissionResult

但结果失败且msg为

  

SQL状态:42883 st_makepoint不存在,还必须使用显式转换器

我也用这样简单的形式测试过。

select bs1.rental_shop_name,
    bs1.lon,
    bs1.lat,
    bs2.rental_shop_name,
    bs2.lon,
    bs2.lat,
    count(*),
    ST_MakeLine(ST_MakePoint(bs1.lon, bs1.lat), ST_MakePoint(bs2.lon, bs2.lat))
from bikeuser as bu
join bikestation as bs1 on bs1.rental_shop_code = bu.rental_shop_code
join bikestation as bs2 on bs2.rental_shop_code = bu.return_shop_code
group by bs1.rental_shop_name,
    bs1.lon,
    bs1.lat,
    bs2.rental_shop_name,
    bs2.lon,
    bs2.lat,
    ST_MakeLine(ST_MakePoint(bs1.lon, bs1.lat), ST_MakePoint(bs2.lon, bs2.lat))
order by count desc limit 40

但同样的结果......

1 个答案:

答案 0 :(得分:0)

使用lat long只是ST_MakePoint是不够的。您还必须设置几何的SRID。如果数据来自WGS84(通常是lat long的情况),则需要在几何上应用ST_SetSRID。

   ST_MakeLine(ST_SetSRID(ST_MakePoint(bs1.lon, bs1.lat),4326), ST_SetSRID(ST_MakePoint(bs2.lon, bs2.lat),4326))

您应该考虑自己的数据SRID。