-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #476 from OpenHistoricalMap/staging
Update Materialized Views for Natural Earth Lakes
- Loading branch information
Showing
5 changed files
with
25 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
-- This script creates a materialized view for lakes in the Natural Earth dataset, merging data from multiple source tables. | ||
-- Drop the materialized view if it exists | ||
DROP MATERIALIZED VIEW IF EXISTS mview_ne_lakes CASCADE; | ||
|
||
-- Create a new materialized view | ||
-- Create the materialized view with a unique serial ID | ||
CREATE MATERIALIZED VIEW mview_ne_lakes AS | ||
SELECT | ||
'ne_10m_lakes_' || CAST(ogc_fid AS TEXT) AS ogc_fid, | ||
ROW_NUMBER() OVER () AS id, -- Generates a unique sequential ID | ||
name, | ||
wkb_geometry, | ||
ST_Simplify(wkb_geometry, 100) AS wkb_geometry, | ||
'ne_10m_lakes' AS source_table | ||
FROM ne_10m_lakes | ||
WHERE ST_Simplify(wkb_geometry, 100) IS NOT NULL | ||
|
||
UNION ALL | ||
SELECT | ||
'ne_10m_lakes_europe_' || CAST(ogc_fid AS TEXT) AS ogc_fid, | ||
ROW_NUMBER() OVER () + (SELECT COUNT(*) FROM ne_10m_lakes WHERE wkb_geometry IS NOT NULL) AS id, | ||
name, | ||
wkb_geometry, | ||
ST_Simplify(wkb_geometry, 100) AS wkb_geometry, | ||
'ne_10m_lakes_europe' AS source_table | ||
FROM ne_10m_lakes_europe | ||
WHERE ST_Simplify(wkb_geometry, 100) IS NOT NULL | ||
|
||
UNION ALL | ||
SELECT | ||
'ne_10m_lakes_north_america_' || CAST(ogc_fid AS TEXT) AS ogc_fid, | ||
ROW_NUMBER() OVER () | ||
+ (SELECT COUNT(*) FROM ne_10m_lakes WHERE wkb_geometry IS NOT NULL) | ||
+ (SELECT COUNT(*) FROM ne_10m_lakes_europe WHERE wkb_geometry IS NOT NULL) AS id, | ||
name, | ||
wkb_geometry, | ||
ST_Simplify(wkb_geometry, 100) AS wkb_geometry, | ||
'ne_10m_lakes_north_america' AS source_table | ||
FROM ne_10m_lakes_north_america; | ||
FROM ne_10m_lakes_north_america | ||
WHERE ST_Simplify(wkb_geometry, 100) IS NOT NULL; | ||
|
||
-- Create spatial and ID indexes | ||
CREATE INDEX idx_mview_ne_lakes_geom ON mview_ne_lakes USING GIST (wkb_geometry); | ||
CREATE INDEX idx_mview_ne_lakes_ogc_fid ON mview_ne_lakes (ogc_fid); | ||
CREATE INDEX idx_mview_ne_lakes_id ON mview_ne_lakes (id); |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dependencies: | ||
- name: osm-seed | ||
version: '0.1.0-n820.ha0b02a1' | ||
version: '0.1.0-n806.h184cc3c' | ||
repository: https://devseed.com/osm-seed-chart/ |
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
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