mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
introduce address column for place tables
The column is a hstore containing the full OSM tag with key and value.
This commit is contained in:
@@ -423,7 +423,7 @@ class Geocode
|
||||
$sSQL .= " rank_address,";
|
||||
$sSQL .= " min(place_id) AS place_id, ";
|
||||
$sSQL .= " min(parent_place_id) AS parent_place_id, ";
|
||||
$sSQL .= " calculated_country_code AS country_code, ";
|
||||
$sSQL .= " country_code, ";
|
||||
$sSQL .= " get_address_by_language(place_id, -1, $sLanguagePrefArraySQL) AS langaddress,";
|
||||
$sSQL .= " get_name_by_language(name, $sLanguagePrefArraySQL) AS placename,";
|
||||
$sSQL .= " get_name_by_language(name, ARRAY['ref']) AS ref,";
|
||||
@@ -466,7 +466,7 @@ class Geocode
|
||||
$sSQL .= " admin_level, ";
|
||||
$sSQL .= " rank_search, ";
|
||||
$sSQL .= " rank_address, ";
|
||||
$sSQL .= " calculated_country_code, ";
|
||||
$sSQL .= " country_code, ";
|
||||
$sSQL .= " importance, ";
|
||||
if (!$this->bDeDupe) $sSQL .= "place_id,";
|
||||
$sSQL .= " langaddress, ";
|
||||
@@ -551,7 +551,7 @@ class Geocode
|
||||
$sSQL .= " 30 AS rank_address, ";
|
||||
$sSQL .= " min(place_id) as place_id, ";
|
||||
$sSQL .= " min(parent_place_id) AS parent_place_id, ";
|
||||
$sSQL .= " calculated_country_code AS country_code, ";
|
||||
$sSQL .= " country_code, ";
|
||||
$sSQL .= " get_address_by_language(place_id, housenumber_for_place, $sLanguagePrefArraySQL) AS langaddress, ";
|
||||
$sSQL .= " null AS placename, ";
|
||||
$sSQL .= " null AS ref, ";
|
||||
@@ -576,7 +576,7 @@ class Geocode
|
||||
$sSQL .= " SELECT ";
|
||||
$sSQL .= " osm_id, ";
|
||||
$sSQL .= " place_id, ";
|
||||
$sSQL .= " calculated_country_code, ";
|
||||
$sSQL .= " country_code, ";
|
||||
$sSQL .= " CASE "; // interpolate the housenumbers here
|
||||
$sSQL .= " WHEN startnumber != endnumber ";
|
||||
$sSQL .= " THEN ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) ";
|
||||
@@ -595,7 +595,7 @@ class Geocode
|
||||
$sSQL .= " osm_id, ";
|
||||
$sSQL .= " place_id, ";
|
||||
$sSQL .= " housenumber_for_place, ";
|
||||
$sSQL .= " calculated_country_code "; //is this group by really needed?, place_id + housenumber (in combination) are unique
|
||||
$sSQL .= " country_code "; //is this group by really needed?, place_id + housenumber (in combination) are unique
|
||||
if (!$this->bDeDupe) $sSQL .= ", place_id ";
|
||||
|
||||
if (CONST_Use_Aux_Location_data) {
|
||||
@@ -1239,8 +1239,8 @@ class Geocode
|
||||
if ($aSearch['sCountryCode'] && !$aSearch['sClass'] && !$aSearch['sHouseNumber']) {
|
||||
// Just looking for a country by code - look it up
|
||||
if (4 >= $this->iMinAddressRank && 4 <= $this->iMaxAddressRank) {
|
||||
$sSQL = "SELECT place_id FROM placex WHERE calculated_country_code='".$aSearch['sCountryCode']."' AND rank_search = 4";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND calculated_country_code in ($sCountryCodesSQL)";
|
||||
$sSQL = "SELECT place_id FROM placex WHERE country_code='".$aSearch['sCountryCode']."' AND rank_search = 4";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND country_code in ($sCountryCodesSQL)";
|
||||
if ($bBoundingBoxSearch)
|
||||
$sSQL .= " AND _st_intersects($this->sViewboxSmallSQL, geometry)";
|
||||
$sSQL .= " ORDER BY st_area(geometry) DESC LIMIT 1";
|
||||
@@ -1258,7 +1258,7 @@ class Geocode
|
||||
$sSQL = "SELECT place_id FROM place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." ct";
|
||||
if ($sCountryCodesSQL) $sSQL .= " JOIN placex USING (place_id)";
|
||||
$sSQL .= " WHERE st_contains($this->sViewboxSmallSQL, ct.centroid)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND calculated_country_code in ($sCountryCodesSQL)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND country_code in ($sCountryCodesSQL)";
|
||||
if (sizeof($this->aExcludePlaceIDs)) {
|
||||
$sSQL .= " AND place_id not in (".join(',', $this->aExcludePlaceIDs).")";
|
||||
}
|
||||
@@ -1275,7 +1275,7 @@ class Geocode
|
||||
$sSQL = "SELECT place_id FROM place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." ct";
|
||||
if ($sCountryCodesSQL) $sSQL .= " join placex using (place_id)";
|
||||
$sSQL .= " WHERE ST_Contains($this->sViewboxLargeSQL, ct.centroid)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND calculated_country_code in ($sCountryCodesSQL)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND country_code in ($sCountryCodesSQL)";
|
||||
if ($this->sViewboxCentreSQL) $sSQL .= " ORDER BY ST_Distance($this->sViewboxCentreSQL, ct.centroid) ASC";
|
||||
$sSQL .= " LIMIT $this->iLimit";
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
@@ -1288,7 +1288,7 @@ class Geocode
|
||||
$sSQL .= " AND type='".$aSearch['sType']."'";
|
||||
$sSQL .= " AND ST_Contains($this->sViewboxSmallSQL, geometry) ";
|
||||
$sSQL .= " AND linked_place_id is null";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND calculated_country_code in ($sCountryCodesSQL)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND country_code in ($sCountryCodesSQL)";
|
||||
if ($this->sViewboxCentreSQL) $sSQL .= " ORDER BY ST_Distance($this->sViewboxCentreSQL, centroid) ASC";
|
||||
$sSQL .= " LIMIT $this->iLimit";
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
@@ -1534,7 +1534,7 @@ class Geocode
|
||||
$sSQL .= " AND class='".$aSearch['sClass']."' ";
|
||||
$sSQL .= " AND type='".$aSearch['sType']."'";
|
||||
$sSQL .= " AND linked_place_id is null";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND calculated_country_code in ($sCountryCodesSQL)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND country_code in ($sCountryCodesSQL)";
|
||||
$sSQL .= " ORDER BY rank_search ASC ";
|
||||
$sSQL .= " LIMIT $this->iLimit";
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
@@ -1604,7 +1604,7 @@ class Geocode
|
||||
if (sizeof($this->aExcludePlaceIDs)) {
|
||||
$sSQL .= " and l.place_id not in (".join(',', $this->aExcludePlaceIDs).")";
|
||||
}
|
||||
if ($sCountryCodesSQL) $sSQL .= " and lp.calculated_country_code in ($sCountryCodesSQL)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " and lp.country_code in ($sCountryCodesSQL)";
|
||||
if ($sOrderBySQL) $sSQL .= "order by ".$sOrderBySQL." asc";
|
||||
if ($this->iOffset) $sSQL .= " offset $this->iOffset";
|
||||
$sSQL .= " limit $this->iLimit";
|
||||
@@ -1631,7 +1631,7 @@ class Geocode
|
||||
if (sizeof($this->aExcludePlaceIDs)) {
|
||||
$sSQL .= " AND l.place_id not in (".join(',', $this->aExcludePlaceIDs).")";
|
||||
}
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND l.calculated_country_code in ($sCountryCodesSQL)";
|
||||
if ($sCountryCodesSQL) $sSQL .= " AND l.country_code in ($sCountryCodesSQL)";
|
||||
if ($sOrderBy) $sSQL .= "ORDER BY ".$OrderBysSQL." ASC";
|
||||
if ($this->iOffset) $sSQL .= " OFFSET $this->iOffset";
|
||||
$sSQL .= " limit $this->iLimit";
|
||||
|
||||
@@ -103,9 +103,9 @@ class PlaceLookup
|
||||
$bIsInterpolation = $sType == 'interpolation';
|
||||
|
||||
if ($bIsTiger) {
|
||||
$sSQL = "select place_id,partition, 'T' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, housenumber, null as street, null as isin, postcode,";
|
||||
$sSQL = "select place_id,partition, 'T' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, housenumber, null as street, postcode,";
|
||||
$sSQL .= " 'us' as country_code, parent_place_id, null as linked_place_id, 30 as rank_address, 30 as rank_search,";
|
||||
$sSQL .= " coalesce(null,0.75-(30::float/40)) as importance, null as indexed_status, null as indexed_date, null as wikipedia, 'us' as calculated_country_code, ";
|
||||
$sSQL .= " coalesce(null,0.75-(30::float/40)) as importance, null as indexed_status, null as indexed_date, null as wikipedia, 'us' as country_code, ";
|
||||
$sSQL .= " get_address_by_language(place_id, housenumber, $sLanguagePrefArraySQL) as langaddress,";
|
||||
$sSQL .= " null as placename,";
|
||||
$sSQL .= " null as ref,";
|
||||
@@ -119,9 +119,9 @@ class PlaceLookup
|
||||
$sSQL .= " END as housenumber";
|
||||
$sSQL .= " from location_property_tiger where place_id = ".$iPlaceID.") as blub1) as blub2";
|
||||
} elseif ($bIsInterpolation) {
|
||||
$sSQL = "select place_id, partition, 'W' as osm_type, osm_id, 'place' as class, 'house' as type, null admin_level, housenumber, null as street, null as isin, postcode,";
|
||||
$sSQL .= " calculated_country_code as country_code, parent_place_id, null as linked_place_id, 30 as rank_address, 30 as rank_search,";
|
||||
$sSQL .= " (0.75-(30::float/40)) as importance, null as indexed_status, null as indexed_date, null as wikipedia, calculated_country_code, ";
|
||||
$sSQL = "select place_id, partition, 'W' as osm_type, osm_id, 'place' as class, 'house' as type, null admin_level, housenumber, null as street, postcode,";
|
||||
$sSQL .= " country_code, parent_place_id, null as linked_place_id, 30 as rank_address, 30 as rank_search,";
|
||||
$sSQL .= " (0.75-(30::float/40)) as importance, null as indexed_status, null as indexed_date, null as wikipedia, country_code, ";
|
||||
$sSQL .= " get_address_by_language(place_id, housenumber, $sLanguagePrefArraySQL) as langaddress,";
|
||||
$sSQL .= " null as placename,";
|
||||
$sSQL .= " null as ref,";
|
||||
@@ -139,9 +139,9 @@ class PlaceLookup
|
||||
// and not interpolated
|
||||
} else {
|
||||
$sSQL = "select placex.place_id, partition, osm_type, osm_id, class,";
|
||||
$sSQL .= " type, admin_level, housenumber, street, isin, postcode, country_code,";
|
||||
$sSQL .= " type, admin_level, housenumber, street, postcode, country_code,";
|
||||
$sSQL .= " parent_place_id, linked_place_id, rank_address, rank_search, ";
|
||||
$sSQL .= " coalesce(importance,0.75-(rank_search::float/40)) as importance, indexed_status, indexed_date, wikipedia, calculated_country_code, ";
|
||||
$sSQL .= " coalesce(importance,0.75-(rank_search::float/40)) as importance, indexed_status, indexed_date, wikipedia, country_code, ";
|
||||
$sSQL .= " get_address_by_language(place_id, -1, $sLanguagePrefArraySQL) as langaddress,";
|
||||
$sSQL .= " get_name_by_language(name, $sLanguagePrefArraySQL) as placename,";
|
||||
$sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref,";
|
||||
|
||||
@@ -118,7 +118,7 @@ class ReverseGeocode
|
||||
$iMaxRank = 26;
|
||||
}
|
||||
|
||||
$sSQL = 'select place_id,parent_place_id,rank_search,calculated_country_code';
|
||||
$sSQL = 'select place_id,parent_place_id,rank_search,country_code';
|
||||
$sSQL .= ' FROM placex';
|
||||
$sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', geometry, '.$fSearchDiam.')';
|
||||
$sSQL .= ' and rank_search != 28 and rank_search >= '.$iMaxRank;
|
||||
@@ -135,7 +135,7 @@ class ReverseGeocode
|
||||
);
|
||||
$iPlaceID = $aPlace['place_id'];
|
||||
$iParentPlaceID = $aPlace['parent_place_id'];
|
||||
$bIsInUnitedStates = ($aPlace['calculated_country_code'] == 'us');
|
||||
$bIsInUnitedStates = ($aPlace['country_code'] == 'us');
|
||||
}
|
||||
|
||||
// If a house was found make sure there isn't an interpolation line
|
||||
|
||||
Reference in New Issue
Block a user