source: subversion/applications/editors/osmpedit/trackcollection.pm @ 34678

Last change on this file since 34678 was 734, checked in by tpersson, 14 years ago

Initial commit of osmpedit

File size: 1.7 KB
Line 
1#    Copyright (C) 2005 Tommy Persson, tpe@ida.liu.se
2#
3#    This program is free software; you can redistribute it and/or modify
4#    it under the terms of the GNU General Public License as published by
5#    the Free Software Foundation; either version 2 of the License, or
6#    (at your option) any later version.
7#
8#    This program is distributed in the hope that it will be useful,
9#    but WITHOUT ANY WARRANTY; without even the implied warranty of
10#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11#    GNU General Public License for more details.
12#
13#    You should have received a copy of the GNU General Public License
14#    along with this program; if not, write to the Free Software
15#    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
16
17package trackcollection;
18
19use FindBin qw($RealBin);
20use lib "$RealBin/../perl";
21
22use track;
23
24use strict;
25
26sub new {
27    my $this = shift;
28    my $class = ref($this) || $this;
29    bless {
30        TRACKS => [],
31        HIDDEN => 0,
32        @_
33        }, $class;
34}
35
36sub add_track {
37    my $self = shift;
38    my $t = shift;
39    push @{$self->{TRACKS}}, $t;
40}
41
42sub get_tracks {
43    my $self = shift;
44    return @{$self->{TRACKS}};
45}
46
47sub get_n_tracks () {
48    my $self = shift;
49    return $#{$self->{TRACKS}}+1;
50}
51
52sub get_center {
53    my $self = shift;
54    my $n = 0;
55    my $lat = 0;
56    my $lon = 0;
57    foreach my $t ($self->get_tracks ()) {
58        my ($la, $lo) = $t->get_center ();
59        $lat += $la;
60        $lon += $lo;
61        $n++;
62    }
63    if ($n > 0) {
64        $lat /= $n;
65        $lon /= $n;
66    }
67    return ($lat, $lon);
68}
69
70
71sub draw {
72    my $self = shift;
73    my $landsat = shift;
74    $landsat->get_canvas ()->delete ("track");
75    foreach my $t ($self->get_tracks ()) {
76        $t->draw ($landsat);
77    }
78}
79
80
81return 1;
Note: See TracBrowser for help on using the repository browser.