X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/db3ced17bbfff00411f506d8c84419c875959d5e..d5a1883b627147c2a0117fb2af3b8b1a7b07ca64:/lib-php/PlaceLookup.php?ds=inline diff --git a/lib-php/PlaceLookup.php b/lib-php/PlaceLookup.php index 6d7b6be1..7e78d536 100644 --- a/lib-php/PlaceLookup.php +++ b/lib-php/PlaceLookup.php @@ -89,20 +89,36 @@ class PlaceLookup { $aParams = array(); - if ($this->bAddressDetails) $aParams['addressdetails'] = '1'; - if ($this->bExtraTags) $aParams['extratags'] = '1'; - if ($this->bNameDetails) $aParams['namedetails'] = '1'; + if ($this->bAddressDetails) { + $aParams['addressdetails'] = '1'; + } + if ($this->bExtraTags) { + $aParams['extratags'] = '1'; + } + if ($this->bNameDetails) { + $aParams['namedetails'] = '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->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'; + if (!$this->bDeDupe) { + $aParams['dedupe'] = '0'; + } return $aParams; } @@ -147,8 +163,9 @@ class PlaceLookup private function langAddressSql($sHousenumber) { - if ($this->bAddressDetails) + if ($this->bAddressDetails) { return ''; // langaddress will be computed from address details + } return 'get_address_by_language(place_id,'.$sHousenumber.','.$this->aLangPrefOrderSql.') AS langaddress,'; } @@ -234,12 +251,20 @@ class PlaceLookup $sSQL .= ' housenumber,'; $sSQL .= ' country_code, '; $sSQL .= ' importance, '; - if (!$this->bDeDupe) $sSQL .= 'place_id,'; - if (!$this->bAddressDetails) $sSQL .= 'langaddress, '; + if (!$this->bDeDupe) { + $sSQL .= 'place_id,'; + } + if (!$this->bAddressDetails) { + $sSQL .= 'langaddress, '; + } $sSQL .= ' placename, '; $sSQL .= ' ref, '; - if ($this->bExtraTags) $sSQL .= 'extratags, '; - if ($this->bNameDetails) $sSQL .= 'name, '; + if ($this->bExtraTags) { + $sSQL .= 'extratags, '; + } + if ($this->bNameDetails) { + $sSQL .= 'name, '; + } $sSQL .= ' extra_place '; $aSubSelects[] = $sSQL; @@ -260,8 +285,12 @@ class PlaceLookup $sSQL .= $this->langAddressSql('-1'); $sSQL .= ' postcode as placename,'; $sSQL .= ' postcode as ref,'; - if ($this->bExtraTags) $sSQL .= 'null::text AS extra,'; - if ($this->bNameDetails) $sSQL .= 'null::text AS names,'; + if ($this->bExtraTags) { + $sSQL .= 'null::text AS extra,'; + } + if ($this->bNameDetails) { + $sSQL .= 'null::text AS names,'; + } $sSQL .= ' ST_x(geometry) AS lon, ST_y(geometry) AS lat,'; $sSQL .= ' (0.75-(rank_search::float/40)) AS importance, '; $sSQL .= $this->addressImportanceSql('geometry', 'lp.parent_place_id'); @@ -298,8 +327,12 @@ class PlaceLookup $sSQL .= $this->langAddressSql('housenumber_for_place'); $sSQL .= ' null::text AS placename, '; $sSQL .= ' null::text AS ref, '; - if ($this->bExtraTags) $sSQL .= 'null::text AS extra,'; - if ($this->bNameDetails) $sSQL .= 'null::text AS names,'; + if ($this->bExtraTags) { + $sSQL .= 'null::text AS extra,'; + } + if ($this->bNameDetails) { + $sSQL .= 'null::text AS names,'; + } $sSQL .= ' st_x(centroid) AS lon, '; $sSQL .= ' st_y(centroid) AS lat,'; $sSQL .= ' -1.15 AS importance, '; @@ -344,8 +377,12 @@ class PlaceLookup $sSQL .= $this->langAddressSql('housenumber_for_place'); $sSQL .= ' null::text AS placename, '; $sSQL .= ' null::text AS ref, '; - if ($this->bExtraTags) $sSQL .= 'null::text AS extra, '; - if ($this->bNameDetails) $sSQL .= 'null::text AS names, '; + if ($this->bExtraTags) { + $sSQL .= 'null::text AS extra, '; + } + if ($this->bNameDetails) { + $sSQL .= 'null::text AS names, '; + } $sSQL .= ' st_x(centroid) AS lon, '; $sSQL .= ' st_y(centroid) AS lat, '; // slightly smaller than the importance for normal houses @@ -373,42 +410,6 @@ class PlaceLookup $aSubSelects[] = $sSQL; } - - if (CONST_Use_Aux_Location_data) { - $sPlaceIDs = Result::joinIdsByTable($aResults, Result::TABLE_AUX); - if ($sPlaceIDs) { - $sHousenumbers = Result::sqlHouseNumberTable($aResults, Result::TABLE_AUX); - $sSQL = ' SELECT '; - $sSQL .= " 'L' AS osm_type, "; - $sSQL .= ' place_id AS osm_id, '; - $sSQL .= " 'place' AS class,"; - $sSQL .= " 'house' AS type, "; - $sSQL .= ' null::smallint AS admin_level, '; - $sSQL .= ' 30 AS rank_search,'; - $sSQL .= ' 30 AS rank_address, '; - $sSQL .= ' place_id,'; - $sSQL .= ' parent_place_id, '; - $sSQL .= ' housenumber,'; - $sSQL .= " 'us' AS country_code, "; - $sSQL .= $this->langAddressSql('-1'); - $sSQL .= ' null::text AS placename, '; - $sSQL .= ' null::text AS ref, '; - if ($this->bExtraTags) $sSQL .= 'null::text AS extra, '; - if ($this->bNameDetails) $sSQL .= 'null::text AS names, '; - $sSQL .= ' ST_X(centroid) AS lon, '; - $sSQL .= ' ST_Y(centroid) AS lat, '; - $sSQL .= ' -1.10 AS importance, '; - $sSQL .= $this->addressImportanceSql( - 'centroid', - 'location_property_aux.parent_place_id' - ); - $sSQL .= ' null::text AS extra_place '; - $sSQL .= ' FROM location_property_aux '; - $sSQL .= " WHERE place_id in ($sPlaceIDs) "; - - $aSubSelects[] = $sSQL; - } - } } if (empty($aSubSelects)) { @@ -484,7 +485,9 @@ class PlaceLookup { $aOutlineResult = array(); - if (!$iPlaceID) return $aOutlineResult; + if (!$iPlaceID) { + return $aOutlineResult; + } // Get the bounding box and outline polygon $sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,'; @@ -496,10 +499,18 @@ class PlaceLookup } $sSQL .= ' ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,'; $sSQL .= ' ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon'; - if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson'; - if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml'; - if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg'; - if ($this->bIncludePolygonAsText) $sSQL .= ',ST_AsText(geometry) as astext'; + if ($this->bIncludePolygonAsGeoJSON) { + $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson'; + } + if ($this->bIncludePolygonAsKML) { + $sSQL .= ',ST_AsKML(geometry) as askml'; + } + if ($this->bIncludePolygonAsSVG) { + $sSQL .= ',ST_AsSVG(geometry) as assvg'; + } + if ($this->bIncludePolygonAsText) { + $sSQL .= ',ST_AsText(geometry) as astext'; + } if ($fLonReverse != null && $fLatReverse != null) { $sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN '; $sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))'; @@ -522,10 +533,18 @@ class PlaceLookup $aOutlineResult['lon'] = $aPointPolygon['centrelon']; } - if ($this->bIncludePolygonAsGeoJSON) $aOutlineResult['asgeojson'] = $aPointPolygon['asgeojson']; - if ($this->bIncludePolygonAsKML) $aOutlineResult['askml'] = $aPointPolygon['askml']; - if ($this->bIncludePolygonAsSVG) $aOutlineResult['assvg'] = $aPointPolygon['assvg']; - if ($this->bIncludePolygonAsText) $aOutlineResult['astext'] = $aPointPolygon['astext']; + if ($this->bIncludePolygonAsGeoJSON) { + $aOutlineResult['asgeojson'] = $aPointPolygon['asgeojson']; + } + if ($this->bIncludePolygonAsKML) { + $aOutlineResult['askml'] = $aPointPolygon['askml']; + } + if ($this->bIncludePolygonAsSVG) { + $aOutlineResult['assvg'] = $aPointPolygon['assvg']; + } + if ($this->bIncludePolygonAsText) { + $aOutlineResult['astext'] = $aPointPolygon['astext']; + } if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) { $aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;