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);
 
  15 $oDB = new Nominatim\DB();
 
  18 $iTotalBroken = (int) $oDB->getOne('select count(*) from import_polygon_error');
 
  21 while ($iTotalBroken && empty($aPolygons)) {
 
  22     $sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
 
  23     $sSQL .= 'country_code as "country",errormessage as "error message",updated';
 
  24     $sSQL .= ' from import_polygon_error';
 
  28         $aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
 
  32     if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
 
  33     if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
 
  35     if (!empty($aWhere)) {
 
  36         $sSQL .= ' where '.join(' and ', $aWhere);
 
  39     $sSQL .= ' order by updated desc limit 1000';
 
  40     $aPolygons = $oDB->getAll($sSQL);
 
  52     <meta charset="utf-8"/>
 
  53     <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
 
  55     <title>Nominatim Broken Polygon Data</title>
 
  57     <meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
 
  62 <style type="text/css">
 
  68     border-collapse: collapse;
 
  69     background-color: white;
 
  77     border-left-color: #ddd;
 
  78     border-right-color: #ddd;
 
  79     background-color: #eee;
 
  80     -moz-border-radius: 0px 0px 0px 0px;
 
  87     border-left-color: #ddd;
 
  88     border-right-color: #ddd;
 
  89     background-color: white;
 
  90     -moz-border-radius: 0px 0px 0px 0px;
 
  96 echo "<p>Total number of broken polygons: $iTotalBroken</p>";
 
  97 if (!$aPolygons) exit;
 
 100 //var_dump($aPolygons[0]);
 
 101 foreach ($aPolygons[0] as $sCol => $sVal) {
 
 102     echo '<th>'.$sCol.'</th>';
 
 104 echo '<th> </th>';
 
 107 foreach ($aPolygons as $aRow) {
 
 108     if (isset($aSeen[$aRow['type'].$aRow['id']])) continue;
 
 109     $aSeen[$aRow['type'].$aRow['id']] = 1;
 
 111     foreach ($aRow as $sCol => $sVal) {
 
 113             case 'error message':
 
 114                 if (preg_match('/Self-intersection\\[([0-9.\\-]+) ([0-9.\\-]+)\\]/', $sVal, $aMatch)) {
 
 115                     $aRow['lat'] = $aMatch[2];
 
 116                     $aRow['lon'] = $aMatch[1];
 
 117                     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>';
 
 119                     echo '<td>'.($sVal?$sVal:' ').'</td>';
 
 123                 echo '<td>'.osmLink($aRow).'</td>';
 
 126                 echo '<td>'.($sVal?$sVal:' ').'</td>';
 
 130     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>';