]> git.openstreetmap.org Git - nominatim.git/blob - website/polygons.php
README: tiny markdown syntax error
[nominatim.git] / website / polygons.php
1 <?php
2
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');
7
8 $oParams = new Nominatim\ParameterParser();
9
10 $sOutputFormat = 'html';
11 $iDays = $oParams->getInt('days', false);
12 $bReduced = $oParams->getBool('reduced', false);
13 $sClass = $oParams->getString('class', false);
14
15 $oDB =& getDB();
16
17 $iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
18
19 $aPolygons = array();
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';
24
25     $aWhere = array();
26     if ($iDays) {
27         $aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
28         $iDays++;
29     }
30
31     if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
32     if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
33
34     if (!empty($aWhere)) {
35         $sSQL .= ' where '.join(' and ', $aWhere);
36     }
37
38     $sSQL .= ' order by updated desc limit 1000';
39     $aPolygons = chksql($oDB->getAll($sSQL));
40 }
41
42 if (CONST_Debug) {
43     var_dump($aPolygons);
44     exit;
45 }
46
47 ?>
48 <!DOCTYPE html>
49 <html>
50 <head>
51     <meta charset="utf-8"/>
52     <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
53     
54     <title>Nominatim Broken Polygon Data</title>
55     
56     <meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
57
58 </head>
59
60 <body>
61 <style type="text/css">
62 table {
63     border-width: 1px;
64     border-spacing: 0px;
65     border-style: solid;
66     border-color: gray;
67     border-collapse: collapse;
68     background-color: white;
69     margin: 10px;
70 }
71 table th {
72     border-width: 1px;
73     padding: 2px;
74     border-style: inset;
75     border-color: gray;
76     border-left-color: #ddd;
77     border-right-color: #ddd;
78     background-color: #eee;
79     -moz-border-radius: 0px 0px 0px 0px;
80 }
81 table td {
82     border-width: 1px;
83     padding: 2px;
84     border-style: inset;
85     border-color: gray;
86     border-left-color: #ddd;
87     border-right-color: #ddd;
88     background-color: white;
89     -moz-border-radius: 0px 0px 0px 0px;
90 }
91 </style>
92
93 <?php
94
95 echo "<p>Total number of broken polygons: $iTotalBroken</p>";
96 if (!$aPolygons) exit;
97 echo '<table>';
98 echo '<tr>';
99 //var_dump($aPolygons[0]);
100 foreach ($aPolygons[0] as $sCol => $sVal) {
101     echo '<th>'.$sCol.'</th>';
102 }
103 echo '<th>&nbsp;</th>';
104 echo '</tr>';
105 $aSeen = array();
106 foreach ($aPolygons as $aRow) {
107     if (isset($aSeen[$aRow['type'].$aRow['id']])) continue;
108     $aSeen[$aRow['type'].$aRow['id']] = 1;
109     echo '<tr>';
110     foreach ($aRow as $sCol => $sVal) {
111         switch ($sCol) {
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:'&nbsp;').'</a></td>';
117                 } else {
118                     echo '<td>'.($sVal?$sVal:'&nbsp;').'</td>';
119                 }
120                 break;
121             case 'id':
122                 echo '<td>'.osmLink($aRow).'</td>';
123                 break;
124             default:
125                 echo '<td>'.($sVal?$sVal:'&nbsp;').'</td>';
126                 break;
127         }
128     }
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>';
130     echo '</tr>';
131 }
132 echo '</table>';
133
134 ?>
135 </body>
136 </html>