Skip to content

Commit 42ff437

Browse files
committedFeb 19, 2020
fix: python3 support
1 parent 644fee4 commit 42ff437

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed
 

‎README.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ On Debian style OS:
1616

1717
sudo apt install python-gdal
1818

19+
for python3
20+
21+
sudo apt install python3-gdal
22+
1923
for others give your search-engine a try...
2024

2125
## Basic usage

‎gdal2tiles-multiprocess.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ def __init__(self, arguments):
806806
math.ceil(log2(self.in_ds.RasterYSize
807807
/ float(self.tilesize)))))
808808

809-
if self.tmaxz < self.nativezoom:
809+
if int(self.tmaxz or 0) < self.nativezoom:
810810
self.tmaxz = self.nativezoom
811811

812812
if self.options.verbose:
@@ -1580,7 +1580,7 @@ def generate_base_tiles(self, cpu):
15801580

15811581
# mx, my = self.out_gt[0], self.out_gt[3] # OriginX, OriginY
15821582
# px, py = self.mercator.MetersToPixels( mx, my, self.tmaxz)
1583-
# print "Pixel coordinates:", px, py, (mx, my)
1583+
# print("Pixel coordinates:", px, py, (mx, my))
15841584

15851585
print('')
15861586
print('Tiles generated from the max zoom level:')
@@ -1605,11 +1605,11 @@ def generate_base_tiles(self, cpu):
16051605
print ('dataBandsCount: ', self.dataBandsCount)
16061606
print ('tilebands: ', tilebands)
16071607

1608-
# print tminx, tminy, tmaxx, tmaxy
1608+
# print(tminx, tminy, tmaxx, tmaxy)
16091609

16101610
tcount = (1 + abs(tmaxx - tminx)) * (1 + abs(tmaxy - tminy))
16111611

1612-
# print tcount
1612+
# print(tcount)
16131613

16141614
ti = 0
16151615

‎gdal2tiles.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ def open_input(self):
13671367
math.ceil(log2(self.out_ds.RasterYSize
13681368
/ float(self.tilesize)))))
13691369

1370-
if self.tmaxz < self.nativezoom:
1370+
if int(self.tmaxz or 0) < self.nativezoom:
13711371
self.tmaxz = self.nativezoom
13721372

13731373
if self.options.verbose:
@@ -1545,7 +1545,7 @@ def generate_base_tiles(self):
15451545

15461546
# mx, my = self.out_gt[0], self.out_gt[3] # OriginX, OriginY
15471547
# px, py = self.mercator.MetersToPixels( mx, my, self.tmaxz)
1548-
# print "Pixel coordinates:", px, py, (mx, my)
1548+
# print("Pixel coordinates:", px, py, (mx, my))
15491549

15501550
print('')
15511551
print('Tiles generated from the max zoom level:')
@@ -1570,11 +1570,11 @@ def generate_base_tiles(self):
15701570
print ('dataBandsCount: ', self.dataBandsCount)
15711571
print ('tilebands: ', tilebands)
15721572

1573-
# print tminx, tminy, tmaxx, tmaxy
1573+
# print(tminx, tminy, tmaxx, tmaxy)
15741574

15751575
tcount = (1 + abs(tmaxx - tminx)) * (1 + abs(tmaxy - tminy))
15761576

1577-
# print tcount
1577+
# print(tcount)
15781578

15791579
ti = 0
15801580

@@ -1614,7 +1614,7 @@ def generate_base_tiles(self):
16141614
elif self.options.profile == 'geodetic':
16151615
b = self.geodetic.TileBounds(tx, ty, tz)
16161616

1617-
# print "\tgdalwarp -ts 256 256 -te %s %s %s %s %s %s_%s_%s.tif" % ( b[0], b[1], b[2], b[3], "tiles.vrt", tz, tx, ty)
1617+
# print("\tgdalwarp -ts 256 256 -te %s %s %s %s %s %s_%s_%s.tif" % ( b[0], b[1], b[2], b[3], "tiles.vrt", tz, tx, ty))
16181618

16191619
# Don't scale up by nearest neighbour, better change the querysize
16201620
# to the native resolution (and return smaller query tile) for scaling

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='gdal2tiles_leaflet',
5-
version='0.1.0',
5+
version='0.2.0',
66
description='Generate raster image tiles for use with leaflet',
77
url='https://github.com/commenthol/gdal2tiles-leaflet',
88
license='MIT',

‎test/createtiles.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22

33
rm -rf tiles
44

5+
export GDAL_ALLOW_LARGE_LIBJPEG_MEM_ALLOC=1
6+
7+
python=python3
8+
59
case $1 in
610
mpz)
7-
../gdal2tiles-multiprocess.py -l -p raster -z 0-5 -w none karta.jpg tiles
11+
$python ../gdal2tiles-multiprocess.py -l -p raster -z 0-5 -w none karta.jpg tiles
812
;;
913
mp)
10-
../gdal2tiles-multiprocess.py -l -p raster -w none karta.jpg tiles
14+
$python ../gdal2tiles-multiprocess.py -l -p raster -w none karta.jpg tiles
1115
;;
1216
z)
13-
../gdal2tiles.py -l -p raster -w none karta.jpg -z 0-5 tiles
17+
$python ../gdal2tiles.py -l -p raster -w none karta.jpg -z 0-5 tiles
1418
;;
1519
*)
16-
../gdal2tiles.py -l -p raster -w none karta.jpg tiles
20+
$python ../gdal2tiles.py -l -p raster -w none karta.jpg tiles
1721
;;
1822
esac

0 commit comments

Comments
 (0)
Failed to load comments.