From 0e3ac756c9ad412cbbb7d1d1399eeec1bd50c0bd Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 8 Nov 2012 00:06:47 +0100 Subject: [PATCH 1/1] extend error reporting for invalid geometries --- lib/template/details-error-html.php | 148 ++++++++++++++++++++++++++++ sql/tables.sql | 2 +- website/details.php | 18 ++-- 3 files changed, 160 insertions(+), 8 deletions(-) create mode 100644 lib/template/details-error-html.php diff --git a/lib/template/details-error-html.php b/lib/template/details-error-html.php new file mode 100644 index 00000000..ee23e661 --- /dev/null +++ b/lib/template/details-error-html.php @@ -0,0 +1,148 @@ + + + + OpenStreetMap Nominatim: <?php echo $aPointDetails['localname'];?> + + + + + + +
+

+
+
Type:
+ +OSM: '.$sOSMType.' '. $aPointDetails['osm_id'].'
'; +?> + +

This object has an invalid geometry.

+

Details:

+ + + diff --git a/sql/tables.sql b/sql/tables.sql index 8f933abc..efbe323e 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -216,7 +216,6 @@ CREATE INDEX idx_placex_adminname on placex USING BTREE (make_standard_name(name DROP SEQUENCE seq_place; CREATE SEQUENCE seq_place start 1; -GRANT SELECT on place to "www-data" ; GRANT SELECT on placex to "www-data" ; GRANT UPDATE ON placex to "www-data" ; GRANT SELECT ON search_name to "www-data" ; @@ -279,6 +278,7 @@ CREATE TABLE import_polygon_error ( SELECT AddGeometryColumn('import_polygon_error', 'prevgeometry', 4326, 'GEOMETRY', 2); SELECT AddGeometryColumn('import_polygon_error', 'newgeometry', 4326, 'GEOMETRY', 2); CREATE INDEX idx_import_polygon_error_osmid ON import_polygon_error USING BTREE (osm_type, osm_id); +GRANT SELECT ON import_polygon_error TO "www-data"; drop table import_polygon_delete; CREATE TABLE import_polygon_delete ( diff --git a/website/details.php b/website/details.php index c92e3f77..dcfe2090 100755 --- a/website/details.php +++ b/website/details.php @@ -15,6 +15,9 @@ $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"); @@ -22,10 +25,14 @@ // Be nice about our error messages for broken geometry if (!$_GET['place_id']) { - $sErrorMessage = $oDB->getOne("select ST_IsValidReason(geometry) from place where osm_type = '".$_GET['osmtype']."' and osm_id = ".(int)$_GET['osmid']." order by type = 'postcode' asc"); - if (!PEAR::isError($sErrorMessage) && $sErrorMessage) { - echo "Problem with geometry: "; - echo $sErrorMessage; + $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; } } @@ -44,9 +51,6 @@ $iParentPlaceID = $oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID); if ($iParentPlaceID) $iPlaceID = $iParentPlaceID; - $aLangPrefOrder = getPreferredLanguages(); - $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 -- 2.39.5