]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/setup.php
make sure no invalid geometries end up in placex
[nominatim.git] / utils / setup.php
index c25dc094efefd39056bdb8bbbf1a83b94cd0af3a..5ec410000e96a40059dd711cff78f402a5f92cbb 100755 (executable)
@@ -367,7 +367,9 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) {
         $sSQL = 'insert into placex (osm_type, osm_id, class, type, name, admin_level, ';
         $sSQL .= '                   address, extratags, geometry) ';
         $sSQL .= 'select * from place where osm_id % '.$iLoadThreads.' = '.$i;
-        $sSQL .= " and not (class='place' and type='houses' and osm_type='W' and ST_GeometryType(geometry) = 'ST_LineString')";
+        $sSQL .= " and not (class='place' and type='houses' and osm_type='W'";
+        $sSQL .= "          and ST_GeometryType(geometry) = 'ST_LineString')";
+        $sSQL .= " and ST_IsValid(geometry)";
         if ($aCMDResult['verbose']) echo "$sSQL\n";
         if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) {
             fail(pg_last_error($aDBInstances[$i]->connection));
@@ -381,7 +383,7 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) {
     $sSQL .= "class='place' and type='houses' and osm_type='W' and ST_GeometryType(geometry) = 'ST_LineString'";
     if ($aCMDResult['verbose']) echo "$sSQL\n";
     if (!pg_send_query($aDBInstances[$iLoadThreads]->connection, $sSQL)) {
-        fail(pg_last_error($aDBInstances[$iLoadThreads]->->connection));
+        fail(pg_last_error($aDBInstances[$iLoadThreads]->connection));
     }
 
     $bAnyBusy = true;