]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/details.php
extend error reporting for invalid geometries
[nominatim.git] / website / details.php
index 7c6ad8ad4f17cc1428cc11afa7485698ec51b603..dcfe2090bf37ff4b06d72292048959dc2797c353 100755 (executable)
 
        $oDB =& getDB();
 
+       $aLangPrefOrder = getPreferredLanguages();
+       $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
+
        if (isset($_GET['osmtype']) && isset($_GET['osmid']) && (int)$_GET['osmid'] && ($_GET['osmtype'] == 'N' || $_GET['osmtype'] == 'W' || $_GET['osmtype'] == 'R'))
        {
                $_GET['place_id'] = $oDB->getOne("select place_id from placex where osm_type = '".$_GET['osmtype']."' and osm_id = ".(int)$_GET['osmid']." order by type = 'postcode' asc");
+
+               // Be nice about our error messages for broken geometry
+               if (!$_GET['place_id'])
+               {
+                       $aPointDetails = $oDB->getRow("select osm_type, osm_id, errormessage, class, type, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ST_AsText(prevgeometry) as prevgeom, ST_AsText(newgeometry) as newgeom from import_polygon_error where osm_type = '".$_GET['osmtype']."' and osm_id = ".(int)$_GET['osmid']." order by updated desc limit 1");
+                       if (!PEAR::isError($aPointDetails) && $aPointDetails) {
+                               if (preg_match('/\[(-?\d+\.\d+) (-?\d+\.\d+)\]/', $aPointDetails['errormessage'], $aMatches))
+                               {
+                                       $aPointDetails['error_x'] = $aMatches[1];
+                                       $aPointDetails['error_y'] = $aMatches[2];
+                               }
+                               include(CONST_BasePath.'/lib/template/details-error-'.$sOutputFormat.'.php');
+                               exit;
+                       }
+               }
        }
 
        if (!isset($_GET['place_id']))
@@ -33,9 +51,6 @@
        $iParentPlaceID = $oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID);
        if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
 
-       $aLangPrefOrder = getPrefferedLangauges();
-       $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
-
        $hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
 
        // Make sure the point we are reporting on is fully indexed
@@ -43,7 +58,7 @@
        //$oDB->query($sSQL);
 
        // Get the details for this point
-       $sSQL = "select place_id, osm_type, osm_id, class, type, name, admin_level, housenumber, street, isin, postcode, country_code, importance,";
+       $sSQL = "select place_id, osm_type, osm_id, class, type, name, admin_level, housenumber, street, isin, postcode, country_code, importance, wikipedia,";
        $sSQL .= " parent_place_id, rank_address, rank_search, get_searchrank_label(rank_search) as rank_search_label, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ";
        $sSQL .= " ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea,ST_GeometryType(geometry) as geotype, ST_Y(ST_Centroid(geometry)) as lat,ST_X(ST_Centroid(geometry)) as lon ";
        $sSQL .= " from placex where place_id = $iPlaceID";