Skip to content

Commit 4fd2b35

Browse files
committed
mapillary-mvt-fetch: implement option handling
Knows the following options now: --cache, --mvt-impl (to choose between python and perl implementation), --bbox). More will follow.
1 parent 2bf41e8 commit 4fd2b35

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

miscsrc/mapillary-mvt-fetch

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use strict;
1515
use warnings;
1616
use FindBin;
1717

18+
use Getopt::Long;
1819
use LWP::UserAgent;
1920
use JSON::PP;
2021
use lib "$FindBin::RealBin/..";
@@ -49,6 +50,21 @@ my $max_lon = 13.764158;
4950
my $min_lat = 52.337621;
5051
my $max_lat = 52.689878;
5152

53+
my $mvt_impl = 'pl';
54+
55+
GetOptions(
56+
"cache!" => \$do_cache,
57+
"bbox=s" => \my $bbox,
58+
"mvt-impl=s" => \$mvt_impl,
59+
)
60+
or die "usage: $0 [--[no]cache]] [--mvt-impl pl|py] [--bbox minlon,minlat,maxlon,maxlat] YYYYMMDD-[YYYYMMDD]\n";
61+
62+
if ($bbox) {
63+
my @fields = split /,/, $bbox;
64+
die "--bbox must have four fields\n" if @fields != 4;
65+
($min_lon,$min_lat,$max_lon,$max_lat) = @fields;
66+
}
67+
5268
my $date_range = shift;
5369
my $date_from = "";
5470
my $date_to = "";
@@ -151,9 +167,13 @@ for my $tile (@tiles) {
151167
}
152168
}
153169

154-
# Call Python script
155-
# my $json = `python3 $FindBin::RealBin/parse_mvt_sequences.py $file "$date_from" "$date_to"`;
156-
my $json = `$^X $FindBin::RealBin/parse_mvt_sequences.pl $file "$date_from" "$date_to"`;
170+
# Call Python or Perl script for mvt/protobuf decoding
171+
my $json;
172+
if ($mvt_impl eq 'py') {
173+
$json = `python3 $FindBin::RealBin/parse_mvt_sequences.py $file "$date_from" "$date_to"`;
174+
} else {
175+
$json = `$^X $FindBin::RealBin/parse_mvt_sequences.pl $file "$date_from" "$date_to"`;
176+
}
157177
my $results = eval { decode_json($json) };
158178
if ($results && ref $results eq 'ARRAY') {
159179
for my $seq (@$results) {

0 commit comments

Comments
 (0)