Skip to content

Commit

Permalink
Added new table
Browse files Browse the repository at this point in the history
  • Loading branch information
shievaniR authored Aug 1, 2020
1 parent 109ed89 commit 6a595f0
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions sql/geom.sql
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
CREATE TABLE towers (
radio text,
mcc smallint,
net integer,
area integer,
cell integer,
unit smallint,
long double precision,
lat double precision,
range integer,
samples smallint,
changeable smallint,
created interval,
updated interval,
averagesignal smallint,
geom geometry
CREATE TABLE btowers(
LSA text,
District text,
Latitude double precision,
Longitude double precision,
Sitetype text
);
ALTER TABLE towers ADD COLUMN geom geometry(Point, 4326);
UPDATE towers SET geom = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326);
SELECT json_build_object('type', 'FeatureCollection','crs', json_build_object('type','name','properties', json_build_object('name','EPSG:4326')),'features', json_agg(json_build_object('type','Feature','geometry',ST_AsGeoJSON(geom)::json,'properties', json_build_object('radio', radio,'mcc',mcc,'net',net,'area',area,'cell', cell,'long', long,'lat',lat,'range',range)))) FROM towers WHERE geom && ST_SetSRID('BOX3D("+req.body.west+" "+req.body.south+","+req.body.east+" "+req.body.north+")'::box3d,4326)

ALTER TABLE btowers ADD COLUMN geom geometry(Point, 4326);
UPDATE btowers SET geom = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326);

SELECT json_build_object('type', 'FeatureCollection','crs', json_build_object('type','name','properties', json_build_object('name','EPSG:4326')),'features', json_agg(json_build_object('type','Feature','geometry',ST_AsGeoJSON(geom)::json,'properties', json_build_object('LSA',lsa,'District',district,'latitude',latitude,'longitude',longitude,'Sitetype', sitetype)))) FROM btowers;

0 comments on commit 6a595f0

Please sign in to comment.