unpack requires a string argument of length 2?
bertt opened this issue · 13 comments
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 ?
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.
https://quantized-mesh-tile.readthedocs.io/en/latest/terraintile.html#quantized_mesh_tile.terrain.TerrainTile.fromFile also there is an option to do it for you.
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
ok shall it check on other OS too
If you can yes would be great.
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
installed python 2.7.12 on windows too but got same error
found it! turns out something was wrong with my testfile...
very confusing error message though :-)