use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class SrtFileReader method readSrt8.
private void readSrt8() {
ImgFileReader reader = getReader();
reader.position(tableHeader.getPosition() + srt8.getPosition());
int reclen = srt8.getItemSize();
int block = 1;
for (int i = 0; i < srt8.getNumItems(); i++) {
Integer nblock = offsetToBlock.get(i);
if (nblock != null)
block = nblock;
int flags = reader.get() & 0xff;
CodePosition cp = readCharPosition(reclen - 1);
int ch = block * 256 + (i % 256);
if ((flags & 0xf0) != 0) {
sort.add(ch, countExp + 1, 0, 0, flags);
countExp += ((flags >> 4) & 0xf) + 1;
} else {
sort.add(ch, cp.getPrimary(), cp.getSecondary(), cp.getTertiary(), flags);
}
}
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class SrtFileReader method readTableHeader.
private void readTableHeader() {
ImgFileReader reader = getReader();
reader.position(tableHeader.getPosition());
int len = reader.getChar();
sort.setHeader3Len(len);
sort.setId1(reader.getChar());
sort.setId2(reader.getChar());
sort.setCodepage(reader.getChar());
if (sort.getCodepage() == 65001)
sort.setMulti(true);
// ?
reader.getInt();
characterTable.readSectionInfo(reader, true);
// padding?
reader.position(reader.position() + 6);
srt5.readSectionInfo(reader, true);
// padding?
reader.position(reader.position() + 6);
if (len > 0x2c) {
srt6.readSectionInfo(reader, false);
}
if (len > 0x34) {
reader.getInt();
int maxCodeBlock = reader.getInt();
sort.setMaxPage(maxCodeBlock);
srt7.readSectionInfo(reader, true);
// padding?
reader.position(reader.position() + 6);
}
if (len > 0x44) {
srt8.readSectionInfo(reader, true);
}
readCharacterTable();
if (srt7.getSize() > 0) {
readSrt7();
readSrt8();
}
readExpansions();
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class SrtFileReader method readCharacterTable.
private void readCharacterTable() {
ImgFileReader reader = getReader();
reader.position(characterTable.getPosition());
int rs = characterTable.getItemSize();
long start = tableHeader.getPosition() + characterTable.getPosition();
reader.position(start);
for (int ch = 1; ch <= characterTable.getNumItems(); ch++) {
int flags = reader.get() & 0xff;
CodePosition cp = readCharPosition(rs - 1);
if ((flags & 0xf0) != 0) {
sort.add(ch, countExp + 1, 0, 0, flags);
countExp += ((flags >> 4) & 0xf) + 1;
} else {
sort.add(ch, cp.getPrimary(), cp.getSecondary(), cp.getTertiary(), flags);
}
}
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class NETFileReader method readLabelOffsets.
/**
* The first field in NET 1 is a label offset in LBL. Currently we
* are only interested in that to convert between a NET 1 offset and
* a LBL offset.
*/
private void readLabelOffsets() {
ImgFileReader reader = getReader();
offsets = readOffsets();
int start = netHeader.getRoadDefinitionsStart();
for (int off : offsets) {
reader.position(start + off);
int labelOffset = reader.getu3();
// TODO what if top bit is not set?, there can be more than one name and we will miss them
offsetLabelMap.put(off, labelOffset & 0x7fffff);
}
}
use of uk.me.parabola.imgfmt.app.ImgFileReader in project mkgmap by openstreetmap.
the class NETFileReader method getRoads.
/**
* Get the list of roads from the net section.
*
* Saving the bare minimum that is needed, please improve.
* @return A list of RoadDefs. Note that currently not everything is
* populated in the road def so it can't be written out as is.
*/
public List<RoadDef> getRoads() {
ImgFileReader reader = getReader();
int start = netHeader.getRoadDefinitionsStart();
List<RoadDef> roads = new ArrayList<RoadDef>();
int record = 0;
for (int off : offsets) {
reader.position(start + off);
RoadDef road = new RoadDef(++record, off, null);
readLabels(reader, road);
byte netFlags = reader.get();
/*int len =*/
reader.getu3();
int[] counts = new int[24];
int level = 0;
while (level < 24) {
int n = reader.get();
counts[level++] = (n & 0x7f);
if ((n & 0x80) != 0)
break;
}
for (int i = 0; i < level; i++) {
int c = counts[i];
for (int j = 0; j < c; j++) {
/*byte b =*/
reader.get();
/*char sub =*/
reader.getChar();
}
}
if ((netFlags & RoadDef.NET_FLAG_ADDRINFO) != 0) {
char flags2 = reader.getChar();
int zipFlag = (flags2 >> 10) & 0x3;
int cityFlag = (flags2 >> 12) & 0x3;
int numberFlag = (flags2 >> 14) & 0x3;
IntArrayList indexes = new IntArrayList();
fetchZipCityIndexes(reader, zipFlag, zipSize, indexes);
for (int index : indexes) {
road.addZipIfNotPresent(zips.get(index));
}
fetchZipCityIndexes(reader, cityFlag, citySize, indexes);
for (int index : indexes) {
road.addCityIfNotPresent(cities.get(index));
}
fetchNumber(reader, numberFlag);
}
if ((netFlags & RoadDef.NET_FLAG_NODINFO) != 0) {
int nodFlags = reader.get();
int nbytes = nodFlags & 0x3;
if (nbytes > 0) {
/*int nod = */
reader.getUint(nbytes + 1);
}
}
roads.add(road);
}
return roads;
}
Aggregations