random shit
--- /dev/null
+++ b/nclakes/.gitignore
@@ -1,1 +1,6 @@
+credentials
+out/
+*.csv
+__pycache__/
+osmread/
--- /dev/null
+++ b/nclakes/1_export_all_lakes.sh
@@ -1,1 +1,56 @@
+#!/bin/bash
+
+source settings.sh
+OSM_BIN=/media/ssd/osm-3s_v0.7.52/bin
+BULKUTILS=../bulkupload
+
+
+ODIR=out/
+
+
+echo "Will generate relations"
+echo "TODO: parallelize the thing"
+mkdir $ODIR/
+rm -rf $ODIR/*
+#rm -rf $ODIROSC/*
+
+YFROM=-40
+YTO=70
+TSTEP=4
+for Y in `seq $YFROM $TSTEP $YTO`; do
+ for X in `seq -180 $TSTEP 180`; do
+ X1=$X
+ Y1=$Y
+ X2=$(($X+$TSTEP))
+ Y2=$(($Y+$TSTEP))
+ BOX="($Y1, $X1, $Y2, $X2)"
+ FNAME='rel_'$X1'_'$Y1'_'$X2'_'$Y2
+
+ EXNAME=$ODIR/$FNAME.osm
+ FIXNAME=$ODIR/corr_$FNAME.osm
+ OSCTMP=$ODIR/corr_$FNAME.osc
+ echo $FNAME
+# [timeout:3600]
+# [maxsize:6073741824];
+ $OSM_BIN/osm3s_query > $EXNAME 2>/dev/null << EOF
+ (
+ way[natural=water]
+ $BOX;
+ );
+ out meta;
+EOF
+ fsize=$(wc -c <"$EXNAME")
+ if [ $fsize -gt 251 ]; then
+ ./check_lake.py $EXNAME >> $ALL_LAKES_ORIG
+ rm $EXNAME
+ else
+ rm $EXNAME
+ fi
+ done
+ cat $ALL_LAKES_ORIG | sort -h | uniq > $UNIQ_LAKES
+ ./generate_html.sh
+ echo "Progress: $Y/$YTO"
+done
+
+
--- /dev/null
+++ b/nclakes/check_lake.py
@@ -1,1 +1,25 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+## Frank@Villaro-Dixon.eu - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE, etc.
+from osmread import parse_file, Way, Node
+
+import csv
+import sys
+
+
+f = sys.argv[1]
+csvw = csv.writer(sys.stdout)
+
+#Parse the .osm
+for entity in parse_file(f):
+ if isinstance(entity, Way):
+ nodes = entity.nodes
+ if nodes[0] != nodes[-1]:
+ csvw.writerow([entity.id, nodes[0], nodes[-1], len(nodes)])
+
+
+
+# vim: set ts=4 sw=4 noet:
+
+
--- /dev/null
+++ b/nclakes/disp_html.py
@@ -1,1 +1,40 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+## Frank@Villaro-Dixon.eu - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE, etc.
+import csv
+
+def josm_url_way(iway):
+ return 'http://localhost:8111/load_object?new_layer=true&objects=w{}'.format(iway)
+
+print('<table class="sortable">')
+print('<tr>')
+print('<th>Way id</th>')
+print('<th>links</th>')
+print('<th>Start node</th>')
+print('<th>End nodes</th>')
+print('<th>Way len [nodes]</th>')
+print('</tr>')
+
+with open('uniq_lakes.csv', 'r') as csvf:
+ csvr = csv.reader(csvf)
+ for row in csvr:
+ iway = row[0]
+ ns = row[1]
+ ne = row[2]
+ wl = row[3]
+
+ print('<tr>')
+ print('<td>{}</td>'.format(iway))
+ print('<td id="{}"><a onclick="openWay({});" href="#{}">JOSM</a>'.format(iway, iway, iway))
+ print('— <a href="http://www.openstreetmap.org/way/{}">OSM</a></a></td>'.format(iway))
+ print('<td>{}</td>'.format(ns))
+ print('<td>{}</td>'.format(ne))
+ print('<td>{}</td>'.format(wl))
+ print('</tr>')
+print('</table>')
+
+
+# vim: set ts=4 sw=4 noet:
+
+
--- /dev/null
+++ b/nclakes/footer.html
@@ -1,1 +1,5 @@
+ </body>
+</html>
+
+
--- /dev/null
+++ b/nclakes/generate_html.sh
@@ -1,1 +1,8 @@
+#!/bin/bash
+source settings.sh
+cat header.html > $HTML_OUT
+python3 disp_html.py >> $HTML_OUT
+echo "Last update: $(date -u)<br>" >> $HTML_OUT
+cat footer.html >> $HTML_OUT
+
--- /dev/null
+++ b/nclakes/header.html
@@ -1,1 +1,55 @@
+<!DOCTYPE html>
+<html>
+ <!-- vim: set ts=4 sw=4 noet: -->
+ <head>
+ <title>OSM QA on non closed water bodies</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <script src="https://code.jquery.com/jquery-1.11.3.js"></script>
+ <script src="http://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>
+ <style>
+body {
+ background-color: lightblue;
+}
+table, th, td {
+ border: 2px solid darkblue;
+}
+table {
+ border-collapse: collapse;
+}
+/* Sortable tables */
+table.sortable thead {
+ background-color:#eee;
+ color:#666666;
+ font-weight: bold;
+ cursor: default;
+}
+
+ </style>
+ </head>
+ <body>
+<script type="text/javascript">
+ function openWay(wayid) {
+ var url = 'http://localhost:8111/load_object?new_layer=true&objects=w'+wayid;
+ $.get(url);
+ }
+</script>
+
+<h1>OSM lakes QA</h1>
+<h2>What does it do ?</h2>
+<p>This simple tool checks for <b>non-closed</b> <i>natural=water</i> tags, which
+according semanticaly and according to <a href="http://wiki.openstreetmap.org/wiki/Tag:natural%3Dwater">the wiki</a>
+is not allowed</p>
+<p>The majority of the time, it can either be because:
+<ul>
+ <li>The way is not closed</li>
+ <li>The way is embedded in a relation. In this case, the relation must have the natural=water tag, and it must be removed from
+ the ways<li>
+</ul>
+
+<p>You can click on <b>JOSM</b> to load the way into JOSM
+(needs the prefs->remote to be enabled). The <b>OSM</b> link shows the way into OpenStreetMap</p>
+
+If questions: osm_nclakes@vi-di.fr
+
+
--- /dev/null
+++ b/nclakes/settings.sh
@@ -1,1 +1,7 @@
+ALL_LAKES_ORIG=errors.csv
+UNIQ_LAKES=uniq_lakes.csv
+TMP_BUF_UPDATE=updated.csv
+HTML_OUT=../results/nc_lakes.html
+OSM_BIN=/media/ssd/osm-3s_v0.7.52/bin
+
--- /dev/null
+++ b/nclakes/update_lake.sh
@@ -1,1 +1,18 @@
+#!/bin/bash
+lakeid=$1
+echo my lakeid is $lakeid
+source settings.sh
+ODIR=out/
+
+EXNAME=$ODIR$lakeid.osm
+echo $EXNAME
+$OSM_BIN/osm3s_query > $EXNAME 2>/dev/null << EOF
+way($lakeid);
+out meta;
+EOF
+
+python3 check_lake.py $EXNAME >> $TMP_BUF_UPDATE
+rm $EXNAME
+
+
--- /dev/null
+++ b/nclakes/update_lakes.sh
@@ -1,1 +1,12 @@
+#!/bin/bash
+source settings.sh
+
+
+> $TMP_BUF_UPDATE
+cat $UNIQ_LAKES | sort -h | uniq | cut -d, -f1 | parallel ./update_lake.sh
+
+cat $TMP_BUF_UPDATE | sort -h > $UNIQ_LAKES
+
+./generate_html.sh
+
--- a/rivers_QA/check_river.py
+++ b/rivers_QA/check_river.py
@@ -67,9 +67,13 @@
ele_cache[ilast] = ele_last
if ele_first == -9999:
+ print('Willb')
break
if ele_last == -9999:
+ print('Willb2')
break
+
+ ##print('{} and {}'.format(ele_first, ele_last))
if ele_first+80 < ele_last:
delta = ele_first-ele_last
--- a/rivers_QA/check_river.sh
+++ b/rivers_QA/check_river.sh
@@ -1,5 +1,5 @@
#!/bin/bash
python3 check_river.py $1 >> errors.csv
-gzip $1
+rm $1
--- a/rivers_QA/run_all.sh
+++ /dev/null
@@ -1,56 +1,1 @@
-#!/bin/bash
-
-OSM_BIN=/media/ssd/osm-3s_v0.7.52/bin
-BULKUTILS=../bulkupload
-
-
-ODIR=out/
-
-
-echo "Will generate relations"
-echo "TODO: parallelize the thing"
-mkdir $ODIR/
-rm -rf $ODIR/*
-#rm -rf $ODIROSC/*
-
-YFROM=36
-YTO=70
-TSTEP=2
-for Y in `seq $YFROM $TSTEP $YTO`; do
- for X in `seq -180 $TSTEP 180`; do
- X1=$X
- Y1=$Y
- X2=$(($X+$TSTEP))
- Y2=$(($Y+$TSTEP))
- BOX="($Y1, $X1, $Y2, $X2)"
- FNAME='rel_'$X1'_'$Y1'_'$X2'_'$Y2
-
- EXNAME=$ODIR/$FNAME.osm
- FIXNAME=$ODIR/corr_$FNAME.osm
- OSCTMP=$ODIR/corr_$FNAME.osc
- echo $FNAME
-# [timeout:3600]
-# [maxsize:6073741824];
- $OSM_BIN/osm3s_query > $EXNAME 2>/dev/null << EOF
- (
- way[waterway~"river|stream|canal|drain|ditch"]
- $BOX;
- );
- out meta;
- >;
- out meta;
-EOF
- fsize=$(wc -c <"$EXNAME")
- if [ $fsize -gt 251 ]; then
- ./check_river.sh $EXNAME >> errors.csv
- else
- rm $EXNAME
- fi
- done
- cat errors.csv | sort -h | uniq > uniq_errors.csv
- ./generate_html.sh
- echo "Progress: $Y/$YTO"
-done
-
-