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