Skip to content

Commit

Permalink
support template URL for TMS backend
Browse files Browse the repository at this point in the history
  • Loading branch information
woodpeck committed Jun 29, 2020
1 parent 22cae90 commit 1c52d13
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
tirex (0.6.3) bionic; urgency=medium

* modify TMS backend to take template URL parameter

This comment has been minimized.

Copy link
@stephankn

stephankn Jan 13, 2021

Contributor

is it correct that no "signature" is added? number of version headings and signatures differs.
dpkg-gencontrol report warnings:

dpkg-gencontrol: warning: debian/changelog(l5): found start of entry where expected more change data or trailer
LINE: tirex (0.6.2) bionic; urgency=medium

tirex (0.6.2) bionic; urgency=medium

* add TMS backend
Expand Down
4 changes: 2 additions & 2 deletions etc/renderer/tms/demotms.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ maxz=10
# Backend specific configuration
#-----------------------------------------------------------------------------

# the URL prefix for the TMS server, should probably end with a '?' or '&'
# the URL template for the TMS server, must contain {x} {y} {z}
# DO NOT USE tile.openstreetmap.de in a production environment, this is
# for testing only!
url=https://a.tile.openstreetmap.de/
url=https://a.tile.openstreetmap.de/{z}/{x}/{y}.png

# "slots" is the maximum number of parallel requests that one backend process
# will make; note that if you have several backend processes, these will add up
Expand Down
20 changes: 14 additions & 6 deletions lib/Tirex/Backend/TMS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Config parameters for the map file:
=over 8
=item url url prefix (to be followed by z/x/y.png)
=item url url template (should contain {x}, {y}, {z} which are replaced)
=item slots maximum number of parallel connections per backend process
=back
Expand Down Expand Up @@ -71,17 +72,24 @@ sub create_metatile

my $limit = 2 ** $metatile->get_z();

my $url = $map->{'url'};
my $z = $metatile->get_z();
$url =~ s/{z}/$z/g;

for (my $x = 0; $x < $Tirex::METATILE_COLUMNS; $x++)
{
my $xx = $metatile->get_x() + $x;
next if ($xx >= $limit);
next if ($xx >= $limit);
my $url1 = $url;
$url1 =~ s/{x}/$xx/g;
for (my $y = 0; $y < $Tirex::METATILE_ROWS; $y++)
{
my $yy = $metatile->get_y() + $y;
next if ($yy >= $limit);
my $url = sprintf("%s/%d/%d/%d.png", $map->{'url'}, $metatile->get_z(), $xx, $yy);
::syslog('debug', 'TMS request: %s', $url) if ($Tirex::DEBUG);
my $request = HTTP::Request->new('GET', $url, [ 'User-Agent' => 'tirex-backend-tms/' . $Tirex::VERSION ]);
next if ($yy >= $limit);
my $url2 = $url1;
$url2 =~ s/{y}/$yy/g;
::syslog('debug', 'TMS request: %s', $url2) if ($Tirex::DEBUG);
my $request = HTTP::Request->new('GET', $url2, [ 'User-Agent' => 'tirex-backend-tms/' . $Tirex::VERSION ]);
my $async_id = $async->add($request);
$async_index->{$async_id} = $x*$Tirex::METATILE_ROWS+$y;
}
Expand Down

0 comments on commit 1c52d13

Please sign in to comment.