<?php
- function failInternalError($sError, $sSQL = false, $vDumpVar = false)
- {
- header('HTTP/1.0 500 Internal Server Error');
- header('Content-type: text/html; charset=utf-8');
- echo "<html><body><h1>Internal Server Error</h1>";
- echo '<p>Nominatim has encountered an internal error while processing your request. This is most likely because of a bug in the software.</p>';
- echo "<p><b>Details:</b> ".$sError,"</p>";
- echo '<p>Feel free to report the bug in the <a href="http://trac.openstreetmap.org">OSM bug database</a>. Please include the error message above and the URL you used.</p>';
- if (CONST_Debug)
- {
- echo "<hr><h2>Debugging Information</h2><br>";
- if ($sSQL)
- {
- echo "<h3>SQL query</h3><code>".$sSQL."</code>";
- }
- if ($vDumpVar)
- {
- echo "<h3>Result</h3> <code>";
- var_dump($vDumpVar);
- echo "</code>";
- }
- }
- echo "\n</body></html>\n";
- exit;
- }
-
-
- function userError($sError)
- {
- header('HTTP/1.0 400 Bad Request');
- header('Content-type: text/html; charset=utf-8');
- echo "<html><body><h1>Bad Request</h1>";
- echo '<p>Nominatim has encountered an error with your request.</p>';
- echo "<p><b>Details:</b> ".$sError,"</p>";
- echo '<p>If you feel this error is incorrect feel free to report the bug in the <a href="http://trac.openstreetmap.org">OSM bug database</a>. Please include the error message above and the URL you used.</p>';
- echo "\n</body></html>\n";
- exit;
- }
-
- function getParamBool($name, $default=false)
- {
- if (!isset($_GET[$name])) return $default;
-
- return (bool) $_GET[$name];
- }
-
function fail($sError, $sUserError = false)
{
if (!$sUserError) $sUserError = $sError;
{
// Try an exact match on the gb_postcode table
$sSQL = 'select \'AA\', ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from gb_postcode where postcode = \''.$sPostcode.'\'';
- $aNearPostcodes = $oDB->getAll($sSQL);
- if (PEAR::IsError($aNearPostcodes))
- {
- var_dump($sSQL, $aNearPostcodes);
- exit;
- }
+ $aNearPostcodes = chksql($oDB->getAll($sSQL));
if (sizeof($aNearPostcodes))
{
if (!$bRaw) $sSQL .= " WHERE isaddress OR type = 'country_code'";
$sSQL .= " order by rank_address desc,isaddress desc";
- $aAddressLines = $oDB->getAll($sSQL);
- if (PEAR::IsError($aAddressLines))
- {
- var_dump($aAddressLines);
- exit;
- }
+ $aAddressLines = chksql($oDB->getAll($sSQL));
if ($bRaw) return $aAddressLines;
//echo "<pre>";
//var_dump($aAddressLines);
$sSQL .= ' OR ST_DWithin('.$sPointSQL.', ST_Centroid(geometry), '.$fSearchDiam.'))';
$sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', geometry) ASC limit 1';
//var_dump($sSQL);
- $aPlace = $oDB->getRow($sSQL);
- if (PEAR::IsError($aPlace))
- {
- var_Dump($sSQL, $aPlace);
- exit;
- }
+ $aPlace = chksql($oDB->getRow($sSQL));
$iPlaceID = $aPlace['place_id'];
}
if ($iPlaceID)
{
$sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = $iPlaceID order by cached_rank_address desc,isaddress desc,distance desc limit 1";
- $iPlaceID = $oDB->getOne($sSQL);
- if (PEAR::IsError($iPlaceID))
- {
- var_Dump($sSQL, $iPlaceID);
- exit;
- }
+ $iPlaceID = chksql($oDB->getOne($sSQL));
if ($iPlaceID && $aPlace['place_id'] && $iMaxRank < 28)
{
$sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = ".$aPlace['place_id']." order by cached_rank_address desc,isaddress desc,distance desc";
- $iPlaceID = $oDB->getOne($sSQL);
- if (PEAR::IsError($iPlaceID))
- {
- var_Dump($sSQL, $iPlaceID);
- exit;
- }
+ $iPlaceID = chksql($oDB->getOne($sSQL));
}
if (!$iPlaceID)
{