我在PostGIS中創建了一個表itapp_cities
,用於存儲城市的數據。我添加了一列location
,數據類型爲geometry
,用於存儲城市的longitude
和latitude
。當我運行以下INSERT
查詢時,出現如下所示的錯誤。如何將POINTS(LANG,LAT)存儲到PostGIS中的幾何類型列中?
INSERT
查詢:
INSERT INTO itapp_cities(city_id, city_name, city_code, state_id, location)
VALUES (DEFAULT,'Ada', 'ada-ok',37,POINT(34.774531000000003, -96.678344899999999));
表定義:
CREATE TABLE itapp_cities
(
city_id bigserial NOT NULL,
city_name character varying(100) NOT NULL,
city_code character varying(5) NOT NULL DEFAULT ''::character varying,
state_id bigint NOT NULL,
location geometry,
CONSTRAINT itapp_cities_pkey PRIMARY KEY (city_id),
CONSTRAINT fk_states FOREIGN KEY (city_id)
REFERENCES itapp_states (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
)
錯誤:
ERROR: column "location" is of type geometry but expression is of type point LINE 2: VALUES (DEFAULT,'Ada', 'ada-ok',37,POINT(34.77453100000000... ^ HINT: You will need to rewrite or cast the expression. ********** Error ********** ERROR: column "location" is of type geometry but expression is of type point SQL state: 42804
如何將點值存儲在此列中?我是新來的PostGIS所以請原諒我這個愚蠢的問題