Skip to content

Commit

Permalink
Unique subclass osm-fr#2 osm-fr#3
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed Nov 14, 2019
1 parent 1648401 commit 7f90e6a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions analyse-bano.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ PGOPTIONS='--client-min-messages=warning' psql osm -qc "
select * from (
select case
when id is null
then format('<error class=\"33\" subclass=\"1\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /></error>',
lat,lon,voie_cadastre,fantoir)
then format('<error class=\"33\" subclass=\"%s\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /></error>',
subclass,lat,lon,voie_cadastre,fantoir)
when id_noname is not null and id_noname not like '%,%' and (l_geom-l_ways_noname<100) and ((l_noname > 0.5 and l2_noname<100) or (l_noname > 0.75)) and upper(voie_cadastre)!=voie_cadastre
then format('<error class=\"32\" subclass=\"1\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /><way id=\"%s\"></way><fixes><fix><way id=\"%s\"><tag action=\"create\" k=\"name\" v=\"%s\" /></way></fix></fixes></error>',
lat,lon,voie_cadastre,fantoir,id_noname,id_noname,voie_cadastre)
then format('<error class=\"32\" subclass=\"%s\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /><way id=\"%s\"></way><fixes><fix><way id=\"%s\"><tag action=\"create\" k=\"name\" v=\"%s\" /></way></fix></fixes></error>',
subclass,lat,lon,voie_cadastre,fantoir,id_noname,id_noname,voie_cadastre)
when id is not null and id not like '%,%' and (l_geom-l_ways<100) and ((l > 0.5 and l2 < 100) or (l>0.75)) and names is null and upper(voie_cadastre)!=voie_cadastre
then format('<error class=\"32\" subclass=\"1\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /><way id=\"%s\"></way><fixes><fix><way id=\"%s\"><tag action=\"create\" k=\"name\" v=\"%s\" /></way></fix></fixes></error>',
lat,lon,voie_cadastre,fantoir,id,id,voie_cadastre)
then format('<error class=\"32\" subclass=\"%s\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /><way id=\"%s\"></way><fixes><fix><way id=\"%s\"><tag action=\"create\" k=\"name\" v=\"%s\" /></way></fix></fixes></error>',
subclass,lat,lon,voie_cadastre,fantoir,id,id,voie_cadastre)
when id is not null and id not like '%,%' and (l_geom-l_ways<100) and ((l > 0.5 and l2 < 100) or (l>0.75)) and names is not null and upper(voie_cadastre)!=voie_cadastre
then format('<error class=\"31\" subclass=\"1\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /><way id=\"%s\"><tag k=\"name\" v=\"%s\" /></way><fixes><fix><way id=\"%s\"><tag action=\"modify\" k=\"name\" v=\"%s\" /></way></fix><fix><way id=\"%s\"><tag action=\"create\" k=\"ref:FR:FANTOIR\" v=\"%s\" /></way></fix></fixes></error>',
lat,lon,voie_cadastre,fantoir,id,names,id,voie_cadastre,id,fantoir)
then format('<error class=\"31\" subclass=\"%s\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /><way id=\"%s\"><tag k=\"name\" v=\"%s\" /></way><fixes><fix><way id=\"%s\"><tag action=\"modify\" k=\"name\" v=\"%s\" /></way></fix><fix><way id=\"%s\"><tag action=\"create\" k=\"ref:FR:FANTOIR\" v=\"%s\" /></way></fix></fixes></error>',
subclass,lat,lon,voie_cadastre,fantoir,id,names,id,voie_cadastre,id,fantoir)
when names ~* voie_cadastre then ''
else format('<error class=\"30\" subclass=\"1\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /></error>',
lat,lon,voie_cadastre,fantoir)
else format('<error class=\"30\" subclass=\"%s\"><location lat=\"%s\" lon=\"%s\" /><text lang=\"fr\" value=\"%s (%s)\" /></error>',
subclass,lat,lon,voie_cadastre,fantoir)
end as er
from (select round(st_x(st_transform(st_centroid(geom),4326))::numeric,6) as lon, round(st_y(st_transform(st_centroid(geom),4326))::numeric,6) as lat,
from (select
abs(('x'||md5(coalesce(nom_voie, replace(voie_cadastre,E'\x22','')) || f.fantoir || ST_AsText(geom)))::bit(64)::bigint) AS subclass,
round(st_x(st_transform(st_centroid(geom),4326))::numeric,6) as lon, round(st_y(st_transform(st_centroid(geom),4326))::numeric,6) as lat,
coalesce(nom_voie, replace(voie_cadastre,E'\x22','')) as voie_cadastre, f.fantoir, replace(names,E'\x22','') as names, id, id_noname,
st_length(st_intersection(ways,st_buffer(geom,20)))/st_length(ways) as l,
st_length(st_transform(ways,4326)::geography)-st_length(st_transform(st_intersection(ways,geom),4326)::geography) as l2,
Expand Down

0 comments on commit 7f90e6a

Please sign in to comment.