Search in sources :

Example 1 with ImgFileReader

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

Example 2 with ImgFileReader

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

Example 3 with ImgFileReader

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()]);
}
Also used : ArrayList(java.util.ArrayList) Label(uk.me.parabola.imgfmt.app.Label) ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader) Section(uk.me.parabola.imgfmt.app.Section)

Example 4 with ImgFileReader

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

Example 5 with ImgFileReader

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()]);
}
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

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