]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/files/default/cgi/HEADER.cgi
Mention and link to the full history planet files.
[chef.git] / cookbooks / planet / files / default / cgi / HEADER.cgi
1 #!/usr/bin/env python
2
3 from time import time
4 from os import stat, environ
5 from re import search
6
7 def nice_size(file):
8     size = stat(file).st_size
9     KB = 1024.
10     MB = 1024. * KB
11     GB = 1024. * MB
12     TB = 1024. * GB
13     
14     if size < KB:
15         size, suffix = size, ''
16     elif size < MB:
17         size, suffix = size/KB, 'KB'
18     elif size < GB:
19         size, suffix = size/MB, 'MB'
20     elif size < TB:
21         size, suffix = size/GB, 'GB'
22     else:
23         size, suffix = size/TB, 'TB'
24     
25     if size < 10:
26         return '%.1f %s' % (round(size,1), suffix)
27     else:
28         return '%d %s' % (round(size), suffix)
29
30 def nice_time(time):
31     if time < 15:
32         return 'moments'
33     if time < 90:
34         return '%d seconds' % time
35     if time < 60 * 60 * 1.5:
36         return '%d minutes' % (time / 60.)
37     if time < 24 * 60 * 60 * 1.5:
38         return '%d hours' % (time / 3600.)
39     if time < 7 * 24 * 60 * 60 * 1.5:
40         return '%d days' % (time / 86400.)
41     if time < 30 * 24 * 60 * 60 * 1.5:
42         return '%d weeks' % (time / 604800.)
43
44     return '%d months' % (time / 2592000.)
45
46 def file_info(file, name):
47     size = nice_size(file)
48     hash = search(r'\w{32}', open(file+'.md5', 'r').read()).group(0)
49     date = nice_time(time() - stat(file).st_mtime)
50
51     return '<b><a href="%(file)s">%(name)s</a></b><br><b>%(size)s</b>, created %(date)s ago.<br><small>md5: %(hash)s</small>.' % locals()
52
53 planet_link = file_info('planet/planet-latest.osm.bz2', 'Latest Weekly Planet File')
54 changesets_link = file_info('planet/changesets-latest.osm.bz2', 'Latest Weekly Changesets')
55
56 print """
57 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
58 <html>
59  <head>
60   <title>Index of /</title>
61   <link href="style.css" rel="stylesheet" type="text/css">
62  </head>
63  <body>
64 <img id="logo" src="logo.png" alt="OSM logo" width="128" height="128">
65 <h1>Planet OSM</h1>
66
67 <p>
68 The files found here are regularly-updated, complete copies of the OpenStreetMap.org
69 database, and those published before the 12 September 2012 are distributed under a Creative Commons Attribution-ShareAlike 2.0 license, those published after are  Open Data Commons Open Database License 1.0 licensed. For more information, <a href="http://wiki.openstreetmap.org/wiki/Planet.osm">see the project wiki</a>.
70 </p>
71
72 <table id="about">
73   <tr>
74     <th>
75         <h2>Complete OSM Data</h2>
76     </th>
77     <th>
78         <h2>Using The Data</h2>
79     </th>
80     <th>
81         <h2>Extracts &amp; Mirrors</h2>
82     </th>
83   </tr>
84   <tr>
85     <td>
86         <p>%(planet_link)s</p>
87         <p>%(changesets_link)s</p>
88         <p>
89         Each week, a new and complete copy of all data in OpenStreetMap is made
90         available as both a compressed XML file and a custom PBF format file.
91         Also available is the <a href="planet/full-history">'history'</a> file
92         which contains not only up-to-date data but also older versions of data
93         and deleted data items.
94         <p>
95         </p>
96         A smaller file with complete metadata for all changes ('changesets') in
97         XML format is also available.
98         </p>
99     </td>
100     <td>
101         <p>
102         You are granted permission to use OpenStreetMap data by 
103         <a href="http://osm.org/copyright">the OpenStreetMap License</a>, which also describes 
104         your obligations.
105         </p>
106         <p>
107         You can <a href="http://wiki.openstreetmap.org/wiki/Planet.osm#Processing_the_File">process the file</a>
108         or extracts with a variety of tools. <a href="http://wiki.openstreetmap.org/wiki/Osmosis">Osmosis</a>
109         is a general-purpose command-line tool for converting the data among different formats
110         and databases, and <a href="http://wiki.openstreetmap.org/wiki/Osm2pgsql">Osm2pgsql</a>
111         is a tool for importing the data into a Postgis database for rendering maps.
112         </p>
113         <p>
114         <a href="http://wiki.openstreetmap.org/wiki/Coastline_error_checker">Processed coastline data</a>
115         derived from OSM data is also needed for rendering usable maps, and can be found in a
116         <a href="historical-shapefiles/processed_p.tar.bz2">single shapefile</a> (360MB).
117         </p>
118     </td>
119     <td>
120         <p>
121         The complete planet is very large, so you may prefer to use one of
122         <a href="http://wiki.openstreetmap.org/wiki/Planet.osm#Downloading">several periodic extracts</a>
123         (individual countries or states) from third parties. <a href="http://download.geofabrik.de/openstreetmap/">GeoFabrik.de</a>
124         and <a href="http://download.bbbike.org/osm/">BBBike.org</a> are two providers
125         of extracts with up-to-date worldwide coverage.
126         </p>
127     </td>
128   </tr>
129 </table>
130
131 <p>
132 If you find data within OpenStreetMap that you believe is an infringement of someone else's copyright, then please make contact with the <a href="http://wiki.openstreetmap.org/wiki/Data_working_group">OpenStreetMap Data Working Group</a>.
133 </p>
134 """ % locals()