Debian Codegraph @

doc/typ-compiler.txt

raw
1 == The mkgmap TYP file compiler ==
2
3 This document describes the format that is understood by the mkgmap TYP compiler.
4 It contains everything you need to write a TYP file description that can be compiled, showing exactly how
5 you can get the different colour effects that are available.
6
7 The file can be in written in almost any character-set that allows basic ascii characters and can have Strings for any language that can be encoded in that character-set.
8 The mkgmap .txt TYP processor looks at the start of the file for a unicode BOM or a header line of the form:
9 ; -*- coding: charset -*-
10
11 to determine the encoding, and then will convert those Strings that can be represented in the target .IMG code-page and ignore the ones that can't.
12
13 It is safest to edit multi-lingual TYP files (eg. resources/mapnik.txt) with a good text editor;
14 if nessessary, using a graphical editor to manipulate the icons, then cutting the result back into the TYP .txt file.
15
16 For your own TYP file it might be convenient to use one of the graphical editors that are available.
17 However, beware that some of these editors don't preserve the full contents of the file
18 and might change the character representations of the Strings to those in a different character
19 set/encoding.
20 Also they make assumptions about the chars used to represent colours in icons and might change them.
21
22 These produce file formats that differ from each other and have variations to the specification that is presented here. These variations will be supported as they are discovered as long as they do not conflict with each other, but are not listed here for clarity. In particular the files produced by [http://www.pinns.co.uk/osm/ostyp.html TYPWiz] and [https://sites.google.com/site/sherco40/ TYPViewer] are supported.
23
24 == The [_id] section ==
25
26 ;FID=#
27 : The family id.
28 ;ProductCode=#
29 : The product code within a family, usually just left as one.
30 ;CodePage=#
31 : The code page to use for writing the labels.
32
33 Example:
34 [_id]
35 FID=1299
36 ProductCode=1
37 CodePage=1252
38 [end]
39
40 == The [_drawOrder] section ==
41 This is a list of polygon types and level numbers. Polygons with a higher
42 level number are drawn on top of those with a lower one.
43
44 There is only one tag that is valid in this section.
45
46 ;Type=object_type,level
47 :The object_type is the polygon type such as 0x07 or an extended type such as 0x10208
48 :The level is a number starting at 1.
49
50 Example:
51 [_drawOrder]
52 Type=0x032,1
53 Type=0x10101,2
54 Type=0x002,3
55 Type=0x003,3
56 Type=0x007,3
57 Type=0x009,3
58 Type=0x00c,3
59 Type=0x00e,3
60 Type=0x010,3
61 Type=0x012,3
62 Type=0x015,3
63 Type=0x01b,3
64 ...
65 [end]
66
67 If a polygon type is not listed in this section, then it will not be displayed at all. If it is then it will be styled according to a definition in a [_polygon] section later in this file, or in the default Garmin style if these is no such definition.
68
69 == Element sections ==
70 The main part of the file consists of descriptions of how elements are to be displayed so that you can change the colours and style of the displayed elements.
71
72 Each style definition starts with the name of the section in square brackets and ends with the line "[end]". For example:
73 [_polygon]
74 Type=0x02
75 String1=0x04,Residential
76 String2=0x01,Résidentiel
77 String3=0x03,Bebouwde kom
78 ExtendedLabels=Y
79 FontStyle=NoLabel
80 Xpm="0 0 2 0"
81 "! c #DCDCDC"
82 " c none"
83 [end]
84
85 [_line]
86 Type=0x22
87 ; options to style the line
88 [end]
89
90 [_point]
91 Type=0x52
92 ; options to style the POI
93 [end]
94
95 You have one of these for each polygon, line of POI you want to change from the built in Garmin style.
96
97 == Common options for element sections ==
98
99 These options will work in all the element sections [_point], [_line] and [_polygon].
100
101 ;Type=object_type
102 :The object type number - the kind of element that it is. If the number is greater than 0xff then it will be treated as a type and subtype combination. Eg 0x2305 is type 0x23 with subtype 0x5.
103
104 ;String=#,xxx
105 ;String=xxx
106 :Defines a label that will be attached to the element.
107 The (optional) first part is a language number, the next is the actual string.
108 You can use String1, String2 for compatibility, but just String will do for the mkgmap compiler.
109 String=Parking Lot
110 String=0x04,Parking
111 String=0x03,Parkeerplaats
112 :If the language number isn't specified it defaults to 0x00 which is the generic language.
113 This string is used if there isn't a definition for the currently selected language;
114 If there isn't a default the device shows the first string in the list.
115 The language numbers are defined [https://wiki.openstreetmap.org/wiki/Mkgmap/help/typ_compile#Appendix here].
116
117 ;FontStyle=xxx
118 : xxx can be one of NoLabel, SmallFont, NormalFont, LargeFont.
119
120 ;DayCustomColor=#colour
121 : The colour used for the font when the GPS unit is displaying day colours.
122
123 ;NightCustomColor=#colour
124 : The colour used when the GPS unit is displaying night colours.
125
126 == XPM format ==
127 The XPM format is a fairly widely used format for small image icons, so you
128 can read about it [http://en.wikipedia.org/wiki/X_PixMap elsewhere].
129 You would normally use some tool to create the image and copy it in,
130 but it is possible to create them by hand.
131 This is a brief summary of what it all means based on the following example:
132 Xpm="10 5 3 1"
133 "r c #ff0000"
134 "g c #00ff00"
135 "b c #0000ff"
136 "rrrrrrrrrr"
137 "rrrrrrrrrr"
138 "rbbbbbgggr"
139 "rbbbrggggr"
140 "rbbrrrrrrr"
141 "rrrrrrrrrr"
142
143 Working from the top, the first line consists of four numbers that mean
144 in order: the pixmap has a width of 10 and a height of 5; there are 3
145 different colours and each colour is represented by 1 character.
146
147 There then follows the three lines giving the colours to use. The first character(s) are a short name for the colour, in this case there is one character (r, g, b) because the last field in the first line was 1. Next is the letter 'c' which can be ignored, and the follows the normal RGB representation of the colour. In this case I have chosen red to be represented by the letter r, g for green and b for blue, but you can use any characters or colours you choose. A space is allowed, and it is traditional to use a space for the background colour.
148
149 Then there is the pixmap itself, it is 10 columns wide and 5 lines to match the width and height values in the first line. If the number of characters representing each pixel was 2 say, then there would be 10 groups of 2 characters across. Each letter represents one pixel of the final image, in this example, the top of the icon would be a red line and in the middle there would be some blue and green.
150
151 == Polygon elements ==
152 A [_polygon] section can have any of the common tags.
153
154 It must also contain an Xpm tag. This uses a modified form of the XPM format, see the XPM section for details about the format that are common between all the element types. The following notes only refer to how it is used within the polygon section.
155
156 * A single solid colour, that is the same in day and night displays
157 Xpm="0 0 1 0"
158 "a c #778899"
159
160 * One solid colour that is used in the day display mode and another that is used in the night display mode.
161 Xpm="0 0 2 0"
162 "a c #778899"
163 "b c #223322"
164
165 * A pixmap that has the same solid colours in day and night modes. The pixmap must be 32x32 and have two colours.
166 Xpm="32 32 2 1"
167 "a c #778899"
168 "b c #223322"
169 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
170 "aaaaaaaaaaaaabbbbbbbaaaaaaaaaaaa"
171 "aaaaaaaaaaabbbbbbbbbbbaaaaaaaaaa"
172 ; ... 32 rows in total
173
174 * The pixmap can have a transparent background, in which case the second colour will be given as 'none'
175 Xpm="32 32 2 1"
176 "a c #778899"
177 "b c none"
178 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
179 "aaaaaaaaaaaaabbbbbbbaaaaaaaaaaaa"
180 "aaaaaaaaaaabbbbbbbbbbbaaaaaaaaaa"
181 ; ... 32 rows in total
182
183 * If you want to have different colours for the day and night modes, then use 4 colours. As before the second and fourth colours can be 'none' to indicate that the background is transparent for the day and/or night colour respectively. In the example the night colour has a transparent background and the day version does not. When you draw the pixmap you only use the day colours, the device will automatically switch to the alternate colours when in night mode. It is traditional to use '3' and '4' for the night colour tags in the XPM, but with mkgmap you can use whatever you like.
184 Xpm="32 32 4 1"
185 "a c #778899"
186 "b c #221133"
187 "3 c #112233"
188 "4 c none"
189 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
190 "aaaaaaaaaaaaabbbbbbbaaaaaaaaaaaa"
191 "aaaaaaaaaaabbbbbbbbbbbaaaaaaaaaa"
192 ; ... 32 rows in total
193
194 == Line elements ==
195 A line section can contain any of the common tags. It can also have the following additional tags
196
197 ;LineWidth=#
198 :The line width in pixels. This is the width, excluding borders if there are any. This is only used if there is not a pixmap.
199 ;BorderWidth=#
200 :The border width. The line will be drawn (on devices that support this) with a border at each edge of the line. It is only used if there is no pixmap. If there should not be a border then it can be omitted or set to zero.
201 ;UseOrientation=(Y|N)
202 :If Y then the pixmap is rotated so that is always following the direction of the road.
203 LineWidth=2
204 BorderWidth=2
205 UseOrientation=Y
206
207 As with polygons there is an Xpm tag too and it can specify that solid colours should be used or that there is a bitmap.
208
209 If there is a bitmap then it is always has a width of 32, its height will be the width of the line (yes that sound confusing the first time you read it, it just means that the line is written horizontally in the pixmap). The colours work in exactly the same way as they do for polygons, so see the examples there for the different possibilities with day/night and transparent colours. An example with a pixmap, which shows a line that will have a thickness of 3.
210 Xpm="32 3 4 1"
211 "a c #550088"
212 ". c #889988"
213 "3 c #889988"
214 "4 c #889955"
215 "aaaaaaaaaaaaaaaaaaaaaaaaa....aaa"
216 "aaaaaa................aaaaaaaaaa"
217 "aaaaaaaaaaaaaaaaaaaaaaaaa....aaa"
218
219 When there is no pixmap then the LineWidth and BorderWidth options come into play. The following combinations are recognised by mkgmap.
220
221 * Solid line, no border. Same colour day and night.
222 LineWidth=2
223 Xpm="0 0 1 0"
224 "a c #989898"
225
226 * Solid line, no border. Different colour for day and night.
227 LineWidth=2
228 Xpm="0 0 2 0"
229 "a c #989898"
230 "b c #228844"
231
232 * Solid line, border width 1, same colour day/night. The second colour is the border colour, the first the main line colour.
233 LineWidth=2
234 BorderWidth=1
235 Xpm="0 0 2 0"
236 "a c #989898"
237 "b c #345544"
238
239 * Solid line, border of 1, different day/night colours
240 LineWidth=2
241 BorderWidth=1
242 Xpm="0 0 4 0"
243 "a c #989898"
244 "b c #345544"
245 "3 c #119811"
246 "4 c #3499ee"
247
248 == Points (POI) ==
249 A point can have any of the common tags and in addition can have the following two tags to specify the icon to be used in day and/or night modes.
250
251 ;DayXpm
252 :The XPM to be used as the only or when the display is showing day-time colours.
253 ;NightXpm
254 :This is optional and if given is an alternative XPM to use when showing night-time colours. It must have the same width and height as the DayXpm, but everything else about it can be different.
255
256 Only the DayXpm will be explained, the NightXpm is exactly the same, except that it is constrained to have the same width and height as the DayXpm.
257
258 Unlike lines and polygons which are simple two colour bitmaps, points can have many colours and partial transparency.
259 There are several colour modes, mkgmap will automatically determine which you need without having to specify it separately. Each POI can have different colours, transparency schemes and sizes.
260 * Up to 255 solid pixel colours
261 * Up to 254 solid pixel colours with an additional transparent pixel.
262 * Up to 255 pixel colours which can each have a different transparency value.
263 * Up to 16 million different colours, no transparency
264 * Up to 16 million different colours, one transparent pixel.
265
266 Here are example of the input and the effect that is achieved.
267 * A 10x5 icon with 5 solid colours
268 DayXpm="10 5 5 1"
269 "a c #112211"
270 ". c #1e2291"
271 "/ c #1ef291"
272 "@ c #1eff91"
273 "? c #11ff11"
274 "aaaaaaaaaa"
275 "a...aa//??"
276 "aaaaa@@//a"
277 "aaa.....aa"
278 "aaaaaaaaaa"
279
280 * A 10x5 icon with 4 solid colours and a transparent pixel
281 DayXpm="10 5 5 1"
282 ". c #1e2291"
283 "/ c #1ef291"
284 "@ c #1eff91"
285 "? c #11ff11"
286 "a c none"
287 "aaaaaaaaaa"
288 "a...aa//??"
289 "aaaaa@@//a"
290 "aaa.....aa"
291 "aaaaaaaaaa"
292
293 * Icon 10x5 with variable transparency on each colour. This is represented in the normal way by adding an extra alpha value to the end of the RGB colour value. The value 00 is completely transparent and FF is completely opaque. Since the TYP format only has 15 different levels of transparency, you should restrict to using the values [11, 22, 33, ... EE, FF]. However you can use any value and it will be rounded to the nearest supported value.
294 DayXpm="10 5 5 1"
295 ". c #1e2291"
296 "/ c #1ef291"
297 "@ c #1eff91dd"
298 "? c #11ff1188"
299 "a c #00000000"
300 "aaaaaaaaaa"
301 "a...aa//??"
302 "aaaaa@@//a"
303 "aaa.....aa"
304 "aaaaaaaaaa"
305 the first two colours are completely solid (if the alpha value is omitted it defaults to FF as usual), the third is slightly transparent, down to the last which is completely transparent.
306 <p>
307 An alternate notation is supported where the transparency value is appended to the line in the form "alpha=13", this is a transparency value that goes from 0 to 15, with 15 being completely transparent. As such it works the opposite way to the alpha value of the normal RGBa values in the previous example. The required conversions are made by mkgmap which ever one you use.
308
309 * Image with up to 16 million different colours.
310 By setting the number of colours in the XPM to zero you can specify a
311 different kind of image, where the colour for each pixel is specified
312 separately.
313
314 Example
315 IconXpm="10 10 0 0"
316 "#990088"
317 "#990088"
318 "#990067"
319 " ... and so on for 100 different values ..."
320
321 If you prefer you can place several pixel values on the same line, as
322 long as there are the correct number altogether.
323 IconXpm="10 10 0 0"
324 "#990088 #990088 #990067"
325 " ... and so on for 100 different values ..."
326
327 The spaces can be omitted for the most compact representation.
328 It is also possible to have a transparent pixel with this format, but there is currently not a way to represent this.
329
330 == Icons ==
331 An [_icons] section holds a set of images at different resolutions. The images are intended to be of the same logo or icon at a range of different sizes to suit different resolution devices.
332
333 Only a few tags are valid in this section.
334
335 * The <code>Type</code> tag is required. It identifies the point type that this image set will be used for.
336 * The <code>String</code> tag is also allowed, but it does not take a language code at the beginning. Therefore there can only be one of them.
337
338 The other tag that can be present is IconXpm.
339 There can be several of these tags, each one is a different
340 resolution/size. Each one can have a different size, colour mode, and
341 number of colours.
342 The appropriate version is selected according the capabilities of the
343 device it is being displayed on.
344
345 The format of the IconXpm tags has the same possibilities as in the _point sections.