X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/1a4506f6aba70307f4607fda314071dbd14b6f66..c3940466b817a4c10a956f61c43d6bee3214dd40:/lib/PlaceLookup.php diff --git a/lib/PlaceLookup.php b/lib/PlaceLookup.php index f7617d82..6d190c2a 100644 --- a/lib/PlaceLookup.php +++ b/lib/PlaceLookup.php @@ -32,75 +32,104 @@ class PlaceLookup $this->oDB =& $oDB; } - public function setAnchorSql($sPoint) + public function doDeDupe() { - $this->sAnchorSql = $sPoint; + return $this->bDeDupe; } - public function setDeDupe($bDeDupe) + public function setIncludePolygonAsPoints($b = true) { - $this->bDeDupe = $bDeDupe; + $this->bIncludePolygonAsPoints = $b; } - public function setAddressRankList($aList) + public function loadParamArray($oParams, $sGeomType = null) { - $this->sAddressRankListSql = '('.join(',', $aList).')'; - } + $aLangs = $oParams->getPreferredLanguages(); + $this->aLangPrefOrderSql = + 'ARRAY['.join(',', array_map('getDBQuoted', $aLangs)).']'; - public function setAllowedTypesSQLList($sSql) - { - $this->sAllowedTypesSQLList = $sSql; - } + $this->bAddressDetails = $oParams->getBool('addressdetails', true); + $this->bExtraTags = $oParams->getBool('extratags', false); + $this->bNameDetails = $oParams->getBool('namedetails', false); - public function setLanguagePreference($aLangPrefOrder) - { - $this->aLangPrefOrderSql = - 'ARRAY['.join(',', array_map('getDBQuoted', $aLangPrefOrder)).']'; - } + $this->bDeDupe = $oParams->getBool('dedupe', $this->bDeDupe); - public function setIncludeAddressDetails($bAddressDetails = true) - { - $this->bAddressDetails = $bAddressDetails; + if ($sGeomType === null || $sGeomType == 'text') { + $this->bIncludePolygonAsText = $oParams->getBool('polygon_text'); + } + if ($sGeomType === null || $sGeomType == 'geojson') { + $this->bIncludePolygonAsGeoJSON = $oParams->getBool('polygon_geojson'); + } + if ($sGeomType === null || $sGeomType == 'kml') { + $this->bIncludePolygonAsKML = $oParams->getBool('polygon_kml'); + } + if ($sGeomType === null || $sGeomType == 'svg') { + $this->bIncludePolygonAsSVG = $oParams->getBool('polygon_svg'); + } + $this->fPolygonSimplificationThreshold + = $oParams->getFloat('polygon_threshold', 0.0); + + $iWantedTypes = + ($this->bIncludePolygonAsText ? 1 : 0) + + ($this->bIncludePolygonAsGeoJSON ? 1 : 0) + + ($this->bIncludePolygonAsKML ? 1 : 0) + + ($this->bIncludePolygonAsSVG ? 1 : 0); + if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) { + if (CONST_PolygonOutput_MaximumTypes) { + userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option"); + } else { + userError("Polygon output is disabled"); + } + } } - public function setIncludeExtraTags($bExtraTags = false) + public function getMoreUrlParams() { - $this->bExtraTags = $bExtraTags; - } + $aParams = array(); - public function setIncludeNameDetails($bNameDetails = false) - { - $this->bNameDetails = $bNameDetails; - } + if ($this->bAddressDetails) $aParams['addressdetails'] = '1'; + if ($this->bExtraTags) $aParams['extratags'] = '1'; + if ($this->bNameDetails) $aParams['namedetails'] = '1'; - public function setIncludePolygonAsPoints($b = true) - { - $this->bIncludePolygonAsPoints = $b; + if ($this->bIncludePolygonAsPoints) $aParams['polygon'] = '1'; + if ($this->bIncludePolygonAsText) $aParams['polygon_text'] = '1'; + if ($this->bIncludePolygonAsGeoJSON) $aParams['polygon_geojson'] = '1'; + if ($this->bIncludePolygonAsKML) $aParams['polygon_kml'] = '1'; + if ($this->bIncludePolygonAsSVG) $aParams['polygon_svg'] = '1'; + + if ($this->fPolygonSimplificationThreshold > 0.0) { + $aParams['polygon_threshold'] = $this->fPolygonSimplificationThreshold; + } + + if (!$this->bDeDupe) $aParams['dedupe'] = '0'; + + return $aParams; } - public function setIncludePolygonAsText($b = true) + public function setAnchorSql($sPoint) { - $this->bIncludePolygonAsText = $b; + $this->sAnchorSql = $sPoint; } - public function setIncludePolygonAsGeoJSON($b = true) + public function setAddressRankList($aList) { - $this->bIncludePolygonAsGeoJSON = $b; + $this->sAddressRankListSql = '('.join(',', $aList).')'; } - public function setIncludePolygonAsKML($b = true) + public function setAllowedTypesSQLList($sSql) { - $this->bIncludePolygonAsKML = $b; + $this->sAllowedTypesSQLList = $sSql; } - public function setIncludePolygonAsSVG($b = true) + public function setLanguagePreference($aLangPrefOrder) { - $this->bIncludePolygonAsSVG = $b; + $this->aLangPrefOrderSql = + 'ARRAY['.join(',', array_map('getDBQuoted', $aLangPrefOrder)).']'; } - public function setPolygonSimplificationThreshold($f) + public function setIncludeAddressDetails($bAddressDetails = true) { - $this->fPolygonSimplificationThreshold = $f; + $this->bAddressDetails = $bAddressDetails; } private function addressImportanceSql($sGeometry, $sPlaceId) @@ -158,7 +187,7 @@ class PlaceLookup $sSQL .= ' rank_address,'; $sSQL .= ' min(place_id) AS place_id,'; $sSQL .= ' min(parent_place_id) AS parent_place_id,'; - $sSQL .= ' housenumber,'; + $sSQL .= ' -1 as housenumber,'; $sSQL .= ' country_code,'; $sSQL .= $this->langAddressSql('-1'); $sSQL .= ' get_name_by_language(name,'.$this->aLangPrefOrderSql.') AS placename,';