sauvegarde avant reprise 2021

This commit is contained in:
MaelREBOUX 2021-03-07 11:19:18 +01:00
parent 1bb451b51d
commit cfd6df9b33
8 changed files with 3737 additions and 214 deletions

2
.gitignore vendored
View file

@ -49,5 +49,7 @@ scripts/traitements_phase_3_decoupage.fmw.recover
scripts/phase_5.sql
pg_backup/*
scripts/data_backup/*
*.qgs~
scripts/traitements_phase_3_decoupage (backup).fmw

File diff suppressed because one or more lines are too long

40
scripts/load_communes_osm_br.sh Executable file
View file

@ -0,0 +1,40 @@
#!/bin/bash
set -e
set -u
PSQL=/usr/bin/psql
DB_HOST=breizhpolenovo
DB_NAME=redadeg
DB_USER=redadeg
DB_PASSWD=redadeg
# ce script récupère une couche des communes de France et la charge dans la base de données
cd data
# récupérer la couche communales OSM
# https://www.data.gouv.fr/fr/datasets/decoupage-administratif-communal-francais-issu-d-openstreetmap/
wget http://tile.openstreetmap.bzh/data/br/osm_br_municipalities.geojson
#wget pour voir la progression
ogr2ogr -f "PostgreSQL" PG:"host=$DB_HOST user=$DB_USER password=$DB_PASSWD dbname=$DB_NAME" osm_br_municipalities.geojson -nln osm_communes_4326 -lco GEOMETRY_NAME=the_geom -explodecollections -overwrite
# passer la couche de WGS84 en Lambert93
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "TRUNCATE TABLE osm_communes ;"
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "
INSERT INTO osm_communes
SELECT
ogc_fid,
insee,
nom,
wikipedia,
surf_ha,
ST_Transform(ST_SetSRID(the_geom,4326),2154) AS the_geom
FROM osm_communes_4326
WHERE left(insee,2) IN ('22','29','35','44','56')
ORDER BY insee ASC ;"
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "VACUUM FULL osm_communes;"

1124
scripts/phase_5 snap.fmw Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
/*
==========================================================================
phase 2 : création de différentes données à partir du tracé routé
==========================================================================
*/
-- on prend le tracé routé et on fait une version simple
-- 1 ligne par secteur
TRUNCATE TABLE phase_2_trace_secteur ;
WITH trace_ordered AS (
SELECT secteur_id, (ST_Dump(the_geom)).geom AS the_geom
FROM phase_2_trace_pgr
--WHERE secteur_id = 8
ORDER BY secteur_id, path_seq
)
INSERT INTO phase_2_trace_secteur
SELECT
secteur_id, '', '', 0, 0,
ST_COLLECT(the_geom)
--ST_UNION(the_geom)
FROM trace_ordered
GROUP BY secteur_id
ORDER BY secteur_id ;
-- mise à jour des attributs
UPDATE phase_2_trace_secteur a
SET
nom_fr = b.nom_fr,
nom_br = b.nom_br,
longueur = TRUNC( ST_Length(the_geom)::numeric , 0),
longueur_km = TRUNC( ST_Length(the_geom)::numeric / 1000 , 1)
FROM secteur b WHERE a.secteur_id = b.id ;
TRUNCATE phase_2_trace_troncons ;
INSERT INTO phase_2_trace_troncons
SELECT
row_number() over() as uid,
-- infos redadeg
NULL AS secteur_id,
NULL AS ordre,
NULL AS km,
NULL AS km_reel,
NULL AS longueur,
-- infos OSM
t.osm_id, t.highway, t.type, t.oneway, t.ref, t.name_fr, t.name_br,
ST_LineSubstring(the_geom, 1000.00*n/length,
CASE
WHEN 1000.00*(n+1) < length THEN 1000.00*(n+1)/length
ELSE 1
END) AS the_geom
FROM
(SELECT
id,
osm_id, highway, "type", oneway, ref, name_fr, name_br,
ST_LineMerge(the_geom)::geometry(LineString,2154) AS the_geom,
ST_Length(the_geom) As length
FROM phase_2_trace_pgr
-- ce tri est le plus important
ORDER BY id ASC
) AS t
CROSS JOIN generate_series(0,10000) AS n
WHERE n*1000.00/length < 1
ORDER BY t.id ;
-- mise à jour des attributs
UPDATE phase_2_trace_troncons
SET
longueur =
(CASE
WHEN TRUNC( ST_Length(the_geom)::numeric , 0) = 999 THEN 1000
ELSE TRUNC( ST_Length(the_geom)::numeric , 0)
END),
km = uid -- km redadeg
;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,67 @@
#!/bin/bash
# ce traitement consiste à exporter le tracé phase 3 qui a été recalculer
# avec un nommage phase 5
# puis pusk vers le serveur
set -e
set -u
#PSQL=/usr/bin/psql
PSQL=psql
DB_HOST=breizhpolenovo
DB_NAME=redadeg
DB_USER=redadeg
DB_PASS=redadeg
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# et on exporte en geojson pour umap et merour
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo " Exports"
echo ""
echo " exports geojson"
echo ""
rm data/phase_5_trace_secteurs.geojson
ogr2ogr -f "GeoJSON" data/phase_5_trace_secteurs.geojson PG:"host=$DB_HOST user=$DB_USER password=$DB_PASS dbname=$DB_NAME" \
-sql "SELECT * FROM phase_3_trace_secteurs_4326 ORDER BY secteur_id"
rm data/phase_5_trace_troncons.geojson
ogr2ogr -f "GeoJSON" data/phase_5_trace_troncons.geojson PG:"host=$DB_HOST user=$DB_USER password=$DB_PASS dbname=$DB_NAME" \
-sql "SELECT * FROM phase_3_trace_troncons_4326 ORDER BY troncon_id"
echo " exports GML"
echo ""
rm data/phase_2_trace_pgr.gml
ogr2ogr -f "GML" data/phase_2_trace_pgr.gml PG:"host=$DB_HOST user=$DB_USER password=$DB_PASS dbname=$DB_NAME" \
-sql "SELECT * FROM phase_2_trace_pgr ORDER BY secteur_id, path_seq"
echo " fait"
echo ""
echo " pousse vers serveur"
echo ""
rsync -av -z data/phase_5_trace_secteurs.geojson data/phase_5_trace_troncons.geojson data/phase_2_trace_pgr.gml breizhpovh2:/data/www/vhosts/ar-redadeg_openstreetmap_bzh/htdocs/scripts/data/
echo ""
echo " fait"
echo ""
echo ""
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo " F I N"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""