#!/usr/bin/perl
# programming by Jochen Puchalla (c) 2007-2010
# mail at puchalla dash online dot de
# License: GPL V2
$steigdist=5; # minimum distance for climbing percentage calculation
use GD::Simple;
use File::Copy;
foreach $file (@ARGV)
{
if (! open(INPUT,"<$file") )
{
print STDERR "Can't open input file $file\n";
next;
}
print STDOUT "$file:";
$filecore=$file;
$filecore =~ s/.gpx$//g;
if ($file eq $filecore)
{
print STDERR "$file is not a gpx file\n";
next;
}
# open output file:
$outfile="$filecore-gpx3d.png";
if (! open(OUTPUT,">$filecore-gpx3d.png") ) { print STDERR "Can't open output file $filecore-gpx3d.png\n"; $bad++; next; }
$pi=3.141592;
$yzoom=-1; # flip
$zzoom=0.3; # length of height
$zoom=6000; # picture scale
$picmax=8000; # max. picture size in pixels
# set values to 0 for every new file:
$n=-1;
$count=0;
$maxcount=0;
$h_max=10;
$maxnorth=180;
$maxsouth=-180;
$maxwest=-360;
$maxeast=360;
$sum_h=0;
$sum_t=0;
$kms=0;
$number=1;
while ($line=)
{
if ($line =~ //) {print " found track "; $n=-1;} # start processing
if ($line =~ //) {print " found route "; $n=-1;} # start processing
if ($line =~ /pt\ lat\=/)
{
$n++; # next point
@values = split(/\"/, $line);
$lat[$n]=$values[1];
$lon[$n]=$values[3];
if ($lat[$n] > $maxsouth) {$maxsouth = $lat[$n];}
if ($lat[$n] < $maxnorth) {$maxnorth = $lat[$n];}
if ($lon[$n] < $maxeast) {$maxeast = $lon[$n];}
if ($lon[$n] > $maxwest) {$maxwest = $lon[$n];}
# printf STDOUT "%5.2f %5.2f %5.2f %5.2f %5.2f $n \n" , $values[1], $values[2], $values[3], $values[4], $values[5];
$line=;
$line =~ s/e//g;
$line =~ s/l//g;
$line =~ s//g;
$line =~ s/>//g;
$line =~ s/\///g;
$line =~ s/\ //g;
$h[$n]=$line;
if ($n>0) {$h[$n]=($h[$n]+$h[$n-1]*12)/13;} ######### HÖHENGLÄTTUNG ##########
if ($h[$n] > $h_max) {$h_max=$h[$n];}
if ($h[$n] > $h[$n-1]) {$sum_h=$sum_h+$h[$n]-$h[$n-1];}
# printf STDOUT $line;
# printf STDOUT " h=" . $h[$n] . " lat=" . $lat[$n] . " lon=" . $lon[$n];
# Teilstrecke:
$deltas[$n] = 1000 * sqrt( (($lat[$n]-$lat[$n-1])*$pi*6371/180) * (($lat[$n]-$lat[$n-1])*$pi*6371/180) + (6371*cos($pi/180*$lat[$n])*$pi*($lon[$n]-$lon[$n-1])/180) * (6371*cos($pi/180*$lat[$n])*$pi*($lon[$n]-$lon[$n-1])/180) );
# print " $deltas[$n] $n ";
}
if ($line =~ /