Search in sources :

Example 1 with DecodedText

use of uk.me.parabola.imgfmt.app.labelenc.DecodedText in project mkgmap by openstreetmap.

the class LBLFileReader method saveLabel.

/**
 * We have a label and we need to save it.
 *
 * @param labelOffset The offset of the label we are about to save.
 * @param currentOffset The current offset that last read from.
 * @param multiplier The label offset multiplier.
 * @return The offset of the next label.
 */
private int saveLabel(int labelOffset, int currentOffset, int multiplier) {
    DecodedText encText = textDecoder.getText();
    String text = encText.getText();
    Label label = new Label(text);
    assert (labelOffset & (multiplier - 1)) == 0;
    int adustedOffset = labelOffset / multiplier;
    label.setOffset(adustedOffset);
    labels.put(adustedOffset, label);
    // inside the decoder.
    return currentOffset + 1 + encText.getOffsetAdjustment();
}
Also used : DecodedText(uk.me.parabola.imgfmt.app.labelenc.DecodedText) Label(uk.me.parabola.imgfmt.app.Label)

Example 2 with DecodedText

use of uk.me.parabola.imgfmt.app.labelenc.DecodedText 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()]);
}
Also used : CharacterDecoder(uk.me.parabola.imgfmt.app.labelenc.CharacterDecoder) DecodedText(uk.me.parabola.imgfmt.app.labelenc.DecodedText) ArrayList(java.util.ArrayList) ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader) CodeFunctions(uk.me.parabola.imgfmt.app.labelenc.CodeFunctions)

Aggregations

DecodedText (uk.me.parabola.imgfmt.app.labelenc.DecodedText)2 ArrayList (java.util.ArrayList)1 BufferedImgFileReader (uk.me.parabola.imgfmt.app.BufferedImgFileReader)1 ImgFileReader (uk.me.parabola.imgfmt.app.ImgFileReader)1 Label (uk.me.parabola.imgfmt.app.Label)1 CharacterDecoder (uk.me.parabola.imgfmt.app.labelenc.CharacterDecoder)1 CodeFunctions (uk.me.parabola.imgfmt.app.labelenc.CodeFunctions)1