Windows Error
Status: Alpha
Brought to you by:
lhj
When you run it on Windows, the program creates the error that a temp file could not be opened, from Layer.py when doing a copy. This is because Windows has the annoying habit of not being able to open files twice.
If you change the line in Layer.py, l. 482 or so to:
shutil.copyfileobj(tmplay, self.fhlay)
instead of the file copy operation it runs ok.
Unfortunately, it is not quite this easy. First of all you need to do a tmplay.seek(0) first to reset (poorly documented in Python), but even then the Windows version does not create the same file as the Linux one. I have the feeling that this is because the file does not flush...F*cking Vista...
diff for Layer.py
Again...I think I cracked it now. There were two problems to run it on Windoze.
The first one I reported with the temporary file, the other being that the flag for writing a binary file was missing.
Now I can create an imi file on Windows that opens correctly in VP. It still differs in the binary form from the Linux created one, but I believe that is merely a question of ordering the layers (I assume that different hash-maps are used, so when iterating over them they come out in different orders).
In the diff file I have attached, which applies to the Layers.py file only I made accordingly two changes:
the first being a "wb" flag for opening the layer file (I have not checked any of the other "w" flags, maybe they should change as well.
the second to switch over to StringIO as a replacement for a temporary file: I have used only a small OSM file for this and it might not be good for very large OSM files, but it resolves the problem on Windows where temporary files appear not to flush.
File Added: Layerpy.diff
Hi,
Thanks for finding this problem. I have never tried it in other OSes than Linux.
I am trying to apply the patch but it would be nice to keep the temporary file for large maps. Are you sure it is not working with tempfile if the seek and copyfileobj is used for the final copying?