log("VISITING {$_SERVER['REQUEST_URI']}"); } /* With no query given, just displaythe date of the index, and some helpful text */ $dateoption = options::getoption('indexdate'); if ($dateoption =='') { $indexdate = ''; $message = 'updating the index, back soon...'; if (isset($_GET['find'])) { unset ($_GET['find']); } } else { list($year,$month,$day) = sscanf($dateoption, "%d-%d-%d"); $indexdate = "

Index from OpenStreetMap data up to ". date("j M Y", jdtounix(cal_to_jd(CAL_GREGORIAN, $month,$day,$year)))."

"; } $examples = <<You can search for a name, or name near place with the name and place separated with a comma or the word near. A place can be (a) a city, town, suburb, village or hamlet; or (b) a lat,lon pair as in ‘Ely Cathedral near 52.4,0.2’. A name can be (a) anything on the map which is named, such as a street, school, pub etc.; (b) a road number e.g. ‘M11’; (c) an airport code, e.g. ‘STN’; (d) a class of things as in ‘pubs near Ely’ or ‘airport near Derby’; or (e) a lat,lon pair - most useful when not qualified by a place to say where it is in relation to nearby places. More information and examples...

EOD; $found = ''; if (isset($_GET['find'])) { /* process the string requested */ // -------------------------------------------------- function renderentry($xnamed, $i) { $s = <<http://www.openstreetmap.org/index.html?lat={$xnamed['lat']}&lon={$xnamed['lon']}&zoom={$xnamed['zoom']} {$xnamed->description} map EOD; if ($xnamed['type'] == 'node') { if (isset($_SERVER['REMOTE_ADDR'])) { if (strpos($_SERVER['REMOTE_ADDR'], '192.168.0.') === 0) { $site = 'http://egret/osm/'; } if (isset($site)) { $s .= "edit (mei)\n"; } } } $s .= "edit (poi)\n"; return $s; } // -------------------------------------------------- $find = isset($_GET['find']) ? $_GET['find'] : ''; $max = (int) (isset($_GET['max']) ? $_GET['max'] : $config['limit']); $anyoccurenceifnotlocal = isset($_GET['any']); /* Do the deed, and unpack the xml results */ $xmlo = simplexml_load_string(search::xmlise($find, $max, $anyoccurenceifnotlocal)); /* interpret the results into the left side, with error messages as appropriate */ $results = ''; if ($xmlo['distancesearch'] == 'no') { /* a simple seach rather than great circle distance query. This is the more usual case. */ if (! empty($xmlo['error'])) { switch($xmlo['error']) { case 'name not found for postcode': $message = "I cannot find {$xmlo['findname']}, {$xmlo['findplace']} for {$find} (not on the map yet? misspelled?)"; break; case 'name not found': $message = "I cannot find {$find} (not on the map yet? misspelled?)"; break; case 'place not found': $message = "I cannot find a place called {$xmlo['findplace']} (not on the map yet? misspelled?)"; break; case 'too many colons': $message = "I can't cope with that many colons"; break; default: $message = $xmlo['error']; break; } } else { for (;;) { if (isset($xmlo['findplace']) && $xmlo['foundnearplace'] == 'no') { if (isset($xmlo['postcode'])) { $message = "I cannot find {$xmlo['findname']}, {$xmlo['findplace']} for postcode {$xmlo['postcode']} (not on the map yet?)"; break; } else { $results .= "

" . htmlspecialchars($find, ENT_QUOTES, 'UTF-8') . " not found, but...

"; } } $i = 0; foreach($xmlo->named as $xnamed) { $results .= "

\n" . renderentry($xnamed, $i) . "

\n"; if ($i == 0) { $go1 = "go({$xnamed['lat']},{$xnamed['lon']},{$xnamed['zoom']},{$i})"; } $i++; } if ($i == $config['limit']) { $results .= "

... and possibly others

\n"; } break; } } } else { // great circle distance search (colon form of query) $i = 0; foreach($xmlo->distance as $xdistance) { $km = (int) round((double)$xdistance); foreach ($xmlo->named as $xnamed) { if ((string)$xnamed['type'] == (string)$xdistance['fromtype'] && (int)$xnamed['id'] == (int)$xdistance['from']) { $entry1 = renderentry($xnamed, $i); if ($i == 0) { $go1 = "go({$xnamed['lat']},{$xnamed['lon']},{$xnamed['zoom']},{$i})"; } } if ((string)$xnamed['type'] == (string)$xdistance['totype'] && (int)$xnamed['id'] == (int)$xdistance['to']) { $entry2 = renderentry($xnamed, $i+1); } } $results .= "

{$km}km between
\n" . $entry1 . "
and
\n" . $entry2; $i += 2; } } // -------------------------------------------------- } else { /* not processing a query, so substitute an example string in the find box */ $find = 'Regent Street, Cambridge [for example]'; } /* Present the form and the javascript to reposition the map for each result. */ ?> OpenStreetMap name finder
OpenStreetMap
Name Finder
Open Street Map
The Free Wiki World Map
' />
give me matches anywhere in the world if one can't be found near the place specified
(matches are always given worldwide when there is no qualifying place)