17
17
package uk.me.parabola.imgfmt.app.lbl;
19
import java.util.HashMap;
19
22
import uk.me.parabola.imgfmt.Utils;
20
import uk.me.parabola.imgfmt.app.BufferedReadStrategy;
21
import uk.me.parabola.imgfmt.app.BufferedWriteStrategy;
23
import uk.me.parabola.imgfmt.app.BufferedImgFileReader;
24
import uk.me.parabola.imgfmt.app.BufferedImgFileWriter;
22
25
import uk.me.parabola.imgfmt.app.ImgFile;
26
import uk.me.parabola.imgfmt.app.ImgFileReader;
23
27
import uk.me.parabola.imgfmt.app.Label;
24
import uk.me.parabola.imgfmt.app.ReadStrategy;
25
28
import uk.me.parabola.imgfmt.app.labelenc.BaseEncoder;
26
29
import uk.me.parabola.imgfmt.app.labelenc.CharacterDecoder;
27
30
import uk.me.parabola.imgfmt.app.labelenc.CharacterEncoder;
28
31
import uk.me.parabola.imgfmt.app.labelenc.CodeFunctions;
29
32
import uk.me.parabola.imgfmt.app.labelenc.EncodedText;
33
import uk.me.parabola.imgfmt.app.trergn.Subdivision;
30
34
import uk.me.parabola.imgfmt.fs.ImgChannel;
31
35
import uk.me.parabola.log.Logger;
33
import java.io.IOException;
34
import java.util.HashMap;
36
import uk.me.parabola.imgfmt.app.Exit;
38
39
* The file that holds all the labels for the map.
64
65
setHeader(lblHeader);
67
setWriter(new BufferedWriteStrategy(chan));
68
setWriter(new BufferedImgFileWriter(chan));
69
70
position(LBLHeader.HEADER_LEN + LBLHeader.INFO_LEN);
71
72
// The zero offset is for no label.
72
73
getWriter().put((byte) 0);
74
setReader(new BufferedReadStrategy(chan));
75
setReader(new BufferedImgFileReader(chan));
75
76
lblHeader.readHeader(getReader());
76
77
CodeFunctions funcs = CodeFunctions.createEncoderForLBL(
77
78
lblHeader.getEncodingType());
82
83
places.init(this, lblHeader.getPlaceHeader());
85
public void sync() throws IOException {
86
log.debug("syncing lbl file");
90
public void writePost() {
90
91
// Now that the body is written all the required offsets will be set up
91
92
// inside the header, so we can go back and write it.
92
93
getHeader().writeHeader(getWriter());
95
// Text can be put between the header and the body of the file.
94
96
getWriter().put(Utils.toBytes("mkgmap"));
100
99
private void writeBody() {
125
126
* @return A reference to the created label.
127
128
public Label newLabel(String text) {
129
129
EncodedText etext = textEncoder.encodeText(text);
130
l = labelCache.get(text);
130
Label l = labelCache.get(text);
132
132
l = new Label(etext);
133
133
labelCache.put(text, l);
143
143
return places.createPOI(name);
146
public POIRecord createExitPOI(String name, Exit exit) {
147
return places.createExitPOI(name, exit);
150
public POIIndex createPOIIndex(String name, int poiIndex, Subdivision group, int type) {
151
return places.createPOIIndex(name, poiIndex, group, type);
154
public Country createCountry(String name, String abbr) {
155
return places.createCountry(name, abbr);
158
public Region createRegion(Country country, String region, String abbr) {
159
return places.createRegion(country, region, abbr);
162
public City createCity(Region region, String city, boolean unique) {
163
return places.createCity(region, city, unique);
166
public City createCity(Country country, String city, boolean unique) {
167
return places.createCity(country, city, unique);
170
public Zip createZip(String code) {
171
return places.createZip(code);
174
public Highway createHighway(Region region, String name) {
175
return places.createHighway(region, name);
178
public ExitFacility createExitFacility(int type, char direction, int facilities, String description, boolean last) {
179
return places.createExitFacility(type, direction, facilities, description, last);
146
182
public void allPOIsDone() {
147
183
places.allPOIsDone();
177
213
return new String(text.getCtext(), 0, text.getLength());
216
public PlacesHeader getPlaceHeader() {
217
return lblHeader.getPlaceHeader();
220
public int numCities() {
221
return places.numCities();
224
public int numZips() {
225
return places.numZips();
228
public int numHighways() {
229
return places.numHighways();
232
public int numExitFacilities() {
233
return places.numExitFacilities();