Compare commits

...

2 Commits

Author SHA1 Message Date
Robert Langhammer 2b281066f2 Answer empty coordinates with the Trainstation.
Signed-off-by: Robert Langhammer <rlanghammer@web.de>
2024-01-21 21:39:21 +01:00
Robert Langhammer c3100899bf Allow numeric and empty coordinates
Unconfigured routers are sending empty coordinates to recieve the trainstation data.

Signed-off-by: Robert Langhammer <rlanghammer@web.de>
2024-01-21 21:32:24 +01:00
2 changed files with 33 additions and 14 deletions

View File

@ -2,22 +2,22 @@
set -e
lat=${1:-0.0}
lon=${2:-0.0}
lat=$1
lon=$2
#echo $lat $lon
if [ $# -lt 2 ] ; then
cat "hood/Trainstation.json"
else
hood="$(./voronoi/test_voronoi.awk $lat $lon < voronoi/voronoi)"
for poly in poly/*.poly; do
if ./poly/test_poly.awk -- $lat $lon < "$poly"; then
hood=$(basename $poly .poly)
break
fi
done
hood="$(./voronoi/test_voronoi.awk $lat $lon < voronoi/voronoi)"
for poly in poly/*.poly; do
if ./poly/test_poly.awk -- $lat $lon < "$poly"; then
hood=$(basename $poly .poly)
break
fi
done
#echo $hood
cat "hood/$hood.json"
cat "hood/$hood.json"
fi
echo

19
index.php Normal file
View File

@ -0,0 +1,19 @@
<?php
$lat = $_GET['lat'] ?? null;
$lo = $_GET['long'] ?? null;
$hoodid = $_GET['hoodid'] ?? null;
if (empty($hoodid)) {
if (preg_match("/^[0-9.]*$/", $lat) and preg_match("/^[0-9.]*$/", $lo)) {
$hoodfile = shell_exec("./get_hood.sh $lat $lo");
}
else {
echo "coordinates not numeric! ";
}
}
else {
if ((!is_numeric($hoodid))) {exit("hoodid not numeric!");};
$hoodfile = shell_exec("./get_hoodid.sh $hoodid");
}
echo $hoodfile;
?>