X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/7df80bbc6fe0a3769603fade7c124e2641dd0efb..14e6dab005c49a77ac49b6503f7807e620ea0ed3:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index 6de3f242..a7c805f7 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -3,7 +3,7 @@ function fail($sError, $sUserError = false) { if (!$sUserError) $sUserError = $sError; - log('ERROR:'.$sError); + error_log('ERROR: '.$sError); echo $sUserError."\n"; exit; } @@ -40,12 +40,18 @@ function byImportance($a, $b) { +/* + if ($a['importance'] != $b['importance']) + return ($a['importance'] > $b['importance']?-1:1); if ($a['aPointPolygon']['numfeatures'] != $b['aPointPolygon']['numfeatures']) return ($a['aPointPolygon']['numfeatures'] > $b['aPointPolygon']['numfeatures']?-1:1); if ($a['aPointPolygon']['area'] != $b['aPointPolygon']['area']) return ($a['aPointPolygon']['area'] > $b['aPointPolygon']['area']?-1:1); - if ($a['importance'] != $b['importance']) - return ($a['importance'] < $b['importance']?-1:1); +// if ($a['levenshtein'] != $b['levenshtein']) +// return ($a['levenshtein'] < $b['levenshtein']?-1:1); + if ($a['rank_search'] != $b['rank_search']) + return ($a['rank_search'] < $b['rank_search']?-1:1); +*/ return ($a['foundorder'] < $b['foundorder']?-1:1); } @@ -173,6 +179,10 @@ return array(array('lat' => $aNearPostcodes[0]['lat'], 'lon' => $aNearPostcodes[0]['lon'], 'radius' => 0.005)); } + return false; + + /* partial search disabled because it sequentially scans placex + $sSQL = 'select substring(upper(postcode) from \'^[A-Z][A-Z]?[0-9][0-9A-Z]? [0-9]([A-Z][A-Z])$\'),ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from placex where country_code::text = \'gb\'::text AND substring(postcode from \'^([A-Z][A-Z]?[0-9][0-9A-Z]? [0-9])[A-Z][A-Z]$\') = \''.$sPostcodeSector.'\' and class=\'place\' and type=\'postcode\' '; $sSQL .= ' union '; $sSQL .= 'select substring(upper(postcode) from \'^[A-Z][A-Z]?[0-9][0-9A-Z]? [0-9]([A-Z][A-Z])$\'),ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from gb_postcode where substring(postcode from \'^([A-Z][A-Z]?[0-9][0-9A-Z]? [0-9])[A-Z][A-Z]$\') = \''.$sPostcodeSector.'\''; @@ -211,7 +221,7 @@ return array(array('lat' => $fLat, 'lon' => $fLon, 'radius' => $fRadius)); } return false; - + */ /* $fTotalFac is a suprisingly good indicator of accuracy $iZoom = 18 + round(log($fTotalFac,32)); @@ -281,21 +291,21 @@ function getClassTypes() { return array( - 'boundary:adminitrative:2' => array('label'=>'Country','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'boundary:adminitrative:4' => array('label'=>'State','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'boundary:adminitrative:5' => array('label'=>'State District','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'boundary:adminitrative:6' => array('label'=>'County','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'boundary:adminitrative:8' => array('label'=>'City','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'boundary:adminitrative:9' => array('label'=>'City District','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'boundary:adminitrative:10' => array('label'=>'Suburb','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'boundary:adminitrative:11' => array('label'=>'Neighbourhood','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), - 'place:city' => array('label'=>'City','frequency'=>66,'icon'=>'poi_place_city','defzoom'=>12, 'defdiameter' => 0.32,), + 'boundary:administrative:2' => array('label'=>'Country','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), 'place:country' => array('label'=>'Country','frequency'=>0,'icon'=>'poi_boundary_administrative','defzoom'=>6, 'defdiameter' => 15,), + 'boundary:administrative:4' => array('label'=>'State','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), 'place:state' => array('label'=>'State','frequency'=>0,'icon'=>'poi_boundary_administrative','defzoom'=>8, 'defdiameter' => 5.12,), - 'place:region' => array('label'=>'State','frequency'=>0,'icon'=>'poi_boundary_administrative','defzoom'=>8, 'defdiameter' => 5.12,), - 'place:island' => array('label'=>'Island','frequency'=>288,'icon'=>'','defzoom'=>11, 'defdiameter' => 0.64,), + 'boundary:administrative:5' => array('label'=>'State District','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), + 'boundary:administrative:6' => array('label'=>'County','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), 'place:county' => array('label'=>'County','frequency'=>108,'icon'=>'poi_boundary_administrative','defzoom'=>10, 'defdiameter' => 1.28,), - 'boundary:adminitrative' => array('label'=>'Administrative','frequency'=>413,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), + 'boundary:administrative:8' => array('label'=>'City','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), + 'place:city' => array('label'=>'City','frequency'=>66,'icon'=>'poi_place_city','defzoom'=>12, 'defdiameter' => 0.32,), + 'boundary:administrative:9' => array('label'=>'City District','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), + 'boundary:administrative:10' => array('label'=>'Suburb','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), + 'boundary:administrative:11' => array('label'=>'Neighbourhood','frequency'=>0,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), + 'place:region' => array('label'=>'Region','frequency'=>0,'icon'=>'poi_boundary_administrative','defzoom'=>8, 'defdiameter' => 5.12,), + 'place:island' => array('label'=>'Island','frequency'=>288,'icon'=>'','defzoom'=>11, 'defdiameter' => 0.64,), + 'boundary:administrative' => array('label'=>'Administrative','frequency'=>413,'icon'=>'poi_boundary_administrative', 'defdiameter' => 0.32,), 'place:town' => array('label'=>'Town','frequency'=>1497,'icon'=>'poi_place_town','defzoom'=>14, 'defdiameter' => 0.08,), 'place:village' => array('label'=>'Village','frequency'=>11230,'icon'=>'poi_place_village','defzoom'=>15, 'defdiameter' => 0.04,), 'place:hamlet' => array('label'=>'Hamlet','frequency'=>7075,'icon'=>'poi_place_village','defzoom'=>15, 'defdiameter' => 0.04,), @@ -438,6 +448,9 @@ 'amenity:shop' => array('label'=>'Shop','frequency'=>61,'icon'=>'',), 'place:house' => array('label'=>'House','frequency'=>2086,'icon'=>'','defzoom'=>18,), + 'place:house_name' => array('label'=>'House','frequency'=>2086,'icon'=>'','defzoom'=>18,), + 'place:house_number' => array('label'=>'House Number','frequency'=>2086,'icon'=>'','defzoom'=>18,), + 'place:country_code' => array('label'=>'Country Code','frequency'=>2086,'icon'=>'','defzoom'=>18,), // @@ -559,6 +572,7 @@ 'amenity:shopping' => array('label'=>'Shopping','frequency'=>21,'icon'=>'',), 'natural:scrub' => array('label'=>'Scrub','frequency'=>20,'icon'=>'',), 'natural:fen' => array('label'=>'Fen','frequency'=>20,'icon'=>'',), + 'building:yes' => array('label'=>'Building','frequency'=>200,'icon'=>'',), 'amenity:parking' => array('label'=>'Parking','frequency'=>3157,'icon'=>'',), 'highway:bus_stop' => array('label'=>'Bus Stop','frequency'=>35777,'icon'=>'transport_bus_stop2',), @@ -622,7 +636,7 @@ else { if (is_bool($xVal)) return $xVal?'true':'false'; - if (is_numeric($xVal)) return $xVal; +// if (is_numeric($xVal)) return $xVal; return '"'.str_replace('>','\\>',str_replace(array("\n","\r"),'\\n',str_replace(array("\n\r","\r\n"),'\\n',str_replace('"','\\"',$xVal)))).'"'; } } @@ -630,11 +644,17 @@ function _debugDumpGroupedSearches($aData, $aTokens) { $aWordsIDs = array(); - foreach($aTokens as $sToken => $aWords) + if ($aTokens) { - foreach($aWords as $aToken) + foreach($aTokens as $sToken => $aWords) { - $aWordsIDs[$aToken['word_id']] = $sToken.'('.$aToken['word_id'].')'; + if ($aWords) + { + foreach($aWords as $aToken) + { + $aWordsIDs[$aToken['word_id']] = $sToken.'('.$aToken['word_id'].')'; + } + } } } echo "