2         require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
 
   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');
 
  10         $sOutputFormat = 'html';
 
  11         $iDays = getParamInt('days', 1);
 
  12         $bReduced = getParamBool('reduced', false);
 
  13         $sClass = getParamString('class', false);
 
  15         $iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
 
  18         while($iTotalBroken && !sizeof($aPolygons))
 
  20                 $sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
 
  21                 $sSQL .= 'country_code as "country",errormessage as "error message",updated';
 
  22                 $sSQL .= " from import_polygon_error";
 
  23                 $sSQL .= " where updated > 'now'::timestamp - '".$iDays." day'::interval";
 
  26                 if ($bReduced) $sSQL .= " and errormessage like 'Area reduced%'";
 
  27                 if ($sClass) $sSQL .= " and class = '".pg_escape_string($sClass)."'";
 
  28                 $sSQL .= " order by updated desc limit 1000";
 
  29                 $aPolygons = chksql($oDB->getAll($sSQL));
 
  41         <meta charset="utf-8"/>
 
  42         <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
 
  44         <title>Nominatim Broken Polygon Data</title>
 
  46         <meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
 
  51 <style type="text/css">
 
  57         border-collapse: collapse;
 
  58         background-color: white;
 
  66         border-left-color: #ddd;
 
  67         border-right-color: #ddd;
 
  68         background-color: #eee;
 
  69         -moz-border-radius: 0px 0px 0px 0px;
 
  76         border-left-color: #ddd;
 
  77         border-right-color: #ddd;
 
  78         background-color: white;
 
  79         -moz-border-radius: 0px 0px 0px 0px;
 
  85         echo "<p>Total number of broken polygons: $iTotalBroken</p>";
 
  86         if (!$aPolygons) exit;
 
  89 //var_dump($aPolygons[0]);
 
  90         foreach($aPolygons[0] as $sCol => $sVal)
 
  92                 echo "<th>".$sCol."</th>";
 
  94         echo "<th> </th>";
 
  95         echo "<th> </th>";
 
  98         foreach($aPolygons as $aRow)
 
 100                 if (isset($aSeen[$aRow['type'].$aRow['id']])) continue;
 
 101                 $aSeen[$aRow['type'].$aRow['id']] = 1;
 
 103                 foreach($aRow as $sCol => $sVal)
 
 107                         case 'error message':
 
 108                                 if (preg_match('/Self-intersection\\[([0-9.\\-]+) ([0-9.\\-]+)\\]/',$sVal,$aMatch))
 
 110                                         $aRow['lat'] = $aMatch[2];
 
 111                                         $aRow['lon'] = $aMatch[1];
 
 112                                         echo "<td><a href=\"http://www.openstreetmap.org/?lat=".$aMatch[2]."&lon=".$aMatch[1]."&zoom=18&layers=M&".$sOSMType."=".$aRow['id']."\">".($sVal?$sVal:' ')."</a></td>";
 
 116                                         echo "<td>".($sVal?$sVal:' ')."</td>";
 
 120                                 echo '<td>'.osmLink($aRow).'</td>';
 
 123                                 echo "<td>".($sVal?$sVal:' ')."</td>";
 
 127                 echo "<td><a href=\"http://localhost:8111/import?url=http://www.openstreetmap.org/api/0.6/".$sOSMType.'/'.$aRow['id']."/full\" target=\"josm\">josm</a></td>";
 
 128                 if (isset($aRow['lat']))
 
 130                         echo "<td><a href=\"http://open.mapquestapi.com/dataedit/index_flash.html?lat=".$aRow['lat']."&lon=".$aRow['lon']."&zoom=18\" target=\"potlatch2\">P2</a></td>";
 
 134                         echo "<td> </td>";