Add PostGIS GeoJSON support
Works for GET, POST, PATCH, PUT, DELETE, RPC.
This commit is contained in:
committed by
Steve Chavez
parent
86c40e8df9
commit
870f7a39b0
Vendored
+11
@@ -784,3 +784,14 @@ INSERT INTO test.bulk_update_items (id, name, observation) VALUES (1, 'item-1',
|
||||
|
||||
TRUNCATE TABLE test.bulk_update_items_cpk CASCADE;
|
||||
INSERT INTO test.bulk_update_items_cpk (id, name, observation) VALUES (1, 'item-1', NULL), (2, 'item-2', NULL), (3, 'item-3', NULL);
|
||||
|
||||
TRUNCATE TABLE shops CASCADE;
|
||||
INSERT INTO shops(id, address, shop_geom) VALUES(1, '1369 Cambridge St', 'SRID=4326;POINT(-71.10044 42.373695)');
|
||||
INSERT INTO shops(id, address, shop_geom) VALUES(2, '757 Massachusetts Ave', 'SRID=4326;POINT(-71.10543 42.366432)');
|
||||
INSERT INTO shops(id, address, shop_geom) VALUES(3, '605 W Kendall St', 'SRID=4326;POINT(-71.081924 42.36437)');
|
||||
|
||||
TRUNCATE TABLE shop_bles CASCADE;
|
||||
INSERT INTO shop_bles(id, name, coords, shop_id, range_area) VALUES(1, 'Beacon-1', 'SRID=4326;POINT(-71.10044 42.373695)', 1,
|
||||
extensions.ST_GeomFromGeoJSON('{"type": "Polygon", "coordinates": [ [ [ -71.10045254230499, 42.37387083326593 ], [ -71.10048070549963, 42.37377126199953 ], [ -71.10039688646793, 42.37375838212269 ], [ -71.10037006437777, 42.37385844878863 ], [ -71.10045254230499, 42.37387083326593 ] ] ]}'));
|
||||
INSERT INTO shop_bles(id, name, coords, shop_id, range_area) VALUES(2, 'Beacon-2', 'SRID=4326;POINT(-71.10044 42.373695)', 1,
|
||||
extensions.ST_GeomFromGeoJSON('{"type": "Polygon", "coordinates": [ [ [ -71.10034391283989, 42.37385299961788 ], [ -71.10036939382553, 42.373756895982865 ], [ -71.1002916097641, 42.373745997623224 ], [ -71.1002641171217, 42.37384408279195 ], [ -71.10034391283989, 42.37385299961788 ] ] ]}'));
|
||||
|
||||
Vendored
+2
@@ -188,6 +188,8 @@ GRANT ALL ON TABLE
|
||||
, view_test
|
||||
, bulk_update_items
|
||||
, bulk_update_items_cpk
|
||||
, shops
|
||||
, shop_bles
|
||||
TO postgrest_test_anonymous;
|
||||
|
||||
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
||||
|
||||
Vendored
+20
@@ -2649,3 +2649,23 @@ CREATE TABLE test.bulk_update_items_cpk (
|
||||
observation TEXT,
|
||||
PRIMARY KEY (id, name)
|
||||
);
|
||||
|
||||
create extension if not exists postgis with schema extensions;
|
||||
|
||||
create table shops (
|
||||
id int primary key
|
||||
, address text
|
||||
, shop_geom extensions.geometry(POINT, 4326)
|
||||
);
|
||||
|
||||
create table shop_bles (
|
||||
id int primary key
|
||||
, name text
|
||||
, coords extensions.geometry(POINT, 4326)
|
||||
, range_area extensions.geometry(POLYGON, 4326)
|
||||
, shop_id int references shops(id)
|
||||
);
|
||||
|
||||
create function get_shop(id int) returns shops as $$
|
||||
select * from shops where id = $1;
|
||||
$$ language sql;
|
||||
|
||||
Reference in New Issue
Block a user