mirror of
https://github.com/brmlab/povoden.git
synced 2025-06-09 10:45:16 +02:00
use loops for weather stations
This commit is contained in:
parent
41744ccc85
commit
352d86ce9c
2 changed files with 43 additions and 84 deletions
48
Makefile
48
Makefile
|
@ -1,25 +1,21 @@
|
||||||
|
.PHONY : clean refresh
|
||||||
|
|
||||||
HAML=haml
|
HAML=haml
|
||||||
XMLLINT=xmllint --html --nowarning
|
XMLLINT=xmllint --html --nowarning
|
||||||
|
|
||||||
|
# expand as needed
|
||||||
|
VODASTATIONS=307225 307081 307228
|
||||||
|
|
||||||
# option #1
|
# option #1
|
||||||
VODAURL=http://hydro.chmi.cz/hpps/popup_hpps_prfdyn.php?seq=307225
|
VODAURL=http://hydro.chmi.cz/hpps/popup_hpps_prfdyn.php?seq=$(STATION)
|
||||||
VODAIMG1=http://hydro.chmi.cz/hpps/tmp/img/big/307225_H.png
|
VODAIMG1=http://hydro.chmi.cz/hpps/tmp/img/big/$(STATION)_H.png
|
||||||
VODAIMG2=http://hydro.chmi.cz/hpps/tmp/img/big/307225_Q.png
|
VODAIMG2=http://hydro.chmi.cz/hpps/tmp/img/big/$(STATION)_Q.png
|
||||||
|
|
||||||
VODAURL_MELNIK=http://hydro.chmi.cz/hpps/popup_hpps_prfdyn.php?seq=307081
|
|
||||||
VODAIMG1_MELNIK=http://hydro.chmi.cz/hpps/tmp/img/big/307081_H.png
|
|
||||||
VODAIMG2_MELNIK=http://hydro.chmi.cz/hpps/tmp/img/big/307081_Q.png
|
|
||||||
|
|
||||||
VODAURL_USTI=http://hydro.chmi.cz/hpps/popup_hpps_prfdyn.php?seq=307228
|
|
||||||
VODAIMG1_USTI=http://hydro.chmi.cz/hpps/tmp/img/big/307228_H.png
|
|
||||||
VODAIMG2_USTI=http://hydro.chmi.cz/hpps/tmp/img/big/307228_Q.png
|
|
||||||
|
|
||||||
VODAXPATH=//table[@class="stdstationtbl"]/./tr[3]//table/tr[position()>1]
|
VODAXPATH=//table[@class="stdstationtbl"]/./tr[3]//table/tr[position()>1]
|
||||||
|
|
||||||
# option #2
|
# option #2
|
||||||
#VODAURL=http://vvv.chmi.cz/hydro/detail_stanice/307225.html
|
#VODAURL=http://vvv.chmi.cz/hydro/detail_stanice/$(STATION).html
|
||||||
#VODAIMG1=http://vvv.chmi.cz/hydro/graph/big/307225_H.png
|
#VODAIMG1=http://vvv.chmi.cz/hydro/graph/big/$(STATION)_H.png
|
||||||
#VODAIMG2=http://vvv.chmi.cz/hydro/graph/big/307225_Q.png
|
#VODAIMG2=http://vvv.chmi.cz/hydro/graph/big/$(STATION)_Q.png
|
||||||
#VODAXPATH=//table[2]//tr[3]/td//table//tr[position()>1]
|
#VODAXPATH=//table[2]//tr[3]/td//table//tr[position()>1]
|
||||||
|
|
||||||
DOPRAVAURL=http://www.dpp.cz/povodne-aktualni-doprava/
|
DOPRAVAURL=http://www.dpp.cz/povodne-aktualni-doprava/
|
||||||
|
@ -27,21 +23,19 @@ DOPRAVATMP=/tmp/doprava.html
|
||||||
DOPRAVAXPATH1=string(//div[@id="content-container"]/div[@id="pole"]/div/div[2]//a[starts-with(@title,"Stav dopravy k")]/@href)
|
DOPRAVAXPATH1=string(//div[@id="content-container"]/div[@id="pole"]/div/div[2]//a[starts-with(@title,"Stav dopravy k")]/@href)
|
||||||
DOPRAVAXPATH2=//div[@id="content-container"]/div[@id="pole"]/div/div[2]//*[@class="img-c img-envelope"]/../preceding-sibling::*
|
DOPRAVAXPATH2=//div[@id="content-container"]/div[@id="pole"]/div/div[2]//*[@class="img-c img-envelope"]/../preceding-sibling::*
|
||||||
|
|
||||||
|
# function
|
||||||
|
get-voda = \
|
||||||
|
echo Station $(STATION) \
|
||||||
|
wget '$(VODAIMG1)' -O data/stav_$(STATION).png_; \
|
||||||
|
wget '$(VODAIMG2)' -O data/prutok_$(STATION).png_; \
|
||||||
|
wget '$(VODAURL)' -O - | $(XMLLINT) --encode utf8 - | $(XMLLINT) --xpath '$(VODAXPATH)' - > data/table_$(STATION).html_; \
|
||||||
|
$(foreach FILE,data/stav_$(STATION).png data/prutok_$(STATION).png data/table_$(STATION).html,mv -v $(FILE)_ $(FILE);)
|
||||||
|
|
||||||
all: index.html doprava.html pomoc.html kontakty.html
|
all: index.html doprava.html pomoc.html kontakty.html
|
||||||
|
|
||||||
refresh:
|
refresh:
|
||||||
wget '$(VODAIMG1)' -O data/stav_.png
|
$(foreach STATION,$(VODASTATIONS), $(call get-voda) )
|
||||||
wget '$(VODAIMG2)' -O data/prutok_.png
|
sed -i 's/@stations\s*=.*/@stations=[$(foreach STATION,$(VODASTATIONS), $(STATION)\, )]/' index.haml
|
||||||
wget '$(VODAURL)' -O - | $(XMLLINT) --encode utf8 - | $(XMLLINT) --xpath '$(VODAXPATH)' - > data/table_.html
|
|
||||||
mv data/stav_.png data/stav.png && mv data/prutok_.png data/prutok.png && mv data/table_.html data/table.html
|
|
||||||
wget '$(VODAIMG1_MELNIK)' -O data/stav_melnik_.png
|
|
||||||
wget '$(VODAIMG2_MELNIK)' -O data/prutok_melnik_.png
|
|
||||||
wget '$(VODAURL_MELNIK)' -O - | $(XMLLINT) --encode utf8 - | $(XMLLINT) --xpath '$(VODAXPATH)' - > data/table_melnik_.html
|
|
||||||
mv data/stav_melnik_.png data/stav_melnik.png && mv data/prutok_melnik_.png data/prutok_melnik.png && mv data/table_melnik_.html data/table_melnik.html
|
|
||||||
wget '$(VODAIMG1_USTI)' -O data/stav_usti_.png
|
|
||||||
wget '$(VODAIMG2_USTI)' -O data/prutok_usti_.png
|
|
||||||
wget '$(VODAURL_USTI)' -O - | $(XMLLINT) --encode utf8 - | $(XMLLINT) --xpath '$(VODAXPATH)' - > data/table_usti_.html
|
|
||||||
mv data/stav_usti_.png data/stav_usti.png && mv data/prutok_usti_.png data/prutok_usti.png && mv data/table_usti_.html data/table_usti.html
|
|
||||||
|
|
||||||
refreshdpp:
|
refreshdpp:
|
||||||
wget $(DOPRAVAURL) -O - | $(XMLLINT) --encode utf8 - > $(DOPRAVATMP)
|
wget $(DOPRAVAURL) -O - | $(XMLLINT) --encode utf8 - > $(DOPRAVATMP)
|
||||||
|
|
49
index.haml
49
index.haml
|
@ -1,4 +1,7 @@
|
||||||
!!! 5
|
!!! 5
|
||||||
|
|
||||||
|
- @stations=[ 307225, 307081, 307228, ]
|
||||||
|
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
%meta(charset="utf-8")
|
%meta(charset="utf-8")
|
||||||
|
@ -17,13 +20,14 @@
|
||||||
|
|
||||||
.content
|
.content
|
||||||
|
|
||||||
|
- @stations.each do |station|
|
||||||
%table.twocolumn
|
%table.twocolumn
|
||||||
%tr
|
%tr
|
||||||
%td(style="padding: 16px;")
|
%td(style="padding: 16px;")
|
||||||
.imgstav
|
.imgstav
|
||||||
%img(src="data/stav.png")
|
%img(src="data/stav_#{station}.png")
|
||||||
.imgprutok
|
.imgprutok
|
||||||
%img(src="data/prutok.png")
|
%img(src="data/prutok_#{station}.png")
|
||||||
%td(style="padding: 16px;")
|
%td(style="padding: 16px;")
|
||||||
%table#legend24h(style="margin: 16px;")
|
%table#legend24h(style="margin: 16px;")
|
||||||
=File.read("data/legend.html")
|
=File.read("data/legend.html")
|
||||||
|
@ -33,47 +37,8 @@
|
||||||
%th stav [cm]
|
%th stav [cm]
|
||||||
%th průtok [m<sup>3</sup>s<sup>-1</sup>]
|
%th průtok [m<sup>3</sup>s<sup>-1</sup>]
|
||||||
%th teplota [°C]
|
%th teplota [°C]
|
||||||
=File.read("data/table.html")
|
=File.read("data/table_#{station}.html")
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
%table.twocolumn
|
|
||||||
%tr
|
|
||||||
%td(style="padding: 16px;")
|
|
||||||
.imgstav
|
|
||||||
%img(src="data/stav_melnik.png")
|
|
||||||
.imgprutok
|
|
||||||
%img(src="data/prutok_melnik.png")
|
|
||||||
%td(style="padding: 16px;")
|
|
||||||
%table#legend24h(style="margin: 16px;")
|
|
||||||
=File.read("data/legend_melnik.html")
|
|
||||||
%table#table24h
|
|
||||||
%tr
|
|
||||||
%th datum a čas
|
|
||||||
%th stav [cm]
|
|
||||||
%th průtok [m<sup>3</sup>s<sup>-1</sup>]
|
|
||||||
%th teplota [°C]
|
|
||||||
=File.read("data/table_melnik.html")
|
|
||||||
|
|
||||||
%hr
|
|
||||||
|
|
||||||
%table.twocolumn
|
|
||||||
%tr
|
|
||||||
%td(style="padding: 16px;")
|
|
||||||
.imgstav
|
|
||||||
%img(src="data/stav_usti.png")
|
|
||||||
.imgprutok
|
|
||||||
%img(src="data/prutok_usti.png")
|
|
||||||
%td(style="padding: 16px;")
|
|
||||||
%table#legend24h(style="margin: 16px;")
|
|
||||||
=File.read("data/legend_usti.html")
|
|
||||||
%table#table24h
|
|
||||||
%tr
|
|
||||||
%th datum a čas
|
|
||||||
%th stav [cm]
|
|
||||||
%th průtok [m<sup>3</sup>s<sup>-1</sup>]
|
|
||||||
%th teplota [°C]
|
|
||||||
=File.read("data/table_usti.html")
|
|
||||||
|
|
||||||
%hr
|
|
||||||
.footer Data poskytuje Český hydrometeorologický ústav. Bez záruky.
|
.footer Data poskytuje Český hydrometeorologický ústav. Bez záruky.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue