From: Brian E. L. <br...@us...> - 2004-08-22 22:19:40
|
Update of /cvsroot/rideplot/rideplot/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22230 Modified Files: rideplot Log Message: Generates image with dots where photos were taken using --photo_dir option. I haven't documented this option yet. Some hard coded values exist for timestamp and some adjustment needed on image for dots. Index: rideplot =================================================================== RCS file: /cvsroot/rideplot/rideplot/src/rideplot,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** rideplot 21 Aug 2004 08:17:07 -0000 1.6 --- rideplot 22 Aug 2004 22:19:27 -0000 1.7 *************** *** 60,64 **** use strict; use vars qw( $debug $deg $pi $km_per_mile $nonmetric $dist_m $x_scale $y_scale ! $image $max_x $max_y $white $black $dot_brush $dot_fg $dot_bg $scale @data $avg_lat $lat_scale $maxlat $minlat $maxlon $minlon $point $mb_scale $mid_lat $mid_lon $data_format $img_x $img_y $londist $latdist $map_url $map_file $map_get --- 60,64 ---- use strict; use vars qw( $debug $deg $pi $km_per_mile $nonmetric $dist_m $x_scale $y_scale ! $image $max_x $max_y $white $black $blue $dot_brush $dot_fg $dot_bg $scale @data $avg_lat $lat_scale $maxlat $minlat $maxlon $minlon $point $mb_scale $mid_lat $mid_lon $data_format $img_x $img_y $londist $latdist $map_url $map_file $map_get *************** *** 253,256 **** --- 253,257 ---- # Photos have local timestamp. Change them to have GMT time + # This is hard coded at the moment # The "-2" is the skew for the digital camera. *************** *** 259,263 **** my $photo_timestr = sprintf ("%04d/%02d/%02d %02d:%02d:%02d" ,$ntime[0],$ntime[1],$ntime[2],$ntime[3],$ntime[4],$ntime[5]); ! $debug && print "$file |",$photo_timestr, "|\n"; push @photos_tmp, [$photo_timestr , $file]; } --- 260,264 ---- my $photo_timestr = sprintf ("%04d/%02d/%02d %02d:%02d:%02d" ,$ntime[0],$ntime[1],$ntime[2],$ntime[3],$ntime[4],$ntime[5]); ! $debug && print STDERR "$file |",$photo_timestr, "|\n"; push @photos_tmp, [$photo_timestr , $file]; } *************** *** 266,269 **** --- 267,341 ---- } + # Syncronizes photos based upon prevtime and current timestr + sub sync_photos + { + my ($prevtime, $timestr, $prevlat, $prevlon, $lat, $lon) = @_; + # This subroutine is accessing global variables. And doesn't return anything. Should modularize this + + my $continue = 1; + + $debug && print STDERR "Continue: $continue. photo_idx $photo_idx \n"; + + while ( $photo_idx < $#photos && $continue == 1 ) + { + + my $time_photo = ${$photos[$photo_idx]}[0]; + my $photo_name = ${$photos[$photo_idx]}[1]; + + $debug && print STDERR "Prevtime: ", $prevtime ,"\n"; + $debug && print STDERR "Photo timestamp: ", $time_photo ,"\n"; + $debug && print STDERR "Timestr: ", $timestr ,"\n"; + + + + if ( $time_photo ge $prevtime && $time_photo lt $timestr ) + { + # We have a photo taken during tracklog collection. + + + # Interpolate the lat and lon for this photo based upon time + # prevtime, timestr, photo_time, prevlat, prevlon, lat, lon + my ($interplat, $interplon) = interpolate( $prevtime, $timestr, + ${$photos[$photo_idx]}[0], + $prevlat, $prevlon, + $lat, $lon); + push @mapped_photos, [ $interplat, $interplon, $photo_name ]; + + $photo_idx++; + + } + elsif ( $time_photo lt $prevtime ) + { + $photo_idx++; + + } + elsif ( $time_photo gt $timestr ) + { + $continue = 0; + } + else + { + $continue = 0; + } + + + $debug && print STDERR "Incremented on photo_idx: $photo_idx. Total: $#photos\n"; + + } + return; + } + + sub get_map + { + my $ua = LWP::UserAgent->new; + #$ua->agent('Mozilla/5.0'); # Set the user-agent. May not be needed. + $ua->env_proxy(); # Set Proxy settings from enviornment HTTP_PROXY or CGI_HTTP_PROXY + + print STDERR "Getting background map ..."; + my $request = HTTP::Request->new('GET', $map_url ); + my $response = $ua->request($request, $map_get ); + print STDERR " Done.\n"; + } + # initialize constants $pi = 4.0 * atan(1); *************** *** 542,595 **** if ( $#photos > 0 && $photo_idx < $#photos ) { ! my $continue = 1; ! ! $debug && print STDERR "Continue: $continue. photo_idx $photo_idx \n"; ! ! while ( $photo_idx < $#photos && $continue == 1 ) ! { ! ! my $time_photo = ${$photos[$photo_idx]}[0]; ! my $photo_name = ${$photos[$photo_idx]}[1]; ! ! $debug && print STDERR "Prevtime: ", $prevtime ,"\n"; ! $debug && print STDERR "Photo timestamp: ", $time_photo ,"\n"; ! $debug && print STDERR "Timestr: ", $timestr ,"\n"; ! ! ! ! if ( $time_photo ge $prevtime && $time_photo lt $timestr ) ! { ! # We have a photo taken during tracklog collection. ! ! ! # Interpolate the lat and lon for this photo based upon time ! # prevtime, timestr, photo_time, prevlat, prevlon, lat, lon ! my ($interplat, $interplon) = interpolate( $prevtime, $timestr, ! ${$photos[$photo_idx]}[0], ! $prevlat, $prevlon, ! $lat, $lon); ! push @mapped_photos, [ $interplat, $interplon, $photo_name ]; ! ! $photo_idx++; ! ! } ! elsif ( $time_photo lt $prevtime ) ! { ! $photo_idx++; ! ! } ! elsif ( $time_photo gt $timestr ) ! { ! $continue = 0; ! } ! else ! { ! $continue = 0; ! } ! ! ! $debug && print STDERR "Incremented on photo_idx: $photo_idx. Total: $#photos\n"; ! ! } } --- 614,618 ---- if ( $#photos > 0 && $photo_idx < $#photos ) { ! sync_photos($prevtime, $timestr, $prevlat, $prevlon, $lat, $lon); } *************** *** 677,680 **** --- 700,704 ---- die "$0: no travel at all in longitude - unable to scale\n"; } + # Get Center of map coords Needed for background map $mid_lat = ($maxlat + $minlat) / 2 ; *************** *** 695,699 **** # allocate the image and colors ! # I added 10 for picture dots $image = new GD::Image($max_x+$brush_width*2+2 , $max_y+$brush_width*2+2 ); # Store Image dimensions --- 719,723 ---- # allocate the image and colors ! $image = new GD::Image($max_x+$brush_width*2+2 , $max_y+$brush_width*2+2 ); # Store Image dimensions *************** *** 703,706 **** --- 727,731 ---- $white = $image->colorAllocate(255,255,255); # background $black = $image->colorAllocate(0,0,0); + $blue = $image->colorAllocate(0,0,255); $image->transparent($white); # Make white the transparent color *************** *** 810,823 **** { ! foreach (@mapped_photos) { $debug && print STDERR "Mapped photos\n"; ! $debug && print STDERR Dumper ( $_ ); # plot circle for each photo # The circlue is blue and is ten pixels in diameter for now. ! # my $blue = $image->colorAllocate(0,0,255); ! # $image->arc( ll2xy(@{$_}[0..1]) ,10,10,0,360,$blue); ! # $image->fill( ll2xy(@{$_}[0..1]) ,$blue); } --- 835,851 ---- { ! my $mapped_photo; ! foreach $mapped_photo (@mapped_photos) { $debug && print STDERR "Mapped photos\n"; ! $debug && print STDERR Dumper ( $mapped_photo ); ! my @rec_coords = ll2xy( @{$mapped_photo}[0..1], $maxlat, $minlat, $maxlon, $minlon, $max_x, $max_y ); ! $debug && print STDERR "Rec Coords are: ", join (" ",@rec_coords) , "\n"; # plot circle for each photo # The circlue is blue and is ten pixels in diameter for now. ! ! $image->arc( @rec_coords[0..1] ,6,6,0,360,$blue); ! $image->fill( @rec_coords[0..1] ,$blue); } *************** *** 941,955 **** #### - sub get_map - { - my $ua = LWP::UserAgent->new; - #$ua->agent('Mozilla/5.0'); # Set the user-agent. May not be needed. - $ua->env_proxy(); # Set Proxy settings from enviornment HTTP_PROXY or CGI_HTTP_PROXY - print STDERR "Getting background map ..."; - my $request = HTTP::Request->new('GET', $map_url ); - my $response = $ua->request($request, $map_get ); - print STDERR " Done.\n"; - } --- 969,973 ---- |