12 |
use lib '../lib'; |
use lib '../lib'; |
13 |
use blib; |
use blib; |
14 |
use NMEA; |
use NMEA; |
15 |
|
use KML; |
16 |
|
|
17 |
my $trace_path = '../nmea/'; |
my $trace_path = '../nmea/'; |
18 |
|
|
26 |
|
|
27 |
my $q = CGI->new; |
my $q = CGI->new; |
28 |
|
|
|
print $q->header; |
|
|
|
|
29 |
my $head = ''; |
my $head = ''; |
30 |
my $html = join('', qq{ |
my $html = join('', qq{ |
31 |
<h1>Select GPS NMEA dump</h1> |
<h1>Select GPS NMEA dump</h1> |
43 |
], |
], |
44 |
-onChange => 'trace_frm.submit()', |
-onChange => 'trace_frm.submit()', |
45 |
), |
), |
46 |
$q->submit( -value => 'Show trace' ), |
$q->submit( |
47 |
|
-name => 'show', |
48 |
|
-value => 'Show trace' |
49 |
|
), |
50 |
|
' Export to ', |
51 |
|
$q->submit( |
52 |
|
-name => 'export', |
53 |
|
-value => 'KML' |
54 |
|
), |
55 |
$q->br, |
$q->br, |
56 |
'Draw ', |
'Draw ', |
57 |
$q->popup_menu( |
$q->popup_menu( |
107 |
ucfirst($_) . ': ' . $hash->{$_} |
ucfirst($_) . ': ' . $hash->{$_} |
108 |
} ( qw/number time lat lon speed course/ ) |
} ( qw/number time lat lon speed course/ ) |
109 |
), |
), |
110 |
|
%$hash, |
111 |
}; |
}; |
112 |
|
|
113 |
} |
} |
115 |
|
|
116 |
if ( $#points >= 0 ) { |
if ( $#points >= 0 ) { |
117 |
|
|
|
my $map = HTML::GoogleMaps->new( |
|
|
key => $map_key, |
|
|
width => '800px', |
|
|
height => '600px', |
|
|
); |
|
|
#$map->center(point => "Zagreb, Hrvatska"); |
|
|
|
|
|
#$map->zoom(10); |
|
|
$map->v2_zoom(20); |
|
|
$map->controls("large_map_control", "map_type_control"); |
|
|
$map->map_type('hybrid'); |
|
|
$map->center( $center_point ) if $q->param('line') && $center_point; |
|
|
|
|
118 |
sub filter_array { |
sub filter_array { |
119 |
my $o = {@_}; |
my $o = {@_}; |
120 |
my ( $count, $filter, $code ) = |
my ( $count, $filter, $code ) = |
165 |
return $code_calls; |
return $code_calls; |
166 |
} |
} |
167 |
|
|
168 |
|
my $map = HTML::GoogleMaps->new( |
169 |
|
key => $map_key, |
170 |
|
width => '800px', |
171 |
|
height => '600px', |
172 |
|
); |
173 |
|
|
174 |
my @poly_points; |
my @poly_points; |
175 |
my $points = filter_array( |
my $points = filter_array( |
176 |
count => $q->param('points_count'), |
count => $q->param('points_count'), |
184 |
|
|
185 |
die "hum?" unless $#poly_points == $points - 1; |
die "hum?" unless $#poly_points == $points - 1; |
186 |
|
|
187 |
$map->add_polyline( points => [ @poly_points ] ) if @poly_points; |
my @filtered_placemarks; |
188 |
|
|
189 |
my $placemarks = filter_array( |
my $placemarks = filter_array( |
190 |
count => $q->param('placemark_count'), |
count => $q->param('placemark_count'), |
192 |
code => sub { |
code => sub { |
193 |
my $placemark = shift; |
my $placemark = shift; |
194 |
$map->add_marker( %$placemark, noformat => 1 ); |
$map->add_marker( %$placemark, noformat => 1 ); |
195 |
|
push @filtered_placemarks, $placemark; |
196 |
}, |
}, |
197 |
array => \@placemarks, |
array => \@placemarks, |
198 |
); |
); |
199 |
|
|
200 |
|
if ( my $export = $q->param('export') ) { |
201 |
|
if ( $export eq 'KML' ) { |
202 |
|
print $q->header( |
203 |
|
-type => 'application/xhtml+xml', |
204 |
|
), |
205 |
|
KML->output( placemarks => \@filtered_placemarks ); |
206 |
|
exit; |
207 |
|
} else { |
208 |
|
die "unknown export format $export"; |
209 |
|
} |
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
|
#$map->center(point => "Zagreb, Hrvatska"); |
214 |
|
|
215 |
|
#$map->zoom(10); |
216 |
|
$map->v2_zoom(20); |
217 |
|
$map->controls("large_map_control", "map_type_control"); |
218 |
|
$map->map_type('hybrid'); |
219 |
|
$map->center( $center_point ) if $q->param('line') && $center_point; |
220 |
|
|
221 |
|
$map->add_polyline( points => [ @poly_points ] ) if @poly_points; |
222 |
|
|
223 |
my ( $map_div, $map_script ); |
my ( $map_div, $map_script ); |
224 |
( $head, $map_div, $map_script ) = $map->render; |
( $head, $map_div, $map_script ) = $map->render; |
225 |
|
|
232 |
$map_script |
$map_script |
233 |
<a href="http://aprs.gids.nl/nmea/">GPS - NMEA sentence information</a> |
<a href="http://aprs.gids.nl/nmea/">GPS - NMEA sentence information</a> |
234 |
}); |
}); |
235 |
|
|
236 |
|
my $stats = NMEA->stats; |
237 |
|
$html .= '<table>'; |
238 |
|
foreach my $n ( keys %$stats ) { |
239 |
|
$html .= "<tr><td>$n</td><td>" . $stats->{$n} . "</td></tr>"; |
240 |
|
} |
241 |
|
$html .= '</table>'; |
242 |
|
|
243 |
} else { |
} else { |
244 |
$html .= '<em>No points found for ' . $q->param('trace') . '</em>'; |
$html .= '<em>No points found for ' . $q->param('trace') . '</em>'; |
246 |
|
|
247 |
} |
} |
248 |
|
|
249 |
|
print $q->header; |
250 |
print qq{ |
print qq{ |
251 |
<html> |
<html> |
252 |
<head> |
<head> |