-
Notifications
You must be signed in to change notification settings - Fork 13
/
Trace.pm
68 lines (57 loc) · 1.35 KB
/
Trace.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/perl
package Trace;
use strict;
use warnings;
use OsmApi;
# -----------------------------------------------------------------------------
# Creates a trace by uploading a file.
# Returns: new trace id, or undef in case of error (will write error to stderr)
sub create
{
my ($filename, $description, $tags, $visibility) = @_;
my $resp = OsmApi::post_multipart("gpx/create", [
"file" => [$filename],
"description" => $description,
"tags" => $tags,
"visibility" => $visibility,
]);
if (!$resp->is_success)
{
print STDERR "cannot create trace: ".$resp->status_line."\n";
return undef;
}
return $resp->content;
}
sub get
{
my ($id) = @_;
my $resp = OsmApi::get("gpx/$id");
if (!$resp->is_success)
{
print STDERR "cannot load trace: ".$resp->status_line."\n";
return undef;
}
return $resp->content;
}
sub list
{
my $resp = OsmApi::get("user/gpx_files");
if (!$resp->is_success)
{
print STDERR "cannot load traces list: ".$resp->status_line."\n";
return undef;
}
return $resp->content;
}
sub delete
{
my ($id) = @_;
my $resp = OsmApi::delete("gpx/$id");
if (!$resp->is_success)
{
print STDERR "cannot delete trace: ".$resp->status_line."\n";
return undef;
}
return 1;
}
1;