$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)
$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,';
$sSQL .= ' avg(ST_Y(centroid)) AS lat, ';
$sSQL .= ' COALESCE(importance,0.75-(rank_search::float/40)) AS importance, ';
$sSQL .= $this->addressImportanceSql(
- 'centroid',
+ 'ST_Collect(centroid)',
'min(CASE WHEN placex.rank_search < 28 THEN placex.place_id ELSE placex.parent_place_id END)'
);
$sSQL .= " (extratags->'place') AS extra_place ";
"Could not lookup place"
);
+ $aClassType = getClassTypes();
foreach ($aPlaces as &$aPlace) {
if ($this->bAddressDetails) {
// to get addressdetails for tiger data, the housenumber is needed
}
}
- $aClassType = getClassTypes();
$sAddressType = '';
$sClassType = $aPlace['class'].':'.$aPlace['type'].':'.$aPlace['admin_level'];
if (isset($aClassType[$sClassType]) && isset($aClassType[$sClassType]['simplelabel'])) {