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