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