From: Sarah Hoffmann Date: Thu, 30 Apr 2015 19:26:11 +0000 (+0200) Subject: Merge branch 'feature/polygon-simplification' of https://github.com/a1exsh/Nominatim X-Git-Tag: v.2.5.0~62 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/a7e1b3b1eeec1cebc71ee7ae0282dfe3bb31456c?ds=inline;hp=-c Merge branch 'feature/polygon-simplification' of https://github.com/a1exsh/Nominatim --- a7e1b3b1eeec1cebc71ee7ae0282dfe3bb31456c diff --combined lib/Geocode.php index 5f4a0174,6781ceec..212eebb9 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@@ -12,6 -12,7 +12,7 @@@ protected $bIncludePolygonAsGeoJSON = false; protected $bIncludePolygonAsKML = false; protected $bIncludePolygonAsSVG = false; + protected $fPolygonSimplificationThreshold = 0.0; protected $aExcludePlaceIDs = array(); protected $bDeDupe = true; @@@ -102,6 -103,11 +103,11 @@@ $this->bIncludePolygonAsSVG = $b; } + function setPolygonSimplificationThreshold($f) + { + $this->fPolygonSimplificationThreshold = $f; + } + function setDeDupe($bDeDupe = true) { $this->bDeDupe = (bool)$bDeDupe; @@@ -578,6 -584,18 +584,6 @@@ else $aSearch['sOperator'] = 'near'; // near = in for the moment if (strlen($aSearchTerm['operator']) == 0) $aSearch['iSearchRank'] += 1; - // Do we have a shortcut id? - if ($aSearch['sOperator'] == 'name') - { - $sSQL = "select get_tagpair('".$aSearch['sClass']."', '".$aSearch['sType']."')"; - if ($iAmenityID = $this->oDB->getOne($sSQL)) - { - $aValidTokens[$aSearch['sClass'].':'.$aSearch['sType']] = array('word_id' => $iAmenityID); - $aSearch['aName'][$iAmenityID] = $iAmenityID; - $aSearch['sClass'] = ''; - $aSearch['sType'] = ''; - } - } if ($aSearch['iSearchRank'] < $this->iMaxRank) $aNewWordsetSearches[] = $aSearch; } } @@@ -756,6 -774,7 +762,6 @@@ if (!$this->sQuery && !$this->aStructuredQuery) return false; $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$this->aLangPrefOrder))."]"; - $sCountryCodesSQL = false; if ($this->aCountryCodes && sizeof($this->aCountryCodes)) { @@@ -1599,7 -1618,16 +1605,16 @@@ if ($this->bIncludePolygonAsKML) $sSQL .= ",ST_AsKML(geometry) as askml"; if ($this->bIncludePolygonAsSVG) $sSQL .= ",ST_AsSVG(geometry) as assvg"; if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ",ST_AsText(geometry) as astext"; - $sSQL .= " from placex where place_id = ".$aResult['place_id']; + $sFrom = " from placex where place_id = ".$aResult['place_id']; + if ($this->fPolygonSimplificationThreshold > 0) + { + $sSQL .= " from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,".$this->fPolygonSimplificationThreshold.") as geometry".$sFrom.") as plx"; + } + else + { + $sSQL .= $sFrom; + } + $aPointPolygon = $this->oDB->getRow($sSQL); if (PEAR::IsError($aPointPolygon)) {