2012-03-04 13:54:07 +04:00
|
|
|
<?php
|
|
|
|
|
2016-09-14 04:16:46 +03:00
|
|
|
require_once(CONST_BasePath.'/lib/init-website.php');
|
|
|
|
require_once(CONST_BasePath.'/lib/log.php');
|
|
|
|
require_once(CONST_BasePath.'/lib/output.php');
|
|
|
|
ini_set('memory_limit', '200M');
|
2016-06-12 00:07:06 +03:00
|
|
|
|
2016-09-16 03:27:36 +03:00
|
|
|
$oParams = new Nominatim\ParameterParser();
|
2020-10-27 13:05:03 +03:00
|
|
|
$sOutputFormat = $oParams->getSet('format', array('json'), 'json');
|
2020-04-10 04:21:52 +03:00
|
|
|
set_exception_handler_by_format($sOutputFormat);
|
2016-07-31 22:04:33 +03:00
|
|
|
|
2017-12-17 19:29:08 +03:00
|
|
|
$iDays = $oParams->getInt('days', false);
|
2016-09-14 04:16:46 +03:00
|
|
|
$bReduced = $oParams->getBool('reduced', false);
|
|
|
|
$sClass = $oParams->getString('class', false);
|
2012-03-04 13:54:07 +04:00
|
|
|
|
2019-02-24 18:14:36 +03:00
|
|
|
$oDB = new Nominatim\DB();
|
|
|
|
$oDB->connect();
|
2016-06-11 00:58:50 +03:00
|
|
|
|
2020-04-10 04:21:52 +03:00
|
|
|
$iTotalBroken = (int) $oDB->getOne('SELECT count(*) FROM import_polygon_error');
|
2016-06-12 00:07:06 +03:00
|
|
|
|
2016-09-14 04:16:46 +03:00
|
|
|
$aPolygons = array();
|
2018-03-22 14:36:24 +03:00
|
|
|
while ($iTotalBroken && empty($aPolygons)) {
|
2020-04-10 04:21:52 +03:00
|
|
|
$sSQL = 'SELECT osm_type, osm_id, class, type, name->\'name\' as "name",';
|
|
|
|
$sSQL .= 'country_code, errormessage, updated';
|
|
|
|
$sSQL .= ' FROM import_polygon_error';
|
2016-09-14 04:16:46 +03:00
|
|
|
|
2017-12-17 19:29:08 +03:00
|
|
|
$aWhere = array();
|
|
|
|
if ($iDays) {
|
|
|
|
$aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
|
|
|
|
$iDays++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
|
|
|
|
if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
|
|
|
|
|
2018-03-22 14:36:24 +03:00
|
|
|
if (!empty($aWhere)) {
|
2020-04-10 04:21:52 +03:00
|
|
|
$sSQL .= ' WHERE '.join(' and ', $aWhere);
|
2017-12-17 19:29:08 +03:00
|
|
|
}
|
|
|
|
|
2020-04-10 04:21:52 +03:00
|
|
|
$sSQL .= ' ORDER BY updated desc LIMIT 1000';
|
2019-03-10 17:42:58 +03:00
|
|
|
$aPolygons = $oDB->getAll($sSQL);
|
2016-09-14 04:16:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (CONST_Debug) {
|
|
|
|
var_dump($aPolygons);
|
|
|
|
exit;
|
|
|
|
}
|
2016-06-12 15:34:57 +03:00
|
|
|
|
2020-04-10 04:21:52 +03:00
|
|
|
if ($sOutputFormat == 'json') {
|
2020-10-27 13:05:03 +03:00
|
|
|
javascript_renderData($aPolygons);
|
2012-03-04 13:54:07 +04:00
|
|
|
}
|