source: subversion/applications/editors/osmpedit/osmsegment.pm @ 34468

Last change on this file since 34468 was 1109, checked in by tpersson, 13 years ago

More support for ways added

File size: 2.6 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 osmsegment;
18
19use FindBin qw($RealBin);
20use lib "$RealBin/../perl";
21
22use osmbase;
23
24use strict;
25
26use vars qw (@ISA  $AUTOLOAD);
27@ISA = qw (osmbase);
28
29
30# class: path, unsurfaced, minor, estate, street, secondary, primary or 
31# motorway
32#foot: has to be no, unofficial or yes
33# horse: same as foot
34# bike: same as foot
35# car: no or yes
36
37
38sub new {
39    my $this = shift;
40    my $class = ref($this) || $this;
41    SUPER::new $class (
42                       FROM => 0,
43                       TO => 0,
44                       @_
45                       );
46}
47
48sub set_from {
49    my $self = shift;
50    my $val = shift;
51    $self->{FROM} = $val;
52}
53
54sub get_from {
55    my $self = shift;
56    return $self->{FROM};
57}
58
59sub set_to {
60    my $self = shift;
61    my $val = shift;
62    $self->{TO} = $val;
63}
64
65sub get_to {
66    my $self = shift;
67    return $self->{TO};
68}
69
70sub get_osmuid {
71    my $self = shift;
72    my $res = $self->get_uid ();
73    $res =~ s/s//;
74    return $res;
75}
76
77sub get_osmfrom {
78    my $self = shift;
79    my $res = $self->get_from ();
80    $res =~ s/n//;
81    return $res;
82}
83
84sub get_osmto {
85    my $self = shift;
86    my $res = $self->get_to ();
87    $res =~ s/n//;
88    return $res;
89}
90
91
92
93sub print {
94    my $self = shift;
95    my $from = $self->get_from ();
96    my $to = $self->get_to ();
97    my $uid = $self->get_uid ();
98    my $tags = $self->get_tags ();
99    print "OSMSEGMENT: $from $to $uid --- ";
100    foreach my $k (keys %{$tags}) {
101        print "$k - $tags->{$k}; ";
102    }
103    print "\n";
104}
105
106sub update_osm_segment {
107    my $self = shift;
108    my $username = shift;
109    my $password = shift;
110
111    my $from = $self->get_osmfrom ();
112    my $to = $self->get_osmto ();
113    my $tags = $self->get_tags ();
114
115    my $uid = $self->get_osmuid ();
116    print STDERR "Update segment: $uid $from $to\n";
117    if ($uid) {
118        return osmutil::update_segment ($uid, $from, $to, $tags, $username,
119                                        $password);
120    }
121}
122
123
124return 1;
Note: See TracBrowser for help on using the repository browser.