/[maps]/web/googlemap.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /web/googlemap.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (show annotations)
Mon Dec 3 19:16:55 2007 UTC (11 years, 5 months ago) by dpavlin
File size: 2098 byte(s)
added onChange JavaScript
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use HTML::GoogleMaps;
7 use CGI;
8 use CGI::Carp qw/fatalsToBrowser/;
9 use File::Find;
10 use Data::Dump qw/dump/;
11
12 use lib '../';
13 use NMEA;
14
15 my $trace_path = '/home/dpavlin/x/openmoko/gps/';
16
17 # http://localhost/
18 my $map_key = 'ABQIAAAAVQ5szt9Jd8ws6vgfVQOEmhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQ1cKf0DwFJcwtpESJEI0hL8QgtYg';
19
20 my @traces;
21 find({ wanted => sub {
22 push @traces, $_ if -f $_;
23 }}, $trace_path);
24
25 my $q = CGI->new;
26
27 print $q->header;
28
29 my $head = '';
30 my $html = join('', qq{
31 <h1>Select GPS NMEA dump</h1>
32 },
33 $q->start_form( -id => 'trace_frm' ),
34 $q->popup_menu(
35 -name => 'trace',
36 -values => [
37 map {
38 "$_ (" . (stat("$trace_path/$_"))[7] . " bytes)"
39 }
40 sort {
41 (stat("$trace_path/$a"))[10] <=> (stat("$trace_path/$b"))[10]
42 } @traces
43 ],
44 -onChange => 'trace_frm.submit()',
45 ),
46 $q->submit( -value => 'Show trace' ),
47 $q->end_form,
48 );
49
50 if ( my $trace = $q->param('trace') ) {
51 $trace =~ s/\s.+$//;
52
53 my $map = HTML::GoogleMaps->new(key => $map_key);
54 #$map->center(point => "Zagreb, Hrvatska");
55
56 $trace = "$trace_path/$trace";
57
58 my $points = 0;
59
60 open(my $fh, '<', $trace) || die "can't open $trace: $!";
61 while( <$fh> ) {
62
63 my $hash = NMEA->line( $_ ) || next;
64
65 $map->add_marker(
66 point => [ $hash->{lon}, $hash->{lat} ],
67 html => join('<br/>',
68 map {
69 ucfirst($_) . ': ' . $hash->{$_}
70 } ( qw/time lat lon speed course/ )
71 ),
72 );
73
74 $points++;
75 }
76 close($fh);
77
78 if ( $points > 0 ) {
79
80 #$map->zoom(10);
81 #$map->v2_zoom(0);
82 $map->controls("large_map_control", "map_type_control");
83 $map->map_type('hybrid');
84
85 my ( $map_div, $map_script );
86 ( $head, $map_div, $map_script ) = $map->render;
87
88 $html .= join('', qq{
89 <h1>Plotting $points points from }, $q->param('trace'), qq{</h1>
90 $map_div
91 $map_script
92 <a href="http://aprs.gids.nl/nmea/">GPS - NMEA sentence information</a>
93 });
94
95 } else {
96 $html .= '<em>No points found for ' . $q->param('trace') . '</em>';
97 }
98
99 }
100
101 print qq{
102 <html>
103 <head>
104 <title>Read GPS - NMEA sentence and display it on GoogleMaps</title>
105 $head
106 </head>
107 <body>
108 $html
109 </body>
110 </html>
111 };

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26