source: subversion/applications/rendering/gpx_slippy_map/view.php @ 30322

Last change on this file since 30322 was 7916, checked in by ojw, 11 years ago

viewer for the binary files

File size: 1.8 KB
Line 
1<?php
2#----------------------------------------------------------------
3# Render a GPX tracklog onto a slippy-map tile
4#
5#------------------------------------------------------
6# Usage:
7#   tile.php?gpx=12345&t=7/8/9
8#  where:
9#   12345 is the ID of the GPX file on openstreetmap.org/traces
10#   7/8/9 is the tile ID (z/x/y)
11#------------------------------------------------------
12# Copyright 2008, Oliver White
13#
14# This program is free software: you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation, either version 3 of the License, or
17# (at your option) any later version.
18#
19# This program is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program.  If not, see <http://www.gnu.org/licenses/>.
26#------------------------------------------------------
27
28include_once("gpx.php");
29header("Content-type:text/plain");
30
31# Load the GPX file
32$GPX = $_GET["gpx"] + 0;
33$Filename = getGpx($GPX);
34
35$Data = getMeta($Filename, 1); // 1 means leave the filepointer open
36print_r($Data);
37 
38if(!$Data['exists'] || !$Data['valid'])
39  {
40  print "Invalid";
41  return;
42  }
43 
44$fp = $Data['fp'];
45 
46$Resolution = 1 / pow(2.0, 31);
47
48print "------------------------------\n";
49# Loop through the points
50for($ii = 0; $ii < $Data['points']; $ii++)
51{
52  # rx,ry are relative to the mercator projection (0-1)
53  list($spare, $rx, $ry) = unpack("N2", fread($fp, 8));
54  $rx *= $Resolution;
55  $ry *= $Resolution;
56 
57  $lat = mercatorToLat(M_PI * (1.0 - 2.0 * $ry));
58  $lon = -180.0 + 360.0 * $rx;
59 
60  printf("%f, %f\n", $lat, $lon);
61}
62
63fclose($fp);
64
65?>
Note: See TracBrowser for help on using the repository browser.