-
Notifications
You must be signed in to change notification settings - Fork 4
/
analyse_volta_lignes_RTE.sh
executable file
·50 lines (41 loc) · 1.48 KB
/
analyse_volta_lignes_RTE.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /bin/bash
source $(dirname $0)/config.sh
OUT=volta_lignes_RTE.xml.gz
ERROR=95
rm -f $OUT
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<analysers timestamp=\"`date -u +%Y-%m-%dT%H:%M:%SZ`\">
<analyser timestamp=\"`date -u +%Y-%m-%dT%H:%M:%SZ`\">
<class item=\"7040\" tag=\"power\" id=\"$ERROR\" level=\"3\">
<classtext lang=\"fr\" title=\"ligne électrique HT (power=line) manquante à proximité\" />
<classtext lang=\"en\" title=\"missing power=line in the area\" />
</class>
"| gzip -9 >> $OUT
PGOPTIONS='--client-min-messages=warning' psql osm -qc "
select format('<error class=\"$ERROR\" subclass=\"1\" ><infos id=\"%s\" /><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s\" /></error>',
st_geohash(geom),
st_y(geom),
st_x(geom),
nom)
from (
select
ST_LineInterpolatePoint(wkb_geometry,0.5) as geom,
replace(replace(nom_ligne,'LIAISON ',''),'<','<') as nom
from
rte_lignes_aeriennes t
left join
planet_osm_line h
on (st_dwithin(st_transform(wkb_geometry,3857), h.way,50)
and st_dwithin(ST_LineInterpolatePoint(wkb_geometry,0.5)::geography, st_Transform(h.way,4326)::geography, 20)
and h.power = 'line')
where
tension != 'HORS TENSION'
AND etat = 'EN EXPLOITATION'
AND ST_length(wkb_geometry::geography) > 50
AND h.way is null
group by 1,2
) as error;
" -t | gzip -9 >> $OUT
echo " </analyser>
</analysers>" | gzip -9 >> $OUT
send_frontend $OUT