Search in sources :

Example 6 with ImgFileReader

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);
        }
    }
}
Also used : ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Example 7 with ImgFileReader

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();
}
Also used : ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Example 8 with ImgFileReader

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);
        }
    }
}
Also used : ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Example 9 with ImgFileReader

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);
    }
}
Also used : ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Example 10 with ImgFileReader

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;
}
Also used : ArrayList(java.util.ArrayList) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList)

Aggregations

BufferedImgFileReader (uk.me.parabola.imgfmt.app.BufferedImgFileReader)23 ImgFileReader (uk.me.parabola.imgfmt.app.ImgFileReader)23 Label (uk.me.parabola.imgfmt.app.Label)7 ArrayList (java.util.ArrayList)6 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)2 POIRecord (uk.me.parabola.imgfmt.app.lbl.POIRecord)2 HashSet (java.util.HashSet)1 Section (uk.me.parabola.imgfmt.app.Section)1 CharacterDecoder (uk.me.parabola.imgfmt.app.labelenc.CharacterDecoder)1 CodeFunctions (uk.me.parabola.imgfmt.app.labelenc.CodeFunctions)1 DecodedText (uk.me.parabola.imgfmt.app.labelenc.DecodedText)1