3 require_once(CONST_BasePath.'/lib/init-website.php');
4 require_once(CONST_BasePath.'/lib/log.php');
5 require_once(CONST_BasePath.'/lib/output.php');
6 ini_set('memory_limit', '200M');
8 $oParams = new Nominatim\ParameterParser();
10 $sOutputFormat = 'html';
11 $iDays = $oParams->getInt('days', false);
12 $bReduced = $oParams->getBool('reduced', false);
13 $sClass = $oParams->getString('class', false);
17 $iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
20 while ($iTotalBroken && empty($aPolygons)) {
21 $sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
22 $sSQL .= 'country_code as "country",errormessage as "error message",updated';
23 $sSQL .= ' from import_polygon_error';
27 $aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
31 if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
32 if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
34 if (!empty($aWhere)) {
35 $sSQL .= ' where '.join(' and ', $aWhere);
38 $sSQL .= ' order by updated desc limit 1000';
39 $aPolygons = chksql($oDB->getAll($sSQL));
51 <meta charset="utf-8"/>
52 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
54 <title>Nominatim Broken Polygon Data</title>
56 <meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
61 <style type="text/css">
67 border-collapse: collapse;
68 background-color: white;
76 border-left-color: #ddd;
77 border-right-color: #ddd;
78 background-color: #eee;
79 -moz-border-radius: 0px 0px 0px 0px;
86 border-left-color: #ddd;
87 border-right-color: #ddd;
88 background-color: white;
89 -moz-border-radius: 0px 0px 0px 0px;
95 echo "<p>Total number of broken polygons: $iTotalBroken</p>";
96 if (!$aPolygons) exit;
99 //var_dump($aPolygons[0]);
100 foreach ($aPolygons[0] as $sCol => $sVal) {
101 echo '<th>'.$sCol.'</th>';
103 echo '<th> </th>';
106 foreach ($aPolygons as $aRow) {
107 if (isset($aSeen[$aRow['type'].$aRow['id']])) continue;
108 $aSeen[$aRow['type'].$aRow['id']] = 1;
110 foreach ($aRow as $sCol => $sVal) {
112 case 'error message':
113 if (preg_match('/Self-intersection\\[([0-9.\\-]+) ([0-9.\\-]+)\\]/', $sVal, $aMatch)) {
114 $aRow['lat'] = $aMatch[2];
115 $aRow['lon'] = $aMatch[1];
116 echo '<td><a href="https://www.openstreetmap.org/?lat='.$aMatch[2].'&lon='.$aMatch[1].'&zoom=18&layers=M&'.$sOSMType.'='.$aRow['id'].'">'.($sVal?$sVal:' ').'</a></td>';
118 echo '<td>'.($sVal?$sVal:' ').'</td>';
122 echo '<td>'.osmLink($aRow).'</td>';
125 echo '<td>'.($sVal?$sVal:' ').'</td>';
129 echo '<td><a href="http://localhost:8111/import?url=https://www.openstreetmap.org/api/0.6/'.$sOSMType.'/'.$aRow['id'].'/full" target="josm">josm</a></td>';