描述
我將谷歌地理編碼結果中的緯度/經度存盤到地理列中。但根據緯度/經度,查詢回傳的值與插入的值不同。我做錯了什么或錯過了什么?
復制品
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE TABLE "public"."test_location" (
"name" text,
"location" GEOGRAPHY (point)
);
INSERT INTO "public"."test_location" ("name", "location")
VALUES
('test 1', ST_POINT (32.714476, -117.151735)),
('test 2', ST_POINT (36.1450444, -85.4788305));
SELECT
name,
ST_AsText (location)
FROM
"public"."test_location";
-- output:
-- |-----------------------------------------|
-- | name | ST_AsText |
-- |-----------------------------------------|
-- | test 1 | POINT(32.714476 -62.848265) | --> expected POINT(32.714476 -117.151735)
-- | test 2 | POINT(36.1450444 -85.4788305) |
-- |-----------------------------------------|
DROP TABLE "public"."test_location";
uj5u.com熱心網友回復:
好像是交換了經度和緯度
ST_POINT(longitude, latitude)
經度范圍 -180 到 180
緯度范圍 -90 到 90
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/496050.html
標籤:sql PostgreSQL 谷歌地图 地理信息系统 psql
