diff options
author | Markus Koch <markus@notsyncing.net> | 2021-02-26 20:13:02 +0100 |
---|---|---|
committer | Markus Koch <markus@notsyncing.net> | 2021-02-26 20:13:02 +0100 |
commit | a91175fdd8a5862d8e1afcad6888a636542bbda6 (patch) | |
tree | 7342b1584ba258b529dd9c2ad209822253fe3b6d /htdocs | |
parent | 76c0056c878a03969f283e22ecfabd9710edde9a (diff) | |
download | lifomapserver-a91175fdd8a5862d8e1afcad6888a636542bbda6.tar.gz lifomapserver-a91175fdd8a5862d8e1afcad6888a636542bbda6.tar.bz2 lifomapserver-a91175fdd8a5862d8e1afcad6888a636542bbda6.zip |
htdocs: Add script to auto-refresh streets etc.
Diffstat (limited to 'htdocs')
-rw-r--r-- | htdocs/geojson/update.php | 16 | ||||
-rwxr-xr-x | htdocs/geojson/update_all.sh | 12 | ||||
-rw-r--r-- | htdocs/mapscript.js | 7 |
3 files changed, 35 insertions, 0 deletions
diff --git a/htdocs/geojson/update.php b/htdocs/geojson/update.php new file mode 100644 index 0000000..06e2a13 --- /dev/null +++ b/htdocs/geojson/update.php @@ -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."; + } +?> diff --git a/htdocs/geojson/update_all.sh b/htdocs/geojson/update_all.sh new file mode 100755 index 0000000..5a0bc61 --- /dev/null +++ b/htdocs/geojson/update_all.sh @@ -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." diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index dd915c1..cb906e4 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -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("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); function resolve_latlng(latlng, recenter = 0) { |