[File] [PATCH] of Magdir/map for Garmin map subfiles

Jörg Jenderek joerg.jen.der.ek at gmx.net
Mon Apr 29 02:54:12 UTC 2019


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hello,

some days ago i run out of disc space on my Windows System. About
16 GB at c:\ProgramData\Garmin are occupied by Garmin Express, a
software to update Garmin gps navigation devices. When i run file
version 5.36 on downloaded maps are only described as "data".

So i add lines to Magdir/map. Unfortunately there exist no official
documentation by Garmin, but some people have reverse engineered many
aspects of that file format. This is information is found on wiki of
street map. So add comment line like
#https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/IMG_File_Format

Many maps contain a 7 byte sequence containing the creation date. So i
add a sub function to display this date in form like
"yyyy-mm-dd h:mm:ss". This start with year and looks like
 0	name				garmin-date
 # year like 2018
 ...
 # second (0-59)
 >6	ubyte		x		\b:%.2u
Then i replace in Magdir/map already existing garmin dates showing lines
by call of sub routine like
 >0x39	use		garmin-date

Characteristic for such Garmin sub file maps is the up cased phrase
"GARMIN " near the beginning. That is first test line like
 2	string	GARMIN\

At the beginning the header length is stored. That information is shown
at the end by line like
 >>0	uleshort	x		\b, header length 0x%x
Because the size of the header is not large, this info can be used to
distinguish maps from ASCII text file with GARMIN phrase by second test
line like
 >0	uleshort <0x1000	Garmin map,

After the Garmin phrase 3 up case letters are stored for different
sub file. So according to
 wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/GMP_Subfile_Format
subtile of the larger area is indicated by GMP phrase. This is
expressed by line
 >>9	string	GMP				subtile
File named extension is same as 3 character phrase. This is expressed
by line
 !:ext			gmp
Furthermore use this phrase as last part of user defined mime type,
shown by line like
 !:mime			application/x-garmin-gpm

Often after the header something like a copyright message is stored.
When available show this by line like
 >>>(0.s)		string		x	%s

Often offset and length of other section is stored inside sub maps, But
that information is only of interest for developers and not normal
users. So add such information lines as comment like for region one by
lines like
 #>>>0x15			ulelong	       x	\b, at 0x%x
 #>>>0x19			ulelong	       x	0x%x bytes RGN1

After applying the above mentioned modifications by patch
file-5.36-map-garmin-subs.diff then all such garmin sub map files are
described by Magdir/map like:

12EE3.TYP:                 Garmin map, types,
	created 2008-08-01 16:24:43, code page 1252, header length 0x5b
CNEURONT.LBL:              Garmin map, labels UTF8,
	coding type 0x9, header length 0x2a9
CNEURONT.MDR:              Garmin map, address table,
	header length 0x310
CNEURONT.NET:              Garmin map, highways,
	header length 0x64
CNEURONT.NOD:              Garmin map, routing,
	created 2018-07-23 21:43:57,
	header length 0x7f
CNEURONT.RGN:              Garmin map, region,
	header length 0x7d
CNEURONT.SRT:              Garmin map, sort table,
	created 2018-07-24 17:07:11,
	header length 0x25
CNEURONT.TRE:              Garmin map, tree
	City Nav Europe NTU 2019.2
	Basemap Copyright 1995-2018 by GARMIN Corporation.,
	created 2018-07-23 21:43:57, ID 0x18a5df7,
	header length 0x135
CNEuroNTU_2019_30_trf.trf: Garmin map, traffic,
	1st Preitenegg L606/L148,
	header length 0x5a
I0001EA4.TYP:              Garmin map, types,
	created 2018-11-01 16:12:12, code page 65001,
	header length 0xae
I18A600F.GMP:              Garmin map, subtile
	Copyright Garmin Ltd. or its subsidiaries.  All rights reserved.,
	created 2018-07-24 3:44:39,
	header length 0x3d
garmin.txt:                ASCII text, with CRLF line terminators


I hope my diff file can be applied in future version of
file utility.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek







-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXMZnSQAKCRCv8rHJQhrU
1q6CAJ48WMbnUjSQvlDxkSzZxYFcUpA2WgCg17iQPpgC6l/5hncGSQ73/MgH1oc=
=RcCt
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.36/magic/Magdir/map.old	2018-12-28 00:22:34 +0000
+++ file-5.36/magic/Magdir/map	2019-04-28 23:07:03 +0000
@@ -82,14 +82,3 @@
 >0x10	string		!DSKIMG		\b, signature "%.7s"
-# Creation year
->0x39 	uleshort	x 		\b, created %u
-# Creation month (0-11)
->0x3b	ubyte		x		\b-%.2u
-# Creation day (1-31)
->0x3c	ubyte		x		\b-%.2u
-# Creation hour (0-23)
->0x3d	ubyte		x		%u
-# Creation minute (0-59)
->0x3e	ubyte		x		\b:%.2u
-# Creation second (0-59)
->0x3f	ubyte		x		\b:%.2u
+>0x39	use		garmin-date
 # Map file identifier like GARMIN\0
@@ -179,2 +168,152 @@
 
+#	display date stored inside Garmin maps like yyyy-mm-dd h:mm:ss
+0	name				garmin-date
+# year like 2018
+>0 	uleshort	x 		\b, created %u
+# month (0-11)
+>2	ubyte		x		\b-%.2u
+# day (1-31)
+>3	ubyte		x		\b-%.2u
+# hour (0-23)
+>4	ubyte		x		%u
+# minute (0-59)
+>5	ubyte		x		\b:%.2u
+# second (0-59)
+>6	ubyte		x		\b:%.2u
+
+# Summary: Garmin Map subfiles
+# From:	Joerg Jenderek
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/IMG_File_Format
+# Garmin Common Header
+2	string	GARMIN\ 
+# skip ASCII text by checking for low header length
+>0	uleshort <0x1000	Garmin map,
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/GMP_Subfile_Format
+>>9	string	GMP				subtile
+!:mime			application/x-garmin-gpm
+!:ext			gmp
+# copyright message
+>>>(0.s)		string		x	%s
+>>>0x0E 		use		garmin-date
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/MDR_Subfile_Format
+# This contains the searchable address table used for finding routing destinations
+>>9	string	MDR				address table
+!:mime			application/x-garmin-mdr
+!:ext			mdr
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/NOD_Subfile_Format
+# http://svn.parabola.me.uk/display/trunk/doc/nod.txt
+# This contains the routing information
+>>9	string	NOD				routing
+!:mime			application/x-garmin-nod
+!:ext			nod
+>>>0x0E 		use		garmin-date
+#>>>0x15			ulelong		x	\b, at 0x%x
+#>>>0x19			ulelong		x	0x%x bytes NOD1
+#>>>0x25			ulelong		x	\b, at 0x%x
+#>>>0x29			ulelong		x	0x%x bytes NOD2
+#>>>0x31			ulelong		x	\b, at 0x%x
+#>>>0x35			ulelong		x	0x%x bytes NOD3
+# URL: http://www.pinns.co.uk/osm/net.html
+# routable highways (length, direction, allowed speed,house address information)
+>>9	string	NET				highways
+!:mime			application/x-garmin-net
+!:ext			net
+#>>>0x15			ulelong		x	\b, at 0x%x
+#>>>0x19			ulelong		x	0x%x bytes NET1
+#>>>0x22			ulelong		>0
+#>>>>0x1E		ulelong		x	\b, at 0x%x
+#>>>>0x22		ulelong		x	0x%x bytes NET2
+#>>>0x2B			ulelong		>0
+#>>>>0x27		ulelong		x	\b, at 0x%x
+#>>>>0x2B		ulelong		x	0x%x bytes NET3
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/LBL_Subfile_Format
+>>9	string	LBL				labels
+!:mime			application/x-garmin-lbl
+!:ext			lbl
+>>>(0.s)		string	x	%s
+# Label coding type 6h 9h and ah
+>>>0x1E			ubyte		x	\b, coding type 0x%x
+#>>>0x15			ulelong		x	\b, at 0x%x
+#>>>0x19			ulelong		x	0x%x bytes LBL1
+#>>>0x1F			ulelong		x	\b, at 0x%x
+#>>>0x23			ulelong		x	0x%x bytes LBL2
+#>>>0x2D			ulelong		x	\b, at 0x%x
+#>>>0x31			ulelong		x	0x%x bytes LBL3
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/SRT_Subfile_Format
+# A lookup table of the chars in the map's codepage, and their collating sequence
+>>9	string	SRT				sort table
+!:mime			application/x-garmin-srt
+!:ext			srt
+>>>0x0E 		use		garmin-date
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/TRE_Subfile_Format
+>>9	string	TRE				tree
+!:mime			application/x-garmin-tre
+!:ext			tre
+# title like City Nav Europe NTU 2019.2 Basemap
+# or OSM Street map
+>>>(0.s)		string		x	%s
+# 2nd title like Copyright 1995-2018 by GARMIN Corporation.
+# or http://www.openstreetmap.org/
+>>>>&1			string		x	%s
+>>>0x0E 		use		garmin-date
+#>>>0x21			ulelong		x	\b, at 0x%x
+#>>>0x25			ulelong		x	0x%x bytes TRE1
+#>>>0x29			ulelong		x	\b, at 0x%x
+#>>>0x2D			ulelong		x	0x%x bytes TRE2
+#>>>0x31			ulelong		x	\b, at 0x%x
+#>>>0x35			ulelong		x	0x%x bytes TRE3
+# Copyright record size
+#>>>0x39			uleshort	x	\b, copyright record size %u
+# Map ID
+>>>0x74			ulelong		x	\b, ID 0x%x
+# URL: https://www.gpspower.net/garmin-tutorials/353310-basecamp-installing-free-desktop-map.html
+# For road traffic information service (RDS/TMS/TMC). Commonly seen in City Navigator maps
+>>9	string	TRF				traffic,
+!:mime			application/x-garmin-trf
+!:ext			trf
+# city/region like Preitenegg
+>>>(0.s+1) 		string		x	1st %s
+# highway part like L606/L148
+>>>>&1			string		x	%s
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/Format
+# Reference: http://www.pinns.co.uk/osm/typformat.html
+# customize the appearance of objects. For GPS and MapSource/Qlandkarte better looking maps
+>>9	string	TYP				types
+!:mime			application/x-garmin-typ
+!:ext			typ
+>>>0x0E 		use		garmin-date
+# character set 1252 65001~UTF8
+>>>0x15			uleshort	x	\b, code page %u
+# POIs
+#>>>0x17			ulelong		x	\b, at 0x%x
+#>>>0x1B			ulelong		x	0x%x bytes TYP1
+# extra pois
+#>>>0x5B			ulelong		x	\b, at 0x%x
+#>>>0x5F			ulelong		x	0x%x bytes TYP8
+# URL: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/RGN_Subfile_Format
+# http://www.pinns.co.uk/osm/RGN.html
+# region data used by the Garmin software
+>>9	string	RGN				region
+!:mime			application/x-garmin-rgn
+!:ext			rgn
+# POIs,Indexed POIs,Polylines or Polygons or first map level
+#>>>0x15			ulelong	       x	\b, at 0x%x
+#>>>0x19			ulelong	       x	0x%x bytes RGN1
+# polygons with extended types
+#>>>0x21			ulelong	       >0
+#>>>>0x1D		ulelong	       x	\b, at 0x%x
+#>>>>0x21		ulelong	       x	0x%x bytes RGN2
+# polylines with extended types
+#>>>0x3D			ulelong	       >0
+#>>>>0x39		ulelong	       x	\b, at 0x%x
+#>>>>0x3D		ulelong	       x	0x%x bytes RGN3
+# extended POIs
+#>>>0x59			ulelong	       >0
+#>>>>0x55		ulelong	       x	\b, at 0x%x
+#>>>>0x59		ulelong	       x	0x%x bytes RGN3
+#>>9	default		x		unknown map type
+# Header length; GMP:31h 35h 3Dh,MDR:11Eh 238h 2C4h 310h,NOD:3Fh 7Fh,NET:64h,
+# LBL:2A9h,SRT:1Dh 25h 27h,TRE:CFh 135h,TRF:5Ah,TYP:5Bh 6Eh 7Ch AEh,RGN:7Dh
+>>0	uleshort	x		\b, header length 0x%x
+
 # TOM TOM GPS watches ttbin files:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.36-map-garmin-subs.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190429/4e1b4bd1/attachment.obj>


More information about the File mailing list