|
From: <il...@pr...> - 2004-09-18 05:06:09
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6496 Modified Files: submit.php Log Message: Some gross hacking in the name of pragmatism: try to pick up common mistakes that people make when entering coordinates (such as entering them in curvilinear form rather than UTM or vice versa, or missing some digits from the end of the UTM coordinates, or getting the signs on curvilinear coordinates wrong) and fix them up for them automatically. Index: submit.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/submit.php,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- submit.php 18 Sep 2004 05:02:50 -0000 1.12 +++ submit.php 18 Sep 2004 05:05:56 -0000 1.13 @@ -227,10 +227,48 @@ else if ($admin["nodename"] == "") die("nodename cannot be empty"); + /* The limits of what we deem to be sensible coordinates (a + * few hundred kilometres in each direction from Brisbane). */ + $min_e = 200000; + $max_e = 700000; + $min_n = 6700000; + $max_n = 7200000; + $min_lon = 25; /* absolute values, just to keep it easy */ + $max_lon = 30; + $min_lat = 150; + $max_lat = 155; + if ($PREF["wantgps"] && isset($physloc["lat"])) { + if ($physloc["lat"] > $min_n && $physloc["lat"] < $max_n + && $physloc["lon"] > $min_e && $physloc["lon"] < $max_e) { + /* Looks like UTM entered as curvilinear. */ + $physloc["e"] = $physloc["lon"]; + $physloc["n"] = $physloc["lat"]; + } else { + /* We don't have any better guesses for what it might + * be, so we'll just trust them. */ list($physloc["e"], $physloc["n"]) = - cvteastnorth($physloc["lat"], $physloc["lon"]); - } + cvteastnorth($physloc["lat"], $physloc["lon"]); + } + } else if (isset($physloc["e"]) && isset($physloc["n"])) { + if (abs($physloc["n"]) > $min_lon && abs($physloc["n"]) < $max_lon + && abs($physloc["e"]) > $min_lat && abs($physloc["e"]) < $max_lat) { + /* Looks like curvilinear entered as UTM. */ + list($physloc["e"], $physloc["n"]) = + cvteastnorth(-abs($physloc["n"]), abs($physloc["e"])); + } else { + for ($factor = 10; $factor <= 100; $factor *= 10) { + /* Check whether there's a digit or three missing + * from the eastings and/or northings. */ + if ($physloc["e"] * $factor > $min_e && + $physloc["e"] * $factor < $max_e) + $physloc["e"] *= $factor; + if ($physloc["n"] * $factor > $min_n && + $physloc["n"] * $factor > $max_n) + $physloc["n"] *= $factor; + } + } + } function addchange($name, $old, $new, &$changes) { |