119 | | |
| 119 | {{{ |
| 120 | #!sql |
| 121 | |
| 122 | --Insertion des ouvrages français (ROE) dans la dbeel |
| 123 | -- select * from obstacles |
| 124 | |
| 125 | set search_path to belge,onema,public,dbeel; |
| 126 | select * from roe limit 10; |
| 127 | alter table roe set schema onema; |
| 128 | |
| 129 | -- il faut d'abord rentrer un lieu |
| 130 | create table onema.roecourt as (select "Id_ROE", |
| 131 | "roe_Nom", |
| 132 | "bassin_hydrographique", |
| 133 | "bassin_administratif", |
| 134 | "deptCd", |
| 135 | "deptNom", |
| 136 | "commCd", |
| 137 | "commNom", |
| 138 | "ObjFusion_id", |
| 139 | "IdTopo", |
| 140 | "nomTopo", |
| 141 | "IdTrCart", |
| 142 | "nomCart", |
| 143 | "etatNom", |
| 144 | "roe_typeCd", |
| 145 | "roe_typeNom", |
| 146 | "roe_stypeCd", |
| 147 | "roe_stypeNom", |
| 148 | "roe_stypEmCd1", |
| 149 | "roe_stypEmNom1", |
| 150 | "roe_stypEmCd2", |
| 151 | "roe_stypEmNom2", |
| 152 | "roe_stypEmCd3", |
| 153 | "roe_stypEmNom3", |
| 154 | "roe_fnt1_code", |
| 155 | "roe_fnt1_nom", |
| 156 | "roe_fnt2_code", |
| 157 | "roe_fnt2_nom", |
| 158 | "roe_fnt3_code", |
| 159 | "roe_fnt3_nom", |
| 160 | "roe_staCd", |
| 161 | "roe_staNom", |
| 162 | "roe_etatCd", |
| 163 | "roe_dateModif", |
| 164 | "roe_source", |
| 165 | "pre_ice_hauteur_terrain", |
| 166 | "pre_ice_hauteur_chute", |
| 167 | "pre_ice_nom_2", |
| 168 | "pre_ice_date_creation_ouvrage", |
| 169 | "pre_ice_usage1", |
| 170 | "pre_ice_usage2", |
| 171 | "pre_ice_usage3", |
| 172 | "pre_ice_usage4", |
| 173 | "pre_ice_fpi1", |
| 174 | "pre_ice_fpi2", |
| 175 | "pre_ice_fpi3", |
| 176 | "pre_ice_fpi4", |
| 177 | "pre_ice_fpi5", |
| 178 | "pre_ice_note_fr_Anguille", |
| 179 | "roe_commentaire_validation", |
| 180 | "roe_commentaire_suppression" |
| 181 | FROM onema.roe) |
| 182 | |
| 183 | |
| 184 | DROP TABLE if exists onema.roedbeel CASCADE; |
| 185 | CREATE TABLE onema.roedbeel ( |
| 186 | "Id_ROE" character varying, |
| 187 | CONSTRAINT pk_obs_op_id PRIMARY KEY (op_id), |
| 188 | CONSTRAINT c_uk_id_roe UNIQUE ("Id_ROE"), |
| 189 | CONSTRAINT fk_so_observation_place_type_id FOREIGN KEY (op_no_observationplacetype) |
| 190 | REFERENCES dbeel_nomenclature.observation_place_type (no_id) |
| 191 | MATCH SIMPLE ON UPDATE CASCADE ON DELETE RESTRICT |
| 192 | ) INHERITS (dbeel.observation_places); |
| 193 | -- select * from belge.ouvragedbeel; |
| 194 | |
| 195 | INSERT INTO onema.roedbeel |
| 196 | SELECT uuid_generate_v4() AS op_id, |
| 197 | '3035' AS op_gis_systemname , |
| 198 | 'roe' AS op_gis_layername, |
| 199 | "Id_ROE" AS op_gislocation, |
| 200 | "roe_Nom" AS op_placename, |
| 201 | 11 AS op_no_observationplacetype, -- Obstacle location |
| 202 | NULL AS op_op_id, |
| 203 | geom as the_geom, |
| 204 | "Id_ROE" -- on a rajouté qu'une seule colonne, seulement l'identifiant de l'ouvrage.... |
| 205 | FROM onema.roe |
| 206 | where "roe_staCd"=1 ; -- 80262 lines |
| 207 | |
| 208 | --select * from onema.roedbeel |
122 | | |
123 | | |
| 211 | DROP TABLE if exists onema.physical_obstruction CASCADE; |
| 212 | CREATE TABLE onema.physical_obstruction( |
| 213 | LIKE onema.roecourt, |
| 214 | CONSTRAINT physical_obstruction_id PRIMARY KEY (ob_id), |
| 215 | CONSTRAINT fk_dp FOREIGN KEY (ob_dp_id) REFERENCES dbeel.data_provider (dp_id), |
| 216 | CONSTRAINT fk_ob_origin FOREIGN KEY (ob_no_origin)REFERENCES dbeel_nomenclature.observation_origin (no_id) , |
| 217 | CONSTRAINT fk_ob_period FOREIGN KEY (ob_no_period) REFERENCES dbeel_nomenclature.period_type (no_id) , |
| 218 | CONSTRAINT fk_ob_type FOREIGN KEY (ob_no_type) REFERENCES dbeel_nomenclature.observation_type (no_id) , |
| 219 | CONSTRAINT fk_po_obstruction_passability FOREIGN KEY (po_no_obstruction_passability)REFERENCES dbeel_nomenclature.obstruction_impact (no_id) |
| 220 | ) INHERITS (dbeel.physical_obstruction); |
| 221 | |
| 222 | -- select * from belge.physical_obstruction |
| 223 | --select "pre_ice_note_fr_Anguille",count(*) from onema.roe group by "pre_ice_note_fr_Anguille" |
| 224 | INSERT INTO onema.physical_obstruction |
| 225 | SELECT |
| 226 | uuid_generate_v4() as ob_id, |
| 227 | 11 AS ob_no_origin, -- raw data |
| 228 | 16 AS ob_no_type, -- obstruction |
| 229 | 74 AS ob_no_period, -- Unknown |
| 230 | NULL AS ob_starting_date, |
| 231 | NULL AS ob_ending_date, |
| 232 | d.op_id as ob_op_id, |
| 233 | 7 AS ob_dp_id, |
| 234 | 219 as ot_no_obstruction_type, |
| 235 | 1 as ot_obstruction_number, |
| 236 | NULL AS ot_no_mortality_type, |
| 237 | NULL AS ot_no_mortality, |
| 238 | NULL as po_no_obstruction_passability, |
| 239 | case when (pre_ice_hauteur_chute=-999 and pre_ice_hauteur_terrain != -999) then pre_ice_hauteur_terrain |
| 240 | when pre_ice_hauteur_chute=-999 then NULL |
| 241 | else pre_ice_hauteur_chute end as po_obstruction_height, |
| 242 | NULL AS po_turbine_number, |
| 243 | d."Id_ROE", |
| 244 | "roe_Nom", |
| 245 | "bassin_hydrographique", |
| 246 | "bassin_administratif", |
| 247 | "deptCd", |
| 248 | "deptNom", |
| 249 | "commCd", |
| 250 | "commNom", |
| 251 | "ObjFusion_id", |
| 252 | "IdTopo", |
| 253 | "nomTopo", |
| 254 | "IdTrCart", |
| 255 | "nomCart", |
| 256 | "etatNom", |
| 257 | "roe_typeCd", |
| 258 | "roe_typeNom", |
| 259 | "roe_stypeCd", |
| 260 | "roe_stypeNom", |
| 261 | "roe_stypEmCd1", |
| 262 | "roe_stypEmNom1", |
| 263 | "roe_stypEmCd2", |
| 264 | "roe_stypEmNom2", |
| 265 | "roe_stypEmCd3", |
| 266 | "roe_stypEmNom3", |
| 267 | "roe_fnt1_code", |
| 268 | "roe_fnt1_nom", |
| 269 | "roe_fnt2_code", |
| 270 | "roe_fnt2_nom", |
| 271 | "roe_fnt3_code", |
| 272 | "roe_fnt3_nom", |
| 273 | "roe_staCd", |
| 274 | "roe_staNom", |
| 275 | "roe_etatCd", |
| 276 | "roe_dateModif", |
| 277 | "roe_source", |
| 278 | "pre_ice_hauteur_terrain", |
| 279 | "pre_ice_hauteur_chute", |
| 280 | "pre_ice_nom_2", |
| 281 | "pre_ice_date_creation_ouvrage", |
| 282 | "pre_ice_usage1", |
| 283 | "pre_ice_usage2", |
| 284 | "pre_ice_usage3", |
| 285 | "pre_ice_usage4", |
| 286 | "pre_ice_fpi1", |
| 287 | "pre_ice_fpi2", |
| 288 | "pre_ice_fpi3", |
| 289 | "pre_ice_fpi4", |
| 290 | "pre_ice_fpi5", |
| 291 | "pre_ice_note_fr_Anguille", |
| 292 | "roe_commentaire_validation", |
| 293 | "roe_commentaire_suppression" |
| 294 | FROM |
| 295 | onema.roecourt r JOIN onema.roedbeel d ON r."Id_ROE"=d."Id_ROE" |
| 296 | where "roe_staCd"=1;--73332 |
| 297 | |
| 298 | }}} |
| 299 | |
| 300 | |
| 301 | |
| 302 | |