Parsing Open Source maps from garmin (*.img extension)

Hello yesterday i try to parse Open Source *.img map files from Garmin.
I found some information but i cant read all of data.
Documentation is here:
http://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/IMG_File_Format
Here is sample code in C++ (but it can be only run in linux)
http://sourceforge.net/projects/garmin-img/

When i try to use documentation from wiki i have problem with reading subfiles like "TRE" files.
Can somebody help me with find more information? or maybe someone can compile this code in linux? Please help.
l3m0nAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BobcsiCommented:
A few days ago I made a Garmin IMG parsing program in Delphi.
What is the exact problem?
0
BobcsiCommented:
I attached a good specification
imgformat.pdf
0
l3m0nAuthor Commented:
i was using delphi too, but i get problem with reading:
1. File type of subfile (TRE) i need to get: "GARMIN TRE" but i got "GARMIN"
Can You paste some part of code?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

BobcsiCommented:
Are you parsing the FAT table?
procedure TGarminIMGFile.ParseFAT;
var
  I: integer;
  endOfParts: integer;
  FATStart: integer;
  firstByte: byte;
  FATLength: integer;
  nBlock: integer;
  FileName, FileExt, FullFileName: string;
  FileType: TIMGSubFileType;
  FileSize, PartNumber: integer;
  SubFile: TIMGSubFile;
  iCount: integer;
  LastBlock: integer;
begin
  F.Seek($01FE);
  endOfParts := F.ReadUInt16;
  if (endOfParts <> $AA55) then
    Exception.Create('Bad partition table end!');

  FATStart := $0200;
  while True do
  begin
    F.Seek(FATStart);
    firstByte := F.ReadByte;
    if firstByte = 1 then
      break
    else
      Inc(FATStart, FAT_BLOCK_SIZE);
  end;

  F.Seek(FATStart + $0C);
  FATLength := F.ReadInt32 - FATStart;
  if FATLength < 0 then
    Exception.Create('Invalid FAT length: ' + IntToStr(FATLength));

  Inc(FATStart, FAT_BLOCK_SIZE);


  F.Seek(FATStart);
  nBlock := FATLength div FAT_BLOCK_SIZE;

  for I := 0 to nBlock - 1 do
  begin
    F.Seek(FATStart + I * FAT_BLOCK_SIZE);
    firstByte := F.ReadByte;
    if firstByte = $01 then
    begin
      FileName := F.ReadString(8);
      FileExt := F.ReadString(3);
      FileType := GetSubFileType(FileExt);
      FullFileName := FileName + '.' + FileExt;
      FileSize := F.ReadInt32;
      PartNumber := F.ReadUInt16;

      Log(Format('FAT block at 0x%s:', [IntToHex(FATStart + I * FAT_BLOCK_SIZE, 4)]));
      Log(Format('  FileName: %s, FileSize: %d, PartNumber: %d', [FullFileName, FileSize, PartNumber]));

Open in new window


Here i got example:
42100010.TRE
42100010.RGN
42100010.LBL....etc
0
l3m0nAuthor Commented:
i dont understand this code:
FileSize := F.ReadInt32;
      PartNumber := F.ReadUInt16;

Open in new window


and this type:

  FileType: TIMGSubFileType;

Open in new window

0
l3m0nAuthor Commented:
Can You paste something else?
0
BobcsiCommented:
ReadInt32 is a function, what read integer (4 byte) from current file position;
and ReadInt16 read a word (2byte)

TIMGSubFileType is an own class for store the read data.

I have many class and source code for process img file, so i can send my files, if you give an email address or something...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
l3m0nAuthor Commented:
my email is: l3moniak2@gmail.com
Very thanks for help.
0
l3m0nAuthor Commented:
Could you send me it please?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.