htdocs: Add script to auto-refresh streets etc.

This commit is contained in:
Markus Koch 2021-02-26 20:13:02 +01:00
parent 76c0056c87
commit a91175fdd8
3 changed files with 35 additions and 0 deletions

16
htdocs/geojson/update.php Normal file
View File

@ -0,0 +1,16 @@
<?php
$fn = "/tmp/lifo_update_ts";
$ctime = time();
$ltime = (int)(file_get_contents($fn));
$ntime = $ltime + 60*1 * 30;
if (isset($_GET['force']))
$ntime = 0;
if ($ctime > $ntime) {
file_put_contents($fn, $ctime);
echo "Downloading... ";
flush();
system("cd /srv/http/maps.linux-forks.de/geojson/; ./update_all.sh");
} else {
echo "Next update in " . intval(($ntime - $ctime) / 60) . " minutes.";
}
?>

12
htdocs/geojson/update_all.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
function fetch() {
"./fetch_$1.sh" | json_reformat -m > "$1.json.tmp"
rm -f "$1.json"
mv "$1.json.tmp" "$1.json"
}
fetch streets
fetch city_outlines
echo "OK."

View File

@ -349,6 +349,13 @@ load_geojson("TL Access (tech layer)", "./geojson/trainlines_access_beta.json",
load_geojson("Railroad Tracks", "./geojson/trains.json", "train", "auto", 0, style_trains); load_geojson("Railroad Tracks", "./geojson/trains.json", "train", "auto", 0, style_trains);
load_geojson("Cities", "./geojson/city_outlines.json", "outline", "auto", 1, style_outlines); load_geojson("Cities", "./geojson/city_outlines.json", "outline", "auto", 1, style_outlines);
function update_geojson() {
var xhttp_ps = new XMLHttpRequest();
xhttp_ps.open("GET", "https://notsyncing.net/maps.linux-forks.de/geojson/update.php", true);
xhttp_ps.send();
}
update_geojson();
L.control.scale().addTo(mymap); L.control.scale().addTo(mymap);
function resolve_latlng(latlng, recenter = 0) { function resolve_latlng(latlng, recenter = 0) {