Skip to content

Commit

Permalink
include comparison #311
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludee committed Aug 14, 2018
1 parent 621c68c commit 46436bf
Showing 1 changed file with 51 additions and 17 deletions.
68 changes: 51 additions & 17 deletions preprocessing/sql_snippets/openstreetmap/ego_pp_osm_deu_power.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ INSERT INTO sandbox.ego_pp_osm_deu_power_point_reaosm (osm_id, rea_method, geom)
WHERE generator_source = 'biogas' OR generator_source = 'biomass'
ORDER BY osm_id;


-- insert M2
INSERT INTO sandbox.ego_pp_osm_deu_power_point_reaosm (osm_id, rea_method, geom)
SELECT osm_id,
Expand All @@ -126,6 +125,16 @@ INSERT INTO sandbox.ego_pp_osm_deu_power_point_reaosm (osm_id, rea_method, geom)
WHERE generator_source = 'wind'
ORDER BY osm_id;

-- insert M5
INSERT INTO sandbox.ego_pp_osm_deu_power_point_reaosm (osm_id, rea_method, geom)
SELECT osm_id,
'M5',
geom
FROM sandbox.ego_pp_osm_deu_power_point_mview
WHERE generator_source = 'solar'
ORDER BY osm_id;


/*
-- insert M3
INSERT INTO sandbox.ego_pp_osm_deu_power_point_reaosm (osm_id, rea_method, geom)
Expand Down Expand Up @@ -156,49 +165,74 @@ INSERT INTO sandbox.ego_pp_osm_deu_power_point_reaosm (osm_id, rea_method, geom)
*/


-- extract solar from oedb osm
DROP MATERIALIZED VIEW IF EXISTS openstreetmap.osm_deu_point_solar_mview CASCADE;
CREATE MATERIALIZED VIEW openstreetmap.osm_deu_point_solar_mview AS
-- extract wind from oedb osm
DROP MATERIALIZED VIEW IF EXISTS openstreetmap.osm_deu_point_wind_mview CASCADE;
CREATE MATERIALIZED VIEW openstreetmap.osm_deu_point_wind_mview AS
SELECT osm_id,
gid,
tags,
ST_TRANSFORM(geom, 3035) ::geometry(Point,3035) AS geom
FROM openstreetmap.osm_deu_point
WHERE tags @> '"generator:source"=>"solar"' ::hstore;
WHERE tags @> '"generator:source"=>"wind"'::hstore;

-- index GIST (geom)
CREATE INDEX osm_deu_point_solar_mview_geom_idx
ON openstreetmap.osm_deu_point_solar_mview
CREATE INDEX osm_deu_point_wind_mview_geom_idx
ON openstreetmap.osm_deu_point_wind_mview
USING GIST (geom);

-- grant (oeuser)
ALTER TABLE openstreetmap.osm_deu_point_solar_mview OWNER TO oeuser;
ALTER TABLE openstreetmap.osm_deu_point_wind_mview OWNER TO oeuser;

-- metadata
COMMENT ON MATERIALIZED VIEW openstreetmap.osm_deu_point_solar_mview IS '{
COMMENT ON MATERIALIZED VIEW openstreetmap.osm_deu_point_wind_mview IS '{
"comment": "eGoPP - REA OSM - Temporary Table",
"version": "v0.4.2" }' ;


-- extract wind from oedb osm
DROP MATERIALIZED VIEW IF EXISTS openstreetmap.osm_deu_point_wind_mview CASCADE;
CREATE MATERIALIZED VIEW openstreetmap.osm_deu_point_wind_mview AS
-- extract biomass from oedb osm
DROP MATERIALIZED VIEW IF EXISTS openstreetmap.osm_deu_point_biogas_mview CASCADE;
CREATE MATERIALIZED VIEW openstreetmap.osm_deu_point_biogas_mview AS
SELECT osm_id,
gid,
tags,
ST_TRANSFORM(geom, 3035) ::geometry(Point,3035) AS geom
FROM openstreetmap.osm_deu_point
WHERE tags @> '"generator:source"=>"wind"'::hstore;
WHERE tags @> '"generator:source"=>"biogas"' ::hstore
OR tags @> '"generator:source"=>"biomass"' ::hstore ;

-- index GIST (geom)
CREATE INDEX osm_deu_point_wind_mview_geom_idx
ON openstreetmap.osm_deu_point_wind_mview
CREATE INDEX osm_deu_point_biogas_mview_geom_idx
ON openstreetmap.osm_deu_point_biogas_mview
USING GIST (geom);

-- grant (oeuser)
ALTER TABLE openstreetmap.osm_deu_point_wind_mview OWNER TO oeuser;
ALTER TABLE openstreetmap.osm_deu_point_biogas_mview OWNER TO oeuser;

-- metadata
COMMENT ON MATERIALIZED VIEW openstreetmap.osm_deu_point_wind_mview IS '{
COMMENT ON MATERIALIZED VIEW openstreetmap.osm_deu_point_biogas_mview IS '{
"comment": "eGoPP - REA OSM - Temporary Table",
"version": "v0.4.2" }' ;


-- extract solar from oedb osm
DROP MATERIALIZED VIEW IF EXISTS openstreetmap.osm_deu_point_solar_mview CASCADE;
CREATE MATERIALIZED VIEW openstreetmap.osm_deu_point_solar_mview AS
SELECT osm_id,
gid,
tags,
ST_TRANSFORM(geom, 3035) ::geometry(Point,3035) AS geom
FROM openstreetmap.osm_deu_point
WHERE tags @> '"generator:source"=>"solar"' ::hstore;

-- index GIST (geom)
CREATE INDEX osm_deu_point_solar_mview_geom_idx
ON openstreetmap.osm_deu_point_solar_mview
USING GIST (geom);

-- grant (oeuser)
ALTER TABLE openstreetmap.osm_deu_point_solar_mview OWNER TO oeuser;

-- metadata
COMMENT ON MATERIALIZED VIEW openstreetmap.osm_deu_point_solar_mview IS '{
"comment": "eGoPP - REA OSM - Temporary Table",
"version": "v0.4.2" }' ;

0 comments on commit 46436bf

Please sign in to comment.