loicgasser/quantized-mesh-tile

unpack requires a string argument of length 2?

bertt opened this issue · 13 comments

bertt commented

when I run the following code, an error about the unpack method
is returned. Any ideas how to fix this?

from quantized_mesh_tile.global_geodetic import GlobalGeodetic
from quantized_mesh_tile.terrain import TerrainTile
geodetic = GlobalGeodetic(True)
[z, x, y] = [9, 533, 383]
[minx, miny, maxx, maxy] = geodetic.TileBounds(x, y, z)
ter = TerrainTile(west=minx, south=miny, east=maxx, north=maxy)
ter.fromFile('9_533_383.terrain')

Error:

Traceback (most recent call last):
  File "test.py", line 24, in <module>
    ter.fromFile('9_533_383.terrain')
  File "C:\Python27\lib\site-packages\quantized_mesh_tile\terrain.py", line 433, in fromFile
    self.fromStringIO(f, hasLighting=hasLighting, hasWatermask=hasWatermask)
  File "C:\Python27\lib\site-packages\quantized_mesh_tile\terrain.py", line 334, in fromStringIO
    unpackEntry(f, TerrainTile.vertexData['uVertexCount'])
  File "C:\Python27\lib\site-packages\quantized_mesh_tile\utils.py", line 19, in unpackEntry
    return unpack('<%s' % entry, f.read(calcsize(entry)))[0]
struct.error: unpack requires a string argument of length 2

What version of python are you running ?

bertt commented

2.7.13rc1, need to install other version?

ok, it should work, did you unzip the file? If you did please attach the file I'll give it a go when I have time.

bertt commented

I use the file from the testcases (https://github.com/loicgasser/quantized-mesh-tile/blob/master/tests/data/9_533_383.terrain) I think it's not gzipped?

Then it's not, probably os related then, I never tried on Windows. :D I'll see what I can do

bertt commented

ok shall it check on other OS too

If you can yes would be great.

bertt commented

works allright on my mac (python 2.7.12) :-)

if you can find out what causes the issue I'd be glad, I'd like to know as well.

great :D

bertt commented

installed python 2.7.12 on windows too but got same error

bertt commented

found it! turns out something was wrong with my testfile...
very confusing error message though :-)