]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/PlaceLookup.php
utils/check_import_finished: skip some checks when setup ran with --drop
[nominatim.git] / lib / PlaceLookup.php
index 58510e266f5a99da705c5ca2303d5c4d3a59f26c..6d7b6be1af4ed6dd04d5e1a6e79fb9050746252e 100644 (file)
@@ -486,65 +486,63 @@ class PlaceLookup
         $aOutlineResult = array();
         if (!$iPlaceID) return $aOutlineResult;
 
-        if (CONST_Search_AreaPolygons) {
-            // Get the bounding box and outline polygon
-            $sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,';
-            if ($fLonReverse != null && $fLatReverse != null) {
-                $sSQL .= ' ST_Y(closest_point) as centrelat,';
-                $sSQL .= ' ST_X(closest_point) as centrelon,';
-            } else {
-                $sSQL .= ' ST_Y(centroid) as centrelat, ST_X(centroid) as centrelon,';
-            }
-            $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 ($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))';
-                $sFrom .=' ELSE centroid END AS closest_point';
-                $sFrom .= ' from placex where place_id = '.$iPlaceID.') as plx';
-            } else {
-                $sFrom = ' from placex where place_id = '.$iPlaceID;
-            }
-            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, null, 'Could not get outline');
+        // Get the bounding box and outline polygon
+        $sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,';
+        if ($fLonReverse != null && $fLatReverse != null) {
+            $sSQL .= ' ST_Y(closest_point) as centrelat,';
+            $sSQL .= ' ST_X(closest_point) as centrelon,';
+        } else {
+            $sSQL .= ' ST_Y(centroid) as centrelat, ST_X(centroid) as centrelon,';
+        }
+        $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 ($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))';
+            $sFrom .=' ELSE centroid END AS closest_point';
+            $sFrom .= ' from placex where place_id = '.$iPlaceID.') as plx';
+        } else {
+            $sFrom = ' from placex where place_id = '.$iPlaceID;
+        }
+        if ($this->fPolygonSimplificationThreshold > 0) {
+            $sSQL .= ' from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry'.$sFrom.') as plx';
+        } else {
+            $sSQL .= $sFrom;
+        }
 
-            if ($aPointPolygon && $aPointPolygon['place_id']) {
-                if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
-                    $aOutlineResult['lat'] = $aPointPolygon['centrelat'];
-                    $aOutlineResult['lon'] = $aPointPolygon['centrelon'];
-                }
+        $aPointPolygon = $this->oDB->getRow($sSQL, null, 'Could not get outline');
 
-                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 ($aPointPolygon && $aPointPolygon['place_id']) {
+            if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
+                $aOutlineResult['lat'] = $aPointPolygon['centrelat'];
+                $aOutlineResult['lon'] = $aPointPolygon['centrelon'];
+            }
 
-                if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) {
-                    $aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
-                    $aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
-                }
+            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['minlon'] - $aPointPolygon['maxlon']) < 0.0000001) {
-                    $aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
-                    $aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
-                }
+            if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) {
+                $aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
+                $aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
+            }
 
-                $aOutlineResult['aBoundingBox'] = array(
-                                                   (string)$aPointPolygon['minlat'],
-                                                   (string)$aPointPolygon['maxlat'],
-                                                   (string)$aPointPolygon['minlon'],
-                                                   (string)$aPointPolygon['maxlon']
-                                                  );
+            if (abs($aPointPolygon['minlon'] - $aPointPolygon['maxlon']) < 0.0000001) {
+                $aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
+                $aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
             }
+
+            $aOutlineResult['aBoundingBox'] = array(
+                                               (string)$aPointPolygon['minlat'],
+                                               (string)$aPointPolygon['maxlat'],
+                                               (string)$aPointPolygon['minlon'],
+                                               (string)$aPointPolygon['maxlon']
+                                              );
         }
 
         // as a fallback we generate a bounding box without knowing the size of the geometry