-
Notifications
You must be signed in to change notification settings - Fork 4
/
analyzer-road-name-ref.sh
executable file
·34 lines (28 loc) · 1.4 KB
/
analyzer-road-name-ref.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
#!/bin/bash
source $(dirname $0)/config.sh
OUT=/home/cquest/public_html/roads-similar-name-ref.xml
OUT=roads-similar-name-ref.xml
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=\"7170\" tag=\"highway\" id=\"3\" level=\"3\">
<classtext lang=\"fr\" title=\"ref=*/name=* similaires sur highway\" />
<classtext lang=\"en\" title=\"similar ref=*/name=* on highway\" />
</class>
" > $OUT
psql osm -c "
select format('<error class=\"3\" subclass=\"1\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"ref=%s name=%s\" /><way id=\"%s\"></way><fixes><fix><way id=\"%s\"><tag action=\"delete\" k=\"name\" v=\"\" /></way></fix></fixes></error>',
round(st_y(ST_Transform(ST_LineInterpolatePoint(l.way,0.5),4326))::numeric,6),
round(st_x(ST_Transform(ST_LineInterpolatePoint(l.way,0.5),4326))::numeric,6),
l.ref,
l.name,
l.osm_id,
l.osm_id)
from planet_osm_line l
join planet_osm_polygon p on (p.way && l.way and st_contains(p.way, ST_LineInterpolatePoint(l.way,0.5)) and p.boundary = 'administrative' and p.tags ? 'ref:INSEE' and p.admin_level='6')
where l.highway is not null and l.ref ~ '^(A|N|D|C|VC|CV|M) [0-9]' and regexp_replace(l.ref,' ','','g')=regexp_replace(l.name,' ','','g');
" -t >> $OUT
echo "
</analyser>
</analysers>" >> $OUT
send_frontend $OUT