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 |
$q->br, |
$q->br, |
51 |
'Draw ', |
'Draw ', |
52 |
$q->popup_menu( |
$q->popup_menu( |
71 |
-onChange => 'trace_frm.submit()', |
-onChange => 'trace_frm.submit()', |
72 |
), |
), |
73 |
' placemarks', |
' placemarks', |
74 |
$q->end_form, |
$q->br, |
75 |
); |
); |
76 |
|
|
77 |
|
|
102 |
ucfirst($_) . ': ' . $hash->{$_} |
ucfirst($_) . ': ' . $hash->{$_} |
103 |
} ( qw/number time lat lon speed course/ ) |
} ( qw/number time lat lon speed course/ ) |
104 |
), |
), |
105 |
|
%$hash, |
106 |
}; |
}; |
107 |
|
|
108 |
} |
} |
110 |
|
|
111 |
if ( $#points >= 0 ) { |
if ( $#points >= 0 ) { |
112 |
|
|
|
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; |
|
|
|
|
113 |
sub filter_array { |
sub filter_array { |
114 |
my $o = {@_}; |
my $o = {@_}; |
115 |
my ( $count, $filter, $code ) = |
my ( $count, $filter, $code ) = |
160 |
return $code_calls; |
return $code_calls; |
161 |
} |
} |
162 |
|
|
163 |
|
my $map = HTML::GoogleMaps->new( |
164 |
|
key => $map_key, |
165 |
|
width => '800px', |
166 |
|
height => '600px', |
167 |
|
); |
168 |
|
|
169 |
my @poly_points; |
my @poly_points; |
170 |
my $points = filter_array( |
my $points = filter_array( |
171 |
count => $q->param('points_count'), |
count => $q->param('points_count'), |
179 |
|
|
180 |
die "hum?" unless $#poly_points == $points - 1; |
die "hum?" unless $#poly_points == $points - 1; |
181 |
|
|
182 |
$map->add_polyline( points => [ @poly_points ] ) if @poly_points; |
my @filtered_placemarks; |
183 |
|
|
184 |
my $placemarks = filter_array( |
my $placemarks = filter_array( |
185 |
count => $q->param('placemark_count'), |
count => $q->param('placemark_count'), |
187 |
code => sub { |
code => sub { |
188 |
my $placemark = shift; |
my $placemark = shift; |
189 |
$map->add_marker( %$placemark, noformat => 1 ); |
$map->add_marker( %$placemark, noformat => 1 ); |
190 |
|
push @filtered_placemarks, $placemark; |
191 |
}, |
}, |
192 |
array => \@placemarks, |
array => \@placemarks, |
193 |
); |
); |
194 |
|
|
195 |
|
if ( my $export = $q->param('export') ) { |
196 |
|
if ( $export =~ m/KML/i ) { |
197 |
|
print $q->header( |
198 |
|
-type => 'application/vnd.google-earth.kml+xml', |
199 |
|
), |
200 |
|
KML->output( placemarks => \@filtered_placemarks ); |
201 |
|
exit; |
202 |
|
} else { |
203 |
|
die "unknown export format $export"; |
204 |
|
} |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
#$map->center(point => "Zagreb, Hrvatska"); |
209 |
|
|
210 |
|
#$map->zoom(10); |
211 |
|
$map->v2_zoom(20); |
212 |
|
$map->controls("large_map_control", "map_type_control"); |
213 |
|
$map->map_type('hybrid'); |
214 |
|
$map->center( $center_point ) if $q->param('line') && $center_point; |
215 |
|
|
216 |
|
$map->add_polyline( points => [ @poly_points ] ) if @poly_points; |
217 |
|
|
218 |
my ( $map_div, $map_script ); |
my ( $map_div, $map_script ); |
219 |
( $head, $map_div, $map_script ) = $map->render; |
( $head, $map_div, $map_script ) = $map->render; |
220 |
|
|
222 |
$#points + 1, ' points from <tt>', $q->param('trace'), '</tt> showing ', |
$#points + 1, ' points from <tt>', $q->param('trace'), '</tt> showing ', |
223 |
$points ? $points . ' points' . ( $placemarks ? ' and ' : '' ) : '', |
$points ? $points . ' points' . ( $placemarks ? ' and ' : '' ) : '', |
224 |
$placemarks ? $placemarks . ' placemarks' : '', |
$placemarks ? $placemarks . ' placemarks' : '', |
225 |
|
' export to ', |
226 |
|
$q->submit( |
227 |
|
-name => 'export', |
228 |
|
-value => 'KML' |
229 |
|
), |
230 |
qq{ |
qq{ |
231 |
$map_div |
$map_div |
232 |
$map_script |
$map_script |
244 |
$html .= '<em>No points found for ' . $q->param('trace') . '</em>'; |
$html .= '<em>No points found for ' . $q->param('trace') . '</em>'; |
245 |
} |
} |
246 |
|
|
247 |
|
$html .= $q->end_form; |
248 |
} |
} |
249 |
|
|
250 |
|
print $q->header; |
251 |
print qq{ |
print qq{ |
252 |
<html> |
<html> |
253 |
<head> |
<head> |