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