-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1149 switch to formatting geojson in postgres
- Loading branch information
1 parent
53fbe36
commit 5eeea9f
Showing
2 changed files
with
50 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
volumes/open_data/sql/create-view-cycling_permanent_counts_locations_geojson.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
CREATE OR REPLACE VIEW open_data.cycling_permanent_counts_locations_geojson AS | ||
WITH features AS ( | ||
SELECT json_build_object( | ||
'type', 'Feature', | ||
'id', location_dir_id, | ||
'geometry', st_asgeojson(st_setsrid(st_makepoint(longitude, latitude), 4326))::jsonb, | ||
'attributes', json_build_object( | ||
'location_dir_id', location_dir_id, | ||
'location_name', location_name, | ||
'direction', direction, | ||
'linear_name_full', linear_name_full, | ||
'side_street', side_street, | ||
'centreline_id', centreline_id, | ||
'bin_size', bin_size, | ||
'latest_calibration_study', latest_calibration_study, | ||
'first_active', first_active, | ||
'last_active', last_active, | ||
'date_decommissioned', date_decommissioned, | ||
'technology', technology | ||
) | ||
) AS features | ||
FROM open_data.cycling_permanent_counts_locations | ||
) | ||
|
||
--aggregate features into FeatureCollection | ||
SELECT json_build_object( | ||
'type', | ||
'FeatureCollection', | ||
'features', | ||
json_agg(features.features) | ||
) AS featurecollection | ||
FROM features; | ||
|
||
ALTER VIEW open_data.cycling_permanent_counts_locations_geojson OWNER TO od_admins; | ||
|
||
GRANT SELECT ON open_data.cycling_permanent_counts_locations_geojson TO ecocounter_bot; | ||
GRANT SELECT ON open_data.cycling_permanent_counts_locations_geojson TO bdit_humans; |