Debian Codegraph @

src/uk/me/parabola/imgfmt/app/lbl/ExitFacility.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2007 Steve Ratcliffe
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 *
14 * Author: Steve Ratcliffe
15 * Create date: Jan 1, 2008
16 */
17 package uk.me.parabola.imgfmt.app.lbl;
18
19 import uk.me.parabola.imgfmt.app.ImgFileWriter;
20 import uk.me.parabola.imgfmt.app.Label;
21
22 /**
23 * Represent a facility at a motorway exit
24 *
25 * @author Mark Burton
26 */
27 public class ExitFacility {
28
29 private final int index;
30 private final Label description;
31 private final int type; // truck stop - 24 hour diesel + food
32 private final int direction; // undefined
33 private final int facilities; // none
34 private final boolean last;
35
36 public ExitFacility(int type, char direction, int facilities, Label description, boolean last, int index) {
37 this.type = type;
38 this.direction = directionCode(direction);
39 this.facilities = facilities;
40 this.description = description;
41 this.last = last;
42 this.index = index;
43 }
44
45 void write(ImgFileWriter writer) {
46 int word = 0;
47 word |= description.getOffset(); // 0:21 = label offset
48 // 22 = unknown
49 if(last)
50 word |= 1 << 23; // 23 = last facility for this exit
51 word |= type << 24; // 24:27 = 4 bit type
52 // 28 = unknown
53 word |= direction << 29; // 29:31 = 3 bit direction
54 writer.put4(word);
55 writer.put1u(facilities);
56 }
57
58 public int getIndex() {
59 return index;
60 }
61
62 public boolean getOvernightParking() {
63 return false;
64 }
65
66 private int directionCode(char direction) {
67 int code = "NSEWIOB".indexOf(direction);
68 if(code < 0)
69 code = 7; // undefined
70 return code;
71 }
72 }