forked from hans/Nominatim
Merge remote-tracking branch 'markus/master' into master
This commit is contained in:
105
lib/Geocode.php
105
lib/Geocode.php
@@ -431,24 +431,23 @@
|
||||
|
||||
if (30 >= $this->iMinAddressRank && 30 <= $this->iMaxAddressRank)
|
||||
{
|
||||
//only Tiger housenumbers and interpolation lines need to be interpolated, because they are saved as lines
|
||||
// with start- and endnumber, the common osm housenumbers are usually saved as points
|
||||
$sHousenumbers = "";
|
||||
$i = 0;
|
||||
$length = count($aPlaceIDs);
|
||||
foreach($aPlaceIDs as $placeID => $housenumber)
|
||||
{
|
||||
$i++;
|
||||
$sHousenumbers .= "(".$placeID.", ".$housenumber.")";
|
||||
if($i<$length)
|
||||
$sHousenumbers .= ", ";
|
||||
}
|
||||
if (CONST_Use_US_Tiger_Data)
|
||||
{
|
||||
//query also location_property_tiger and location_property_aux
|
||||
//Tiger search only if a housenumber was searched and if it was found (i.e. aPlaceIDs[placeID] = housenumber != -1) (realized through a join)
|
||||
//only Tiger housenumbers need to be interpolated, because they are saved as lines with start- and endnumber, the common osm housenumbers are usually saved as points
|
||||
$sHousenumbers = "";
|
||||
$i = 0;
|
||||
$length = count($aPlaceIDs);
|
||||
foreach($aPlaceIDs as $placeID => $housenumber)
|
||||
{
|
||||
$i++;
|
||||
$sHousenumbers .= "(".$placeID.", ".$housenumber.")";
|
||||
if($i<$length)
|
||||
$sHousenumbers .= ", ";
|
||||
}
|
||||
|
||||
$sSQL .= "union ";
|
||||
$sSQL .= "select 'T' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, 30 as rank_search, 30 as rank_address, min(place_id) as place_id, min(parent_place_id) as parent_place_id, 'us' as country_code";
|
||||
$sSQL .= " union";
|
||||
$sSQL .= " select 'T' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, 30 as rank_search, 30 as rank_address, min(place_id) as place_id, min(parent_place_id) as parent_place_id, 'us' as country_code";
|
||||
$sSQL .= ", get_address_by_language(place_id, housenumber_for_place, $sLanguagePrefArraySQL) as langaddress ";
|
||||
$sSQL .= ", null as placename";
|
||||
$sSQL .= ", null as ref";
|
||||
@@ -460,13 +459,37 @@
|
||||
$sSQL .= ", null as extra_place ";
|
||||
$sSQL .= " from (select place_id";
|
||||
//interpolate the Tiger housenumbers here
|
||||
$sSQL .= ", ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) as centroid, parent_place_id, housenumber_for_place ";
|
||||
$sSQL .= "from (location_property_tiger ";
|
||||
$sSQL .= ", ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) as centroid, parent_place_id, housenumber_for_place";
|
||||
$sSQL .= " from (location_property_tiger ";
|
||||
$sSQL .= " join (values ".$sHousenumbers.") as housenumbers(place_id, housenumber_for_place) using(place_id)) ";
|
||||
$sSQL .= " where housenumber_for_place>=0 and 30 between $this->iMinAddressRank and $this->iMaxAddressRank) as blub"; //postgres wants an alias here
|
||||
$sSQL .= " group by place_id, housenumber_for_place"; //is this group by really needed?, place_id + housenumber (in combination) are unique
|
||||
if (!$this->bDeDupe) $sSQL .= ", place_id ";
|
||||
}
|
||||
// osmline
|
||||
// interpolation line search only if a housenumber was searched and if it was found (i.e. aPlaceIDs[placeID] = housenumber != -1) (realized through a join)
|
||||
$sSQL .= " union ";
|
||||
$sSQL .= "select 'W' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, 30 as rank_search, 30 as rank_address, min(place_id) as place_id, min(parent_place_id) as parent_place_id, calculated_country_code as country_code, ";
|
||||
$sSQL .= "get_address_by_language(place_id, housenumber_for_place, $sLanguagePrefArraySQL) as langaddress, ";
|
||||
$sSQL .= "null as placename, ";
|
||||
$sSQL .= "null as ref, ";
|
||||
if ($this->bIncludeExtraTags) $sSQL .= "null as extra, ";
|
||||
if ($this->bIncludeNameDetails) $sSQL .= "null as names, ";
|
||||
$sSQL .= " avg(st_x(centroid)) as lon, avg(st_y(centroid)) as lat,";
|
||||
$sSQL .= $sImportanceSQL."-0.1 as importance, "; // slightly smaller than the importance for normal houses with rank 30, which is 0
|
||||
$sSQL .= " (select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p";
|
||||
$sSQL .= " where s.place_id = min(blub.parent_place_id) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance,";
|
||||
$sSQL .= " null as extra_place ";
|
||||
$sSQL .= " from (select place_id, calculated_country_code ";
|
||||
//interpolate the housenumbers here
|
||||
$sSQL .= ", CASE WHEN startnumber != endnumber THEN ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) ";
|
||||
$sSQL .= " ELSE ST_LineInterpolatePoint(linegeo, 0.5) END as centroid";
|
||||
$sSQL .= ", parent_place_id, housenumber_for_place ";
|
||||
$sSQL .= " from (location_property_osmline ";
|
||||
$sSQL .= " join (values ".$sHousenumbers.") as housenumbers(place_id, housenumber_for_place) using(place_id)) ";
|
||||
$sSQL .= " where housenumber_for_place>=0 and 30 between $this->iMinAddressRank and $this->iMaxAddressRank) as blub"; //postgres wants an alias here
|
||||
$sSQL .= " group by place_id, housenumber_for_place, calculated_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)
|
||||
{
|
||||
@@ -879,7 +902,7 @@
|
||||
|
||||
// Do we have anything that looks like a lat/lon pair?
|
||||
if ( $aLooksLike = looksLikeLatLonPair($sQuery) )
|
||||
{
|
||||
{
|
||||
$this->setNearPoint(array($aLooksLike['lat'], $aLooksLike['lon']));
|
||||
$sQuery = $aLooksLike['query'];
|
||||
}
|
||||
@@ -1307,7 +1330,13 @@
|
||||
if ($aSearch['sHouseNumber'] && sizeof($aSearch['aAddress']))
|
||||
{
|
||||
$sHouseNumberRegex = '\\\\m'.$aSearch['sHouseNumber'].'\\\\M';
|
||||
$aOrder[] = "exists(select place_id from placex where parent_place_id = search_name.place_id and transliteration(housenumber) ~* E'".$sHouseNumberRegex."' limit 1) desc";
|
||||
$aOrder[] = "";
|
||||
$aOrder[0] = " (exists(select place_id from placex where parent_place_id = search_name.place_id";
|
||||
$aOrder[0] .= " and transliteration(housenumber) ~* E'".$sHouseNumberRegex."' limit 1) ";
|
||||
// also housenumbers from interpolation lines table are needed
|
||||
$aOrder[0] .= " or exists(select place_id from location_property_osmline where parent_place_id = search_name.place_id";
|
||||
$aOrder[0] .= " and ".intval($aSearch['sHouseNumber']).">=startnumber and ".intval($aSearch['sHouseNumber'])."<=endnumber limit 1))";
|
||||
$aOrder[0] .= " desc";
|
||||
}
|
||||
|
||||
// TODO: filter out the pointless search terms (2 letter name tokens and less)
|
||||
@@ -1422,10 +1451,11 @@
|
||||
//now search for housenumber, if housenumber provided
|
||||
if ($aSearch['sHouseNumber'] && sizeof($aPlaceIDs))
|
||||
{
|
||||
$searchedHousenumber = intval($aSearch['sHouseNumber']);
|
||||
$aRoadPlaceIDs = $aPlaceIDs;
|
||||
$sPlaceIDs = join(',',$aPlaceIDs);
|
||||
|
||||
// Now they are indexed look for a house attached to a street we found
|
||||
// Now they are indexed, look for a house attached to a street we found
|
||||
$sHouseNumberRegex = '\\\\m'.$aSearch['sHouseNumber'].'\\\\M';
|
||||
$sSQL = "select place_id from placex where parent_place_id in (".$sPlaceIDs.") and transliteration(housenumber) ~* E'".$sHouseNumberRegex."'";
|
||||
if (sizeof($this->aExcludePlaceIDs))
|
||||
@@ -1435,21 +1465,44 @@
|
||||
$sSQL .= " limit $this->iLimit";
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aPlaceIDs = $this->oDB->getCol($sSQL);
|
||||
|
||||
// if nothing found, search in the interpolation line table
|
||||
if(!sizeof($aPlaceIDs))
|
||||
{
|
||||
// do we need to use transliteration and the regex for housenumbers???
|
||||
//new query for lines, not housenumbers anymore
|
||||
if($searchedHousenumber%2 == 0){
|
||||
//if housenumber is even, look for housenumber in streets with interpolationtype even or all
|
||||
$sSQL = "select distinct place_id from location_property_osmline where parent_place_id in (".$sPlaceIDs.") and (interpolationtype='even' or interpolationtype='all') and ".$searchedHousenumber.">=startnumber and ".$searchedHousenumber."<=endnumber";
|
||||
}else{
|
||||
//look for housenumber in streets with interpolationtype odd or all
|
||||
$sSQL = "select distinct place_id from location_property_osmline where parent_place_id in (".$sPlaceIDs.") and (interpolationtype='odd' or interpolationtype='all') and ".$searchedHousenumber.">=startnumber and ".$searchedHousenumber."<=endnumber";
|
||||
}
|
||||
|
||||
if (sizeof($this->aExcludePlaceIDs))
|
||||
{
|
||||
$sSQL .= " and parent_place_id not in (".join(',', $this->aExcludePlaceIDs).")";
|
||||
}
|
||||
//$sSQL .= " limit $this->iLimit";
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
//get place IDs
|
||||
$aPlaceIDs = $this->oDB->getCol($sSQL, 0);
|
||||
}
|
||||
|
||||
// If nothing found try the aux fallback table
|
||||
if (CONST_Use_Aux_Location_data && !sizeof($aPlaceIDs))
|
||||
{
|
||||
$sSQL = "select place_id from location_property_aux where parent_place_id in (".$sPlaceIDs.") and housenumber = '".pg_escape_string($aSearch['sHouseNumber'])."'";
|
||||
if (sizeof($this->aExcludePlaceIDs))
|
||||
{
|
||||
$sSQL .= " and place_id not in (".join(',',$this->aExcludePlaceIDs).")";
|
||||
$sSQL .= " and parent_place_id not in (".join(',',$this->aExcludePlaceIDs).")";
|
||||
}
|
||||
//$sSQL .= " limit $this->iLimit";
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aPlaceIDs = $this->oDB->getCol($sSQL);
|
||||
}
|
||||
|
||||
//if nothing was found in placex or location_property_aux, then search in Tiger data for this housenumber(location_property_tiger)
|
||||
$searchedHousenumber = intval($aSearch['sHouseNumber']);
|
||||
if (CONST_Use_US_Tiger_Data && !sizeof($aPlaceIDs))
|
||||
{
|
||||
//new query for lines, not housenumbers anymore
|
||||
@@ -1478,7 +1531,7 @@
|
||||
//set to -1, if no housenumbers were found
|
||||
$searchedHousenumber = -1;
|
||||
}
|
||||
//else: housenumber was found, remains saved in searchedHousenumber
|
||||
//else: housenumber was found, remains saved in searchedHousenumber
|
||||
}
|
||||
|
||||
|
||||
@@ -1618,6 +1671,7 @@
|
||||
{
|
||||
// Need to verify passes rank limits before dropping out of the loop (yuk!)
|
||||
// reduces the number of place ids, like a filter
|
||||
// rank_address is 30 for interpolated housenumbers
|
||||
$sSQL = "select place_id from placex where place_id in (".join(',',array_keys($aResultPlaceIDs)).") ";
|
||||
$sSQL .= "and (placex.rank_address between $this->iMinAddressRank and $this->iMaxAddressRank ";
|
||||
if (14 >= $this->iMinAddressRank && 14 <= $this->iMaxAddressRank) $sSQL .= " OR (extratags->'place') = 'city'";
|
||||
@@ -1628,12 +1682,13 @@
|
||||
$sSQL .= "and (30 between $this->iMinAddressRank and $this->iMaxAddressRank ";
|
||||
if ($this->aAddressRankList) $sSQL .= " OR 30 in (".join(',',$this->aAddressRankList).")";
|
||||
}
|
||||
$sSQL .= ")";
|
||||
$sSQL .= ") UNION select place_id from location_property_osmline where place_id in (".join(',',array_keys($aResultPlaceIDs)).")";
|
||||
$sSQL .= " and (30 between $this->iMinAddressRank and $this->iMaxAddressRank)";
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aFilteredPlaceIDs = $this->oDB->getCol($sSQL);
|
||||
$tempIDs = array();
|
||||
foreach($aFilteredPlaceIDs as $placeID)
|
||||
{
|
||||
{
|
||||
$tempIDs[$placeID] = $aResultPlaceIDs[$placeID]; //assign housenumber to placeID
|
||||
}
|
||||
$aResultPlaceIDs = $tempIDs;
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
{
|
||||
$this->setOSMID($details['osm_type'], $details['osm_id']);
|
||||
}
|
||||
if (isset($details['fraction'])) $this->fTigerFraction = $details['fraction'];
|
||||
if (isset($details['fraction'])) $this->fInterpolFraction = $details['fraction'];
|
||||
|
||||
return $this->lookup();
|
||||
}
|
||||
@@ -134,12 +134,33 @@
|
||||
if ($this->bNameDetails) $sSQL .= " null as names,";
|
||||
$sSQL .= " ST_X(point) as lon, ST_Y(point) as lat from (select *, ST_LineInterpolatePoint(linegeo, (housenumber-startnumber::float)/(endnumber-startnumber)::float) as point from ";
|
||||
$sSQL .= " (select *, ";
|
||||
$sSQL .= " CASE WHEN interpolationtype='odd' THEN floor((".$this->fTigerFraction."*(endnumber-startnumber)+startnumber)/2)::int*2+1";
|
||||
$sSQL .= " WHEN interpolationtype='even' THEN ((".$this->fTigerFraction."*(endnumber-startnumber)+startnumber+1)/2)::int*2";
|
||||
$sSQL .= " WHEN interpolationtype='all' THEN (".$this->fTigerFraction."*(endnumber-startnumber)+startnumber)::int";
|
||||
$sSQL .= " CASE WHEN interpolationtype='odd' THEN floor((".$this->fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2+1";
|
||||
$sSQL .= " WHEN interpolationtype='even' THEN ((".$this->fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2";
|
||||
$sSQL .= " WHEN interpolationtype='all' THEN (".$this->fInterpolFraction."*(endnumber-startnumber)+startnumber)::int";
|
||||
$sSQL .= " END as housenumber";
|
||||
$sSQL .= " from location_property_tiger where place_id = ".(int)$this->iPlaceID.") as blub1) as blub2";
|
||||
}
|
||||
else if ($this->sType == 'interpolation')
|
||||
{
|
||||
$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 .= " get_address_by_language(place_id, housenumber, $sLanguagePrefArraySQL) as langaddress,";
|
||||
$sSQL .= " null as placename,";
|
||||
$sSQL .= " null as ref,";
|
||||
if ($this->bExtraTags) $sSQL .= " null as extra,";
|
||||
if ($this->bNameDetails) $sSQL .= " null as names,";
|
||||
$sSQL .= " ST_X(point) as lon, ST_Y(point) as lat from (select *, ST_LineInterpolatePoint(linegeo, (housenumber-startnumber::float)/(endnumber-startnumber)::float) as point from ";
|
||||
$sSQL .= " (select *, ";
|
||||
$sSQL .= " CASE WHEN interpolationtype='odd' THEN floor((".$this->fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2+1";
|
||||
$sSQL .= " WHEN interpolationtype='even' THEN ((".$this->fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2";
|
||||
$sSQL .= " WHEN interpolationtype='all' THEN (".$this->fInterpolFraction."*(endnumber-startnumber)+startnumber)::int";
|
||||
$sSQL .= " END as housenumber";
|
||||
$sSQL .= " from location_property_osmline where place_id = ".(int)$this->iPlaceID.") as blub1) as blub2";
|
||||
// testcase: interpolationtype=odd, startnumber=1000, endnumber=1006, fInterpolFraction=1 => housenumber=1007 => error in st_lineinterpolatepoint
|
||||
// but this will never happen, because if the searched point is that close to the endnumber, the endnumber house will be directly taken from placex (in ReverseGeocode.php line 220)
|
||||
// and not interpolated
|
||||
}
|
||||
else
|
||||
{
|
||||
$sSQL = "select placex.place_id, partition, osm_type, osm_id, class, type, admin_level, housenumber, street, isin, postcode, country_code, parent_place_id, linked_place_id, rank_address, rank_search, ";
|
||||
@@ -166,7 +187,7 @@
|
||||
|
||||
if ($this->bAddressDetails)
|
||||
{
|
||||
if(CONST_Use_US_Tiger_Data && $this->sType == 'tiger') // to get addressdetails for tiger data, the housenumber is needed
|
||||
if(CONST_Use_US_Tiger_Data && $this->sType == 'tiger' || $this->sType == 'interpolation') // to get addressdetails for tiger data, the housenumber is needed
|
||||
$aAddress = $this->getAddressNames($aPlace['housenumber']);
|
||||
else
|
||||
$aAddress = $this->getAddressNames();
|
||||
|
||||
@@ -121,6 +121,7 @@
|
||||
$fMaxAreaDistance = 1;
|
||||
$bIsInUnitedStates = false;
|
||||
$bPlaceIsTiger = false;
|
||||
$bPlaceIsLine = false;
|
||||
while(!$iPlaceID && $fSearchDiam < $fMaxAreaDistance)
|
||||
{
|
||||
$fSearchDiam = $fSearchDiam * 2;
|
||||
@@ -156,7 +157,78 @@
|
||||
$iParentPlaceID = $aPlace['parent_place_id'];
|
||||
$bIsInUnitedStates = ($aPlace['calculated_country_code'] == 'us');
|
||||
}
|
||||
// if a street or house was found, look in interpolation lines table
|
||||
if ($iMaxRank_orig >= 28 && $aPlace && $aPlace['rank_search'] >= 26)
|
||||
{
|
||||
// if a house was found, search the interpolation line that is at least as close as the house
|
||||
$sSQL = 'SELECT place_id, parent_place_id, 30 as rank_search, ST_line_locate_point(linegeo,'.$sPointSQL.') as fraction';
|
||||
$sSQL .= ' FROM location_property_osmline';
|
||||
$sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', linegeo, '.$fSearchDiam.')';
|
||||
$sSQL .= ' and indexed_status = 0 ';
|
||||
$sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', linegeo) ASC limit 1';
|
||||
|
||||
if (CONST_Debug)
|
||||
{
|
||||
$sSQL = preg_replace('/limit 1/', 'limit 100', $sSQL);
|
||||
var_dump($sSQL);
|
||||
|
||||
$aAllHouses = $this->oDB->getAll($sSQL);
|
||||
foreach($aAllHouses as $i)
|
||||
{
|
||||
echo $i['housenumber'] . ' | ' . $i['distance'] * 1000 . ' | ' . $i['lat'] . ' | ' . $i['lon']. ' | '. "<br>\n";
|
||||
}
|
||||
}
|
||||
$aPlaceLine = $this->oDB->getRow($sSQL);
|
||||
if (PEAR::IsError($aPlaceLine))
|
||||
{
|
||||
failInternalError("Could not determine closest housenumber on an osm interpolation line.", $sSQL, $aPlaceLine);
|
||||
}
|
||||
if ($aPlaceLine)
|
||||
{
|
||||
if (CONST_Debug) var_dump('found housenumber in interpolation lines table', $aPlaceLine);
|
||||
if ($aPlace['rank_search'] == 30)
|
||||
{
|
||||
// if a house was already found in placex, we have to find out,
|
||||
// if the placex house or the interpolated house are closer to the searched point
|
||||
// distance between point and placex house
|
||||
$sSQL = 'SELECT ST_distance('.$sPointSQL.', house.geometry) as distance FROM placex as house WHERE house.place_id='.$iPlaceID;
|
||||
$aDistancePlacex = $this->oDB->getRow($sSQL);
|
||||
if (PEAR::IsError($aDistancePlacex))
|
||||
{
|
||||
failInternalError("Could not determine distance between searched point and placex house.", $sSQL, $aDistancePlacex);
|
||||
}
|
||||
$fDistancePlacex = $aDistancePlacex['distance'];
|
||||
// distance between point and interpolated house (fraction on interpolation line)
|
||||
$sSQL = 'SELECT ST_distance('.$sPointSQL.', ST_LineInterpolatePoint(linegeo, '.$aPlaceLine['fraction'].')) as distance';
|
||||
$sSQL .= ' FROM location_property_osmline WHERE place_id = '.$aPlaceLine['place_id'];
|
||||
$aDistanceInterpolation = $this->oDB->getRow($sSQL);
|
||||
if (PEAR::IsError($aDistanceInterpolation))
|
||||
{
|
||||
failInternalError("Could not determine distance between searched point and interpolated house.", $sSQL, $aDistanceInterpolation);
|
||||
}
|
||||
$fDistanceInterpolation = $aDistanceInterpolation['distance'];
|
||||
if ($fDistanceInterpolation < $fDistancePlacex)
|
||||
{
|
||||
// interpolation is closer to point than placex house
|
||||
$bPlaceIsLine = true;
|
||||
$aPlace = $aPlaceLine;
|
||||
$iPlaceID = $aPlaceLine['place_id'];
|
||||
$iParentPlaceID = $aPlaceLine['parent_place_id']; // the street
|
||||
$fFraction = $aPlaceLine['fraction'];
|
||||
}
|
||||
// else: nothing to do, take placex house from above
|
||||
}
|
||||
else
|
||||
{
|
||||
$bPlaceIsLine = true;
|
||||
$aPlace = $aPlaceLine;
|
||||
$iPlaceID = $aPlaceLine['place_id'];
|
||||
$iParentPlaceID = $aPlaceLine['parent_place_id']; // the street
|
||||
$fFraction = $aPlaceLine['fraction'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only street found? If it's in the US we can check TIGER data for nearest housenumber
|
||||
if (CONST_Use_US_Tiger_Data && $bIsInUnitedStates && $iMaxRank_orig >= 28 && $iPlaceID && ($aPlace['rank_search'] == 26 || $aPlace['rank_search'] == 27 ))
|
||||
{
|
||||
@@ -180,25 +252,25 @@
|
||||
}
|
||||
|
||||
$aPlaceTiger = $this->oDB->getRow($sSQL);
|
||||
if (PEAR::IsError($aPlace))
|
||||
if (PEAR::IsError($aPlaceTiger))
|
||||
{
|
||||
failInternalError("Could not determine closest Tiger place.", $sSQL, $aPlaceTiger);
|
||||
}
|
||||
if ($aPlaceTiger)
|
||||
{
|
||||
if (CONST_Debug) var_dump('found Tiger place', $aPlaceTiger);
|
||||
if (CONST_Debug) var_dump('found Tiger housenumber', $aPlaceTiger);
|
||||
$bPlaceIsTiger = true;
|
||||
$aPlace = $aPlaceTiger;
|
||||
$iPlaceID = $aPlaceTiger['place_id'];
|
||||
$iParentPlaceID = $aPlaceTiger['parent_place_id']; // the street
|
||||
$iFraction = $aPlaceTiger['fraction'];
|
||||
$fFraction = $aPlaceTiger['fraction'];
|
||||
}
|
||||
}
|
||||
|
||||
// The point we found might be too small - use the address to find what it is a child of
|
||||
if ($iPlaceID && $iMaxRank < 28)
|
||||
{
|
||||
if ($aPlace['rank_search'] > 28 && $iParentPlaceID && !$bPlaceIsTiger)
|
||||
if (($aPlace['rank_search'] > 28 || $bPlaceIsTiger || $bPlaceIsLine) && $iParentPlaceID)
|
||||
{
|
||||
$iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
@@ -217,10 +289,9 @@
|
||||
$iPlaceID = $aPlace['place_id'];
|
||||
}
|
||||
}
|
||||
|
||||
return array('place_id' => $iPlaceID,
|
||||
'type' => $bPlaceIsTiger ? 'tiger' : 'osm',
|
||||
'fraction' => $bPlaceIsTiger ? $iFraction : -1);
|
||||
'type' => $bPlaceIsTiger ? 'tiger' : $bPlaceIsLine ? 'interpolation' : 'osm',
|
||||
'fraction' => ($bPlaceIsTiger || $bPlaceIsLine) ? $fFraction : -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
{
|
||||
if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
|
||||
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright";
|
||||
$sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':'')));
|
||||
$sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':
|
||||
($aPlace['osm_type'] == 'T'?'tiger':($aPlace['osm_type'] == 'I'?'interpolation':'')))));
|
||||
if ($sOSMType)
|
||||
{
|
||||
$aFilteredPlaces['osm_type'] = $sOSMType;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
{
|
||||
if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
|
||||
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright";
|
||||
$sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':'')));
|
||||
$sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':
|
||||
($aPlace['osm_type'] == 'T'?'tiger':($aPlace['osm_type'] == 'I'?'interpolation':'')))));
|
||||
if ($sOSMType)
|
||||
{
|
||||
$aFilteredPlaces['osm_type'] = $sOSMType;
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
{
|
||||
echo "<result";
|
||||
if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
|
||||
$sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':'')));
|
||||
$sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':
|
||||
($aPlace['osm_type'] == 'T'?'tiger':($aPlace['osm_type'] == 'I'?'interpolation':'')))));
|
||||
if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
|
||||
if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
|
||||
if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
|
||||
);
|
||||
|
||||
$sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':($aPointDetails['osm_type'] == 'T'?'tiger':''))));
|
||||
$sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?
|
||||
'relation':($aPointDetails['osm_type'] == 'T'?'tiger':($aPointDetails['osm_type'] == 'I'?'interpolation':'')))));
|
||||
if ($sOSMType)
|
||||
{
|
||||
$aPlace['osm_type'] = $sOSMType;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
|
||||
);
|
||||
|
||||
$sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':($aPointDetails['osm_type'] == 'T'?'tiger':''))));
|
||||
$sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':($aPointDetails['osm_type'] == 'T'?'tiger':($aPointDetails['osm_type'] == 'I'?'interpolation':'')))));
|
||||
if ($sOSMType)
|
||||
{
|
||||
$aPlace['osm_type'] = $sOSMType;
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
foreach($aSearchResults as $iResNum => $aResult)
|
||||
{
|
||||
echo "<place place_id='".$aResult['place_id']."'";
|
||||
$sOSMType = ($aResult['osm_type'] == 'N'?'node':($aResult['osm_type'] == 'W'?'way':($aResult['osm_type'] == 'R'?'relation':($aResult['osm_type'] == 'T'?'tiger':''))));
|
||||
$sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':
|
||||
($aPointDetails['osm_type'] == 'T'?'tiger':($aPointDetails['osm_type'] == 'I'?'interpolation':'')))));
|
||||
if ($sOSMType)
|
||||
{
|
||||
echo " osm_type='$sOSMType'";
|
||||
|
||||
Reference in New Issue
Block a user