3 require_once(CONST_LibDir.'/init-website.php');
4 require_once(CONST_LibDir.'/log.php');
5 require_once(CONST_LibDir.'/output.php');
6 ini_set('memory_limit', '200M');
8 $oParams = new Nominatim\ParameterParser();
9 $sOutputFormat = $oParams->getSet('format', array('json'), 'json');
10 set_exception_handler_by_format($sOutputFormat);
12 $iDays = $oParams->getInt('days', false);
13 $bReduced = $oParams->getBool('reduced', false);
14 $sClass = $oParams->getString('class', false);
16 $oDB = new Nominatim\DB(CONST_Database_DSN);
19 $iTotalBroken = (int) $oDB->getOne('SELECT count(*) FROM import_polygon_error');
22 while ($iTotalBroken && empty($aPolygons)) {
23 $sSQL = 'SELECT osm_type, osm_id, class, type, name->\'name\' as "name",';
24 $sSQL .= 'country_code, errormessage, updated';
25 $sSQL .= ' FROM import_polygon_error';
29 $aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
34 $aWhere[] = "errormessage like 'Area reduced%'";
37 $sWhere[] = "class = '".pg_escape_string($sClass)."'";
40 if (!empty($aWhere)) {
41 $sSQL .= ' WHERE '.join(' and ', $aWhere);
44 $sSQL .= ' ORDER BY updated desc LIMIT 1000';
45 $aPolygons = $oDB->getAll($sSQL);
53 if ($sOutputFormat == 'json') {
54 javascript_renderData($aPolygons);