Merge branch 'master' of https://github.com/osm-bzh/ar_redadeg
This commit is contained in:
commit
11c6b87a0d
|
@ -195,6 +195,36 @@ CREATE VIEW phase_2_pk_secteur_4326 AS
|
|||
ALTER TABLE phase_2_pk_secteur_4326 OWNER to redadeg;
|
||||
|
||||
|
||||
-- les polygones des communes
|
||||
DROP TABLE IF EXISTS osm_communes ;
|
||||
CREATE TABLE osm_communes
|
||||
(
|
||||
gid serial,
|
||||
insee character varying(80),
|
||||
nom character varying(80),
|
||||
wikipedia character varying(80),
|
||||
surf_ha numeric,
|
||||
the_geom geometry,
|
||||
CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POLYGON'::text OR geometrytype(the_geom) = 'MULTIPOLYGON'::text),
|
||||
CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 2154),
|
||||
CONSTRAINT osm_communes_pkey PRIMARY KEY (gid)
|
||||
);
|
||||
CREATE INDEX osm_communes_geom_idx ON osm_communes USING gist(the_geom);
|
||||
ALTER TABLE osm_communes OWNER to redadeg;
|
||||
|
||||
/*
|
||||
INSERT INTO osm_communes
|
||||
SELECT
|
||||
gid,
|
||||
insee,
|
||||
nom,
|
||||
wikipedia,
|
||||
surf_ha,
|
||||
ST_Transform(ST_SetSRID(geom,4326),2154) AS the_geom
|
||||
FROM osm_communes_4326
|
||||
ORDER BY insee ASC ;
|
||||
*/
|
||||
|
||||
-- la couche qui contient les lignes des routes venant de OSM
|
||||
DROP TABLE IF EXISTS osm_roads ;
|
||||
CREATE TABLE osm_roads
|
||||
|
@ -212,6 +242,7 @@ CREATE TABLE osm_roads
|
|||
CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'LINESTRING'::text OR geometrytype(the_geom) = 'MULTILINESTRING'::text),
|
||||
CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 2154)
|
||||
);
|
||||
CREATE INDEX osm_roads_geom_idx ON osm_roads USING gist(the_geom);
|
||||
ALTER TABLE osm_roads OWNER to redadeg;
|
||||
|
||||
|
||||
|
@ -359,7 +390,7 @@ CREATE VIEW phase_2_trace_secteur_4326 AS
|
|||
ALTER TABLE phase_2_trace_secteur_4326 OWNER to redadeg;
|
||||
|
||||
|
||||
|
||||
-- ça sert à quoi ça ?
|
||||
DROP TABLE IF EXISTS phase_2_trace_trous ;
|
||||
CREATE TABLE phase_2_trace_trous
|
||||
(
|
||||
|
|
33
scripts/load_communes.sh
Normal file
33
scripts/load_communes.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
# ce script récupère une couche des communes de France et la charge dans la base de données
|
||||
|
||||
# récupérer la couche communales OSM
|
||||
# https://www.data.gouv.fr/fr/datasets/decoupage-administratif-communal-francais-issu-d-openstreetmap/
|
||||
wget http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20190101-shp.zip
|
||||
|
||||
mv communes-20190101-shp.zip data/
|
||||
unzip communes-20190101-shp.zip
|
||||
|
||||
|
||||
# tansformer le shape en requête insert
|
||||
shp2pgsql -I communes-20190101.shp osm_communes > osm_communes.sql
|
||||
|
||||
# charger
|
||||
psql -d redadeg -U redadeg -W < osm_communes.sql
|
||||
|
||||
# passer la couche de WGS84 en Lambert93
|
||||
psql -c "INSERT INTO osm_communes
|
||||
SELECT
|
||||
gid,
|
||||
insee,
|
||||
nom,
|
||||
wikipedia,
|
||||
surf_ha,
|
||||
ST_Transform(ST_SetSRID(geom,4326),2154) AS the_geom
|
||||
FROM osm_communes_4326
|
||||
ORDER BY insee ASC ;"
|
||||
|
||||
|
||||
# /!\ penser à ne garder que les communes nécessaires pour des questions de performance
|
||||
|
|
@ -5,8 +5,8 @@ UPDATE secteur SET km_reels = 180 WHERE id = 3 ;
|
|||
UPDATE secteur SET km_reels = 187 WHERE id = 4 ;
|
||||
UPDATE secteur SET km_reels = 216 WHERE id = 5 ;
|
||||
UPDATE secteur SET km_reels = 290 WHERE id = 6 ;
|
||||
UPDATE secteur SET km_reels = 200 WHERE id = 7 ;
|
||||
UPDATE secteur SET km_reels = 223 WHERE id = 7 ;
|
||||
UPDATE secteur SET km_reels = 55 WHERE id = 8 ;
|
||||
UPDATE secteur SET km_reels = 285 WHERE id = 9 ;
|
||||
UPDATE secteur SET km_reels = 129 WHERE id = 10 ;
|
||||
UPDATE secteur SET km_reels = 126 WHERE id = 10 ;
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
-- 30 s
|
||||
-- on commence par vider les couches existantes
|
||||
TRUNCATE TABLE osm_roads_pgr ;
|
||||
TRUNCATE TABLE osm_roads_pgr_noded ;
|
||||
TRUNCATE TABLE osm_roads_pgr_vertices_pgr ;
|
||||
DROP TABLE IF EXISTS osm_roads_pgr_noded ;
|
||||
DROP TABLE IF EXISTS osm_roads_pgr_vertices_pgr ;
|
||||
|
||||
|
||||
-- reset de la sequence
|
||||
ALTER SEQUENCE public.osm_roads_pgr_noded_id_seq RESTART WITH 1 ;
|
||||
|
|
Loading…
Reference in a new issue