mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-10 11:42:13 +03:00
extend error reporting for invalid geometries
This commit is contained in:
parent
e5909cc78a
commit
0e3ac756c9
148
lib/template/details-error-html.php
Normal file
148
lib/template/details-error-html.php
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
header("content-type: text/html; charset=UTF-8");
|
||||||
|
?>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OpenStreetMap Nominatim: <?php echo $aPointDetails['localname'];?></title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin:0px;
|
||||||
|
padding:16px;
|
||||||
|
background:#ffffff;
|
||||||
|
height: 100%;
|
||||||
|
font: normal 12px/15px arial,sans-serif;
|
||||||
|
}
|
||||||
|
.line{
|
||||||
|
margin-left:20px;
|
||||||
|
}
|
||||||
|
.name{
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.notused{
|
||||||
|
color:#ddd;
|
||||||
|
}
|
||||||
|
.noname{
|
||||||
|
color:#800;
|
||||||
|
}
|
||||||
|
#map {
|
||||||
|
width:500px;
|
||||||
|
height:500px;
|
||||||
|
border: 2px solid #666;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="js/OpenLayers.js"></script>
|
||||||
|
<script src="js/tiles.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var map;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
map = new OpenLayers.Map ("map", {
|
||||||
|
controls:[
|
||||||
|
new OpenLayers.Control.Permalink(),
|
||||||
|
new OpenLayers.Control.Navigation(),
|
||||||
|
new OpenLayers.Control.PanZoomBar(),
|
||||||
|
new OpenLayers.Control.MouseDefaults(),
|
||||||
|
new OpenLayers.Control.MousePosition(),
|
||||||
|
new OpenLayers.Control.Attribution()],
|
||||||
|
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
|
||||||
|
maxResolution: 156543.0399,
|
||||||
|
numZoomLevels: 19,
|
||||||
|
units: 'm',
|
||||||
|
projection: new OpenLayers.Projection("EPSG:900913"),
|
||||||
|
displayProjection: new OpenLayers.Projection("EPSG:4326")
|
||||||
|
} );
|
||||||
|
map.addLayer(new OpenLayers.Layer.OSM.<?php echo CONST_Tile_Default;?>("Default",
|
||||||
|
{ attribution : '© <a target="_parent" href="http://www.openstreetmap.org">OpenStreetMap</a> and contributors, under an <a target="_parent" href="http://www.openstreetmap.org/copyright">open license</a>'}));
|
||||||
|
|
||||||
|
var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
|
||||||
|
layer_style.fillOpacity = 0.2;
|
||||||
|
layer_style.graphicOpacity = 0.2;
|
||||||
|
|
||||||
|
vectorLayer = new OpenLayers.Layer.Vector("Points", {style: layer_style});
|
||||||
|
map.addLayer(vectorLayer);
|
||||||
|
|
||||||
|
var proj_EPSG4326 = new OpenLayers.Projection("EPSG:4326");
|
||||||
|
var proj_map = map.getProjectionObject();
|
||||||
|
|
||||||
|
freader = new OpenLayers.Format.WKT({
|
||||||
|
'internalProjection': proj_map,
|
||||||
|
'externalProjection': proj_EPSG4326
|
||||||
|
});
|
||||||
|
|
||||||
|
var bounds;
|
||||||
|
<?php if ($aPointDetails['prevgeom']) { ?>
|
||||||
|
var feature = freader.read('<?php echo $aPointDetails['prevgeom'];?>');
|
||||||
|
if (feature) {
|
||||||
|
bounds = feature.geometry.getBounds();
|
||||||
|
|
||||||
|
}
|
||||||
|
feature.style = {
|
||||||
|
strokeColor: "#777777",
|
||||||
|
fillColor: "#F0F0F0",
|
||||||
|
strokeWidth: 2,
|
||||||
|
strokeOpacity: 0.75,
|
||||||
|
fillOpacity: 0.75,
|
||||||
|
strokeDashstyle: "longdash"
|
||||||
|
};
|
||||||
|
vectorLayer.addFeatures([feature]);
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if ($aPointDetails['newgeom']) { ?>
|
||||||
|
feature = freader.read('<?php echo $aPointDetails['newgeom'];?>');
|
||||||
|
if (feature) {
|
||||||
|
if (!bounds) {
|
||||||
|
bounds = feature.geometry.getBounds();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bounds.extend(feature.geometry.getBounds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
feature.style = {
|
||||||
|
strokeColor: "#75ADFF",
|
||||||
|
fillColor: "#FFF7F0",
|
||||||
|
strokeWidth: 2,
|
||||||
|
strokeOpacity: 0.75,
|
||||||
|
fillOpacity: 0.75
|
||||||
|
};
|
||||||
|
vectorLayer.addFeatures([feature]);
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if (isset($aPointDetails['error_x'])) { ?>
|
||||||
|
var pt = new OpenLayers.Geometry.Point(<?php echo $aPointDetails['error_x'].','.$aPointDetails['error_y'];?>);
|
||||||
|
pt = pt.transform(proj_EPSG4326, proj_map);
|
||||||
|
feature = new OpenLayers.Feature.Vector(pt, null,
|
||||||
|
{
|
||||||
|
graphicName : "x",
|
||||||
|
fillColor: "#FF0000",
|
||||||
|
graphic : true,
|
||||||
|
pointRadius: 6
|
||||||
|
});
|
||||||
|
vectorLayer.addFeatures([feature]);
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
|
map.zoomToExtent(bounds);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init();">
|
||||||
|
<div id="map"></div>
|
||||||
|
<h1><?php echo $aPointDetails['localname'] ?></h1>
|
||||||
|
<div class="locationdetails">
|
||||||
|
<div>Type: <span class="type"><?php echo $aPointDetails['class'].':'.$aPointDetails['type'];?></span></div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way': ($aPointDetails['osm_type'] == 'R'?'relation':'')));
|
||||||
|
if ($sOSMType) echo ' <div>OSM: <span class="osm"><span class="label"></span>'.$sOSMType.' <a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aPointDetails['osm_id'].'">'. $aPointDetails['osm_id'].'</a></span></div>';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<p>This object has an invalid geometry.</p>
|
||||||
|
<p><b>Details:</b> <?php echo $aPointDetails['errormessage'];?></p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -216,7 +216,6 @@ CREATE INDEX idx_placex_adminname on placex USING BTREE (make_standard_name(name
|
|||||||
|
|
||||||
DROP SEQUENCE seq_place;
|
DROP SEQUENCE seq_place;
|
||||||
CREATE SEQUENCE seq_place start 1;
|
CREATE SEQUENCE seq_place start 1;
|
||||||
GRANT SELECT on place to "www-data" ;
|
|
||||||
GRANT SELECT on placex to "www-data" ;
|
GRANT SELECT on placex to "www-data" ;
|
||||||
GRANT UPDATE ON placex to "www-data" ;
|
GRANT UPDATE ON placex to "www-data" ;
|
||||||
GRANT SELECT ON search_name 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', 'prevgeometry', 4326, 'GEOMETRY', 2);
|
||||||
SELECT AddGeometryColumn('import_polygon_error', 'newgeometry', 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);
|
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;
|
drop table import_polygon_delete;
|
||||||
CREATE TABLE import_polygon_delete (
|
CREATE TABLE import_polygon_delete (
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
$oDB =& getDB();
|
$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'))
|
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");
|
$_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
|
// Be nice about our error messages for broken geometry
|
||||||
if (!$_GET['place_id'])
|
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");
|
$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($sErrorMessage) && $sErrorMessage) {
|
if (!PEAR::isError($aPointDetails) && $aPointDetails) {
|
||||||
echo "Problem with geometry: ";
|
if (preg_match('/\[(-?\d+\.\d+) (-?\d+\.\d+)\]/', $aPointDetails['errormessage'], $aMatches))
|
||||||
echo $sErrorMessage;
|
{
|
||||||
|
$aPointDetails['error_x'] = $aMatches[1];
|
||||||
|
$aPointDetails['error_y'] = $aMatches[2];
|
||||||
|
}
|
||||||
|
include(CONST_BasePath.'/lib/template/details-error-'.$sOutputFormat.'.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,9 +51,6 @@
|
|||||||
$iParentPlaceID = $oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID);
|
$iParentPlaceID = $oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID);
|
||||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||||
|
|
||||||
$aLangPrefOrder = getPreferredLanguages();
|
|
||||||
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
|
|
||||||
|
|
||||||
$hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
$hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||||
|
|
||||||
// Make sure the point we are reporting on is fully indexed
|
// Make sure the point we are reporting on is fully indexed
|
||||||
|
Loading…
Reference in New Issue
Block a user