]> git.openstreetmap.org Git - nominatim.git/blob - website/polygons.php
92dbf70daaef82f0c5e63035564b05942363ac81
[nominatim.git] / website / polygons.php
1 <?php
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         ini_set('memory_limit', '200M');
6
7         $oDB =& getDB();
8
9         $sOutputFormat = 'html';
10         $iDays = getParamInt('days', 1);
11         $bReduced = getParamBool('reduced', false);
12         $sClass = getParamString('class', false);
13
14         $iTotalBroken = (int) $oDB->getOne('select count(*) from import_polygon_error');
15
16         $aPolygons = array();
17         while($iTotalBroken && !sizeof($aPolygons))
18         {
19                 $sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
20                 $sSQL .= 'country_code as "country",errormessage as "error message",updated';
21                 $sSQL .= " from import_polygon_error";
22                 $sSQL .= " where updated > 'now'::timestamp - '".$iDays." day'::interval";
23                 $iDays++;
24
25                 if ($bReduced) $sSQL .= " and errormessage like 'Area reduced%'";
26                 if ($sClass) $sSQL .= " and class = '".pg_escape_string($sClass)."'";
27                 $sSQL .= " order by updated desc limit 1000";
28                 $aPolygons = $oDB->getAll($sSQL);
29         }
30 //var_dump($aPolygons);
31 ?>
32 <!DOCTYPE html>
33 <html>
34 <head>
35         <meta charset="utf-8"/>
36         <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
37         
38         <title>Nominatim Broken Polygon Data</title>
39         
40         <meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
41
42 </head>
43
44 <body>
45 <style type="text/css">
46 table {
47         border-width: 1px;
48         border-spacing: 0px;
49         border-style: solid;
50         border-color: gray;
51         border-collapse: collapse;
52         background-color: white;
53         margin: 10px;
54 }
55 table th {
56         border-width: 1px;
57         padding: 2px;
58         border-style: inset;
59         border-color: gray;
60         border-left-color: #ddd;
61         border-right-color: #ddd;
62         background-color: #eee;
63         -moz-border-radius: 0px 0px 0px 0px;
64 }
65 table td {
66         border-width: 1px;
67         padding: 2px;
68         border-style: inset;
69         border-color: gray;
70         border-left-color: #ddd;
71         border-right-color: #ddd;
72         background-color: white;
73         -moz-border-radius: 0px 0px 0px 0px;
74 }
75 </style>
76
77 <?php
78
79         echo "<p>Total number of broken polygons: $iTotalBroken</p>";
80         echo "<table>";
81         echo "<tr>";
82 //var_dump($aPolygons[0]);
83         foreach($aPolygons[0] as $sCol => $sVal)
84         {
85                 echo "<th>".$sCol."</th>";
86         }
87         echo "<th>&nbsp;</th>";
88         echo "<th>&nbsp;</th>";
89         echo "</tr>";
90         $aSeen = array();
91         foreach($aPolygons as $aRow)
92         {
93                 if (isset($aSeen[$aRow['type'].$aRow['id']])) continue;
94                 $aSeen[$aRow['type'].$aRow['id']] = 1;
95                 echo "<tr>";
96                 foreach($aRow as $sCol => $sVal)
97                 {
98                         switch($sCol)
99                         {
100                         case 'error message':
101                                 if (preg_match('/Self-intersection\\[([0-9.\\-]+) ([0-9.\\-]+)\\]/',$sVal,$aMatch))
102                                 {
103                                         $aRow['lat'] = $aMatch[2];
104                                         $aRow['lon'] = $aMatch[1];
105                                         echo "<td><a href=\"http://www.openstreetmap.org/?lat=".$aMatch[2]."&lon=".$aMatch[1]."&zoom=18&layers=M&".$sOSMType."=".$aRow['id']."\">".($sVal?$sVal:'&nbsp;')."</a></td>";
106                                 }
107                                 else
108                                 {
109                                         echo "<td>".($sVal?$sVal:'&nbsp;')."</td>";
110                                 }
111                                 break;
112                         case 'id':
113                                 $sOSMType = ($aRow['type'] == 'N'?'node':($aRow['type'] == 'W'?'way':($aRow['type'] == 'R'?'relation':'')));
114                                 echo '<td><a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aRow['id'].'" target="_new">'.$aRow['id'].'</a></td>';
115                                 break;
116                         default:
117                                 echo "<td>".($sVal?$sVal:'&nbsp;')."</td>";
118                                 break;
119                         }
120                 }
121                 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>";
122                 if (isset($aRow['lat']))
123                 {
124                         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>";
125                 }
126                 else
127                 {
128                         echo "<td>&nbsp;</td>"; 
129                 }
130                 echo "</tr>";
131         }
132         echo "</table>";
133
134
135
136 //      include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
137 ?>
138 </body>
139 </html>