Skip to content

Commit 59b202d

Browse files
authored
fix(forest types tiles): add data for canton SZ
2 parents 1a55999 + 5fc3b9d commit 59b202d

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ lib/data/spatial/forest_types_gl
6262
lib/data/spatial/forest_types_ju
6363
lib/data/spatial/forest_types_lu
6464
lib/data/spatial/forest_types_ne
65+
lib/data/spatial/forest_types_sz
6566
lib/data/spatial/forest_types_sg
6667
lib/data/spatial/forest_types_sh
6768
lib/data/spatial/forest_types_so

lib/data/spatial/1-import.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,5 @@ _import "Download manually" "forest_types_so" "forest_types_so" "forest_types_so
103103
_import "Download manually" "forest_types_gl" "forest_types_gl" "forest_types_gl"
104104

105105
_import "Download manually" "forest_types_ar" "forest_types_ar" "forest_types_ar"
106+
107+
_import "Download manually" "forest_types_sz" "forest_types_sz" "forest_types_sz"

lib/data/sql/export_spatial.sql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ WITH altitudinal_zones_cantonal AS
122122
FROM forest_types_ar
123123
WHERE hs_code IS NOT NULL and geom is not null
124124
GROUP BY hs_code, hsue_code)
125+
UNION
126+
(SELECT
127+
ST_Union(geom) AS geom,
128+
CASE hsue_code is null
129+
WHEN TRUE THEN hs_code::text
130+
ELSE hs_code::text || '(' || hsue_code::text || ')'
131+
END AS code,
132+
hs_code::text as code_style
133+
FROM forest_types_sz
134+
WHERE hs_code IS NOT NULL and geom is not null
135+
GROUP BY hs_code, hsue_code)
125136
)foo )
126137

127138
SELECT (code::TEXT || subcode::TEXT)::text AS code, (code::TEXT || subcode::TEXT)::text AS code_style,
@@ -327,5 +338,13 @@ SELECT nais AS code,
327338
nais as code_so,
328339
null as info_vd
329340
FROM forest_types_ar
341+
WHERE nais IS NOT NULL and geom is not null
342+
UNION
343+
SELECT nais AS code,
344+
ST_Transform(geom, 3857) as geometry,
345+
nais as code_vd,
346+
nais as code_so,
347+
null as info_vd
348+
FROM forest_types_sz
330349
WHERE nais IS NOT NULL and geom is not null;
331350

lib/data/sql/import_data.sql

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ ADD
13151315
PRIMARY KEY (gid);
13161316
SELECT
13171317
AddGeometryColumn(
1318-
'', 'forest_types_ju', 'geom', '0',
1318+
'', 'forest_types_ju', 'geom', '2056',
13191319
'MULTIPOLYGON', 2
13201320
);
13211321
----------------------------------------------
@@ -1334,7 +1334,7 @@ ADD
13341334
PRIMARY KEY (gid);
13351335
SELECT
13361336
AddGeometryColumn(
1337-
'', 'forest_types_bl', 'geom', '0',
1337+
'', 'forest_types_bl', 'geom', '2056',
13381338
'MULTIPOLYGON', 2
13391339
);
13401340
----------------------------------------------
@@ -1353,7 +1353,7 @@ ADD
13531353
PRIMARY KEY (gid);
13541354
SELECT
13551355
AddGeometryColumn(
1356-
'', 'forest_types_vd', 'geom', '0',
1356+
'', 'forest_types_vd', 'geom', '2056',
13571357
'MULTIPOLYGON', 2
13581358
);
13591359
----------------------------------------------
@@ -1370,7 +1370,31 @@ ADD
13701370
SELECT
13711371
AddGeometryColumn(
13721372
'', 'altitudinal_zones_vd', 'geom',
1373-
'0', 'MULTIPOLYGON', 2
1373+
'2056', 'MULTIPOLYGON', 2
1374+
);
1375+
----------------------------------------------
1376+
-- Forest types SZ
1377+
CREATE TABLE "forest_types_sz" (
1378+
"fid" serial,
1379+
"sz_einheit" varchar(80),
1380+
"nais" varchar(80),
1381+
"nais1" varchar(80),
1382+
"nais2" varchar(80),
1383+
"mo" numeric,
1384+
"ue" numeric,
1385+
"tahs" varchar(80),
1386+
"tahsue" varchar(80),
1387+
"hs_code" numeric,
1388+
"hsue_code" integer
1389+
);
1390+
ALTER TABLE
1391+
"forest_types_sz"
1392+
ADD
1393+
PRIMARY KEY (gid);
1394+
SELECT
1395+
AddGeometryColumn(
1396+
'', 'forest_types_sz', 'geom', '2056',
1397+
'MULTIPOLYGON', 2
13741398
);
13751399
----------------------------------------------
13761400
-- Forest types SG
@@ -1392,7 +1416,7 @@ ADD
13921416
PRIMARY KEY (gid);
13931417
SELECT
13941418
AddGeometryColumn(
1395-
'', 'forest_types_sg', 'geom', '0',
1419+
'', 'forest_types_sg', 'geom', '2056',
13961420
'MULTIPOLYGON', 2
13971421
);
13981422
----------------------------------------------
@@ -1415,7 +1439,7 @@ ADD
14151439
PRIMARY KEY (gid);
14161440
SELECT
14171441
AddGeometryColumn(
1418-
'', 'forest_types_sh', 'geom', '0',
1442+
'', 'forest_types_sh', 'geom', '2056',
14191443
'MULTIPOLYGON', 2
14201444
);
14211445
----------------------------------------------
@@ -1435,7 +1459,7 @@ ADD
14351459
PRIMARY KEY (gid);
14361460
SELECT
14371461
AddGeometryColumn(
1438-
'', 'forest_types_so', 'geom', '0',
1462+
'', 'forest_types_so', 'geom', '2056',
14391463
'MULTIPOLYGON', 2
14401464
);
14411465
----------------------------------------------
@@ -1461,7 +1485,7 @@ CREATE TABLE "forest_types_gl" (gid serial,
14611485
"hsue_code" float8);
14621486

14631487
ALTER TABLE "forest_types_gl" ADD PRIMARY KEY (gid);
1464-
SELECT AddGeometryColumn('','forest_types_gl','geom','0','MULTIPOLYGON',2);
1488+
SELECT AddGeometryColumn('','forest_types_gl','geom', '2056','MULTIPOLYGON',2);
14651489

14661490

14671491
----------------------------------------------
@@ -1482,7 +1506,7 @@ CREATE TABLE "forest_types_ar" (gid serial,
14821506
"hsue_code" float8);
14831507

14841508
ALTER TABLE "forest_types_ar" ADD PRIMARY KEY (gid);
1485-
SELECT AddGeometryColumn('','forest_types_ar','geom','0','MULTIPOLYGON',2);
1509+
SELECT AddGeometryColumn('','forest_types_ar','geom', '2056','MULTIPOLYGON', 2);
14861510

14871511

14881512

@@ -3247,4 +3271,5 @@ COPY ecograms
32473271
FROM
32483272
'/data/ecograms.csv' DELIMITER ';' CSV HEADER;
32493273

3274+
DROP SCHEMA IF EXISTS export CASCADE;
32503275
CREATE SCHEMA export;

0 commit comments

Comments
 (0)