I'll try to be as clear as possible.
What we want to do is to convert a garmin *.img map from pseudo-nt to non-nt.
So, i have this "example2_NT.img" map and using GmapTool i "split it" and get its subfile "48580011.GMP"
Inside the gmp as stated in first post, there are all of the 5 regular subfiles TRE, RGN, LBL, NET and NOD, and the info on them is EXACTLY the same as if the file where non-nt.
If we get them we can "re-join" them using GmapTool and get the non-nt version.
What i'll explain here is how to find, extract and modify the header of each subfile inside the gmp.
As i already have the raw data of this example i can compare version pseuso-NT and non-NT made by myself, with this and some imagination i realize what is needed to be done.
Here it is the comparison of each subfile header in the pseudo-nt and non*nt version (obviously you won't have the non-nt version in real life !!)
Spoiler: pic
Spoiler: old pics
I only put the headers as they are the only thing that is changed, the bytes you see in red are the ones that differ. This bytes represents the offset (location) of the data within the GMP file.
As in pseudo-NT the subfiles are re-arranged the offsets need to be changed to continue pointing to the right location where the data is.
The headers are easy recognizable and are easy to extract from the GMP file as they are one after another, where one ends the other begins.
The same is with the "body" of the data of each subfile.
The GMP is structured as
GMP header
TRE header
RGN header
LBL header
NET header
NOD header
TRE body
RGN body
LBL body
NET body
NOD body
Once you have each header, with the info inside them you'll know where to look up to retrieve the "body" in the GMP file.
For example in the TRE header (look at the right image) at x31 (4bytes) it is written where it is the beginning of the TRE "body" data (offset).
x31 4bytes means that the info is from x31 to x34. It needs to be read backwards. You see 24 03 00 00 so it is x00000324, without the meaningless zeros x324.
So the body of the TRE subfile begins at x324.
The other differences are from other offsets that point to other locations inside the TRE subfile inside the GMP
The differences are because the data is re-arranged, to put them back as they need to be you need to subtract the offsets some value as it is written here:
Spoiler: list
Whith this info we are now capable to locate and extract the body of each sufile.
Now you put in the "offset corrected" header and the body and create each subfile.
Now you can "join" all the subfiles using GmapTools (you need to SELECT "SHORT HEADER" option), and you get the non-NT version of the img.
You can open it with GPSmapedit, maptk 3.3.0, cgpsmapper 0085 etc...
There is another possibility as explained in an earlier post, instead of changing the offsets in the header you can leave them as they are, and add zeros between the header and the body to maintain the same absolute position of the body.
The number of bytes zeros needed in between are the same that you subtract in the other option.
For example in the TRE subfile, you can leave the header as it is in the gmp then add 587 bytes of zeros and then append the body data.
Obviously this need to be automated for "lot of map" conversion. But for a few map it can be done.
If anyone is already in the know of C, C+ or any other, it would be easy for him/her, i hope so, because i don't have so much time and i would need to study the relevants commands to manage binary data etc...
EDIT: I attach the files i used if you want to use them



Likes: 

Reply With Quote
Bookmarks