use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class LBLFileReader method readZips.
/**
* Reads the zips.
*/
private void readZips() {
ImgFileReader reader = getReader();
PlacesHeader placeHeader = header.getPlaceHeader();
int start = placeHeader.getZipsStart();
int end = placeHeader.getZipsEnd();
reader.position(start);
int zipIndex = 1;
while (reader.position() < end) {
int lblOffset = reader.get3();
Zip zip = new Zip();
zip.setLabel(fetchLabel(lblOffset));
zip.setIndex(zipIndex);
zips.put(zip.getIndex(), zip);
zipIndex++;
}
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class RGNFileReader method fetchPointsCommonExtType.
/**
* The indexed points and the points sections are both read just the same.
*/
private void fetchPointsCommonExtType(Subdivision sd, long start, long end, List<Point> points) {
position(start);
ImgFileReader reader = getReader();
int number = points.size() + 1;
while (position() < end) {
Point p = new Point(sd);
int type = reader.get() << 8;
byte b = reader.get();
type |= 0x10000 + (b & 0x1f);
p.setType(type);
p.setDeltaLong((short) reader.getChar());
p.setDeltaLat((short) reader.getChar());
Label l;
if ((b & 0x20) != 0) {
int labelOffset = reader.getu3();
boolean hasPoi = (labelOffset & 0x400000) != 0;
if (hasPoi) {
POIRecord record = lblFile.fetchPoi(labelOffset);
if (record != null) {
l = record.getNameLabel();
p.setPOIRecord(record);
} else
l = lblFile.fetchLabel(0);
} else {
l = lblFile.fetchLabel(labelOffset);
}
p.setLabel(l);
}
if ((b & 0x80) != 0) {
extractExtraBytes(reader, p);
}
p.setNumber(number++);
points.add(p);
}
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class TREFileReader method getCopyrights.
public String[] getCopyrights(LBLFileReader lblReader) {
Section sect = header.getCopyrightSection();
ImgFileReader reader = getReader();
List<String> msgs = new ArrayList<>();
long pos = sect.getPosition();
while (pos < sect.getEndPos()) {
reader.position(pos);
int offset = reader.get3();
Label label = lblReader.fetchLabel(offset);
if (label != null) {
msgs.add(label.getText());
}
pos += sect.getItemSize();
}
return msgs.toArray(new String[msgs.size()]);
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class TREFileReader method readSubdivs.
/**
* Read in the subdivisions. There are a set of subdivision for each level.
*/
private void readSubdivs() {
ImgFileReader reader = getReader();
int start = header.getSubdivPos();
int end = start + header.getSubdivSize();
reader.position(start);
int subdivNum = 1;
int lastRgnOffset = reader.getu3();
for (int count = 0; count < levelDivs.length && reader.position() < end; count++) {
Subdivision[] divs = levelDivs[count];
Zoom zoom = mapLevels[count];
if (divs == null)
break;
for (int i = 0; i < divs.length; i++) {
int flags = reader.get();
int lon = reader.get3();
int lat = reader.get3();
int width = reader.getChar() & 0x7fff;
int height = reader.getChar() & 0xffff;
if (count < levelDivs.length - 1)
reader.getChar();
int endRgnOffset = reader.getu3();
SubdivData subdivData = new SubdivData(flags, lat, lon, 2 * width, 2 * height, lastRgnOffset, endRgnOffset);
Subdivision subdiv = Subdivision.readSubdivision(mapLevels[count], subdivData);
subdiv.setNumber(subdivNum++);
divs[i] = subdiv;
zoom.addSubdivision(subdiv);
lastRgnOffset = endRgnOffset;
}
}
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class TREFileReader method getMapInfo.
public String[] getMapInfo(int codePage) {
CodeFunctions funcs = CodeFunctions.createEncoderForLBL(0, codePage);
CharacterDecoder decoder = funcs.getDecoder();
// First do the ones in the TRE header gap
ImgFileReader reader = getReader();
reader.position(header.getHeaderLength());
List<String> msgs = new ArrayList<>();
while (reader.position() < header.getHeaderLength() + header.getMapInfoSize()) {
byte[] m = reader.getZString();
decoder.reset();
for (byte b : m) decoder.addByte(b);
DecodedText text = decoder.getText();
String text1 = text.getText();
msgs.add(text1);
}
return msgs.toArray(new String[msgs.size()]);
}
Aggregations