]> git.openstreetmap.org Git - nominatim.git/blob - website/polygons.php
update paths in vagrant docs
[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) chksql($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 = chksql($oDB->getAll($sSQL));
30         }
31
32         if (CONST_Debug)
33         {
34                 var_dump($aPolygons);
35                 exit;
36         }
37 ?>
38 <!DOCTYPE html>
39 <html>
40 <head>
41         <meta charset="utf-8"/>
42         <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
43         
44         <title>Nominatim Broken Polygon Data</title>
45         
46         <meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
47
48 </head>
49
50 <body>
51 <style type="text/css">
52 table {
53         border-width: 1px;
54         border-spacing: 0px;
55         border-style: solid;
56         border-color: gray;
57         border-collapse: collapse;
58         background-color: white;
59         margin: 10px;
60 }
61 table th {
62         border-width: 1px;
63         padding: 2px;
64         border-style: inset;
65         border-color: gray;
66         border-left-color: #ddd;
67         border-right-color: #ddd;
68         background-color: #eee;
69         -moz-border-radius: 0px 0px 0px 0px;
70 }
71 table td {
72         border-width: 1px;
73         padding: 2px;
74         border-style: inset;
75         border-color: gray;
76         border-left-color: #ddd;
77         border-right-color: #ddd;
78         background-color: white;
79         -moz-border-radius: 0px 0px 0px 0px;
80 }
81 </style>
82
83 <?php
84
85         echo "<p>Total number of broken polygons: $iTotalBroken</p>";
86         if (!$aPolygons) exit;
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                                 echo '<td>'.osmLink($aRow).'</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 </body>
141 </html>