Search in sources :

Example 6 with Label

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

the class PlacesFile method createZip.

Zip createZip(String code) {
    Zip z = postalCodes.get(code);
    if (z == null) {
        z = new Zip();
        Label l = lblFile.newLabel(code);
        z.setLabel(l);
        zipList.add(z);
        postalCodes.put(code, z);
    }
    return z;
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 7 with Label

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

the class MDRFile method addPoint.

public void addPoint(Point point, Mdr5Record city, boolean isCity) {
    assert currentMap > 0;
    int fullType = point.getType();
    if (!MdrUtils.canBeIndexed(fullType))
        return;
    if (!poiExclTypes.isEmpty()) {
        int t = (fullType < 0xff) ? fullType << 8 : fullType;
        if (poiExclTypes.contains(t))
            return;
    }
    Label label = point.getLabel();
    String name = label.getText();
    int strOff = createString(name);
    Mdr11Record poi = mdr11.addPoi(currentMap, point, name, strOff);
    poi.setCity(city);
    poi.setIsCity(isCity);
    poi.setType(fullType);
    mdr4.addType(fullType);
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) Point(uk.me.parabola.imgfmt.app.trergn.Point)

Example 8 with Label

use of uk.me.parabola.imgfmt.app.Label 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 9 with Label

use of uk.me.parabola.imgfmt.app.Label 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 10 with Label

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

the class RGNFileReader method readLineCommonExtType.

/**
 * Common code to read extended type lines or polygons for a given sub division.
 * @param reader The reader for the img file.
 * @param div The subdivision.
 * @param line The line or shape that is to be populated.
 */
private void readLineCommonExtType(ImgFileReader reader, Subdivision div, Polyline line) {
    int type = reader.get();
    type = (type & 0xff) << 8;
    byte b1 = reader.get();
    boolean hasExtraBytes = (b1 & 0x80) != 0;
    boolean hasLabel = (b1 & 0x20) != 0;
    type |= 0x10000 + (b1 & 0x1f);
    line.setType(type);
    line.setDeltaLong((short) reader.getChar());
    line.setDeltaLat((short) reader.getChar());
    b1 = reader.get();
    int len;
    // one byte or two byte length field?
    if ((b1 & 0x01) != 0) {
        len = (b1 >> 1) & 0x7f;
        assert len < 0x7f;
    } else {
        byte b2 = reader.get();
        len = (((b2 & 0xff) << 8) + (b1 & 0xff)) >> 2;
        assert len >= 0x7f;
    }
    // the encoded value includes the base field
    --len;
    assert len > 0;
    int base = reader.get();
    byte[] bitstream = reader.get(len);
    BitReader br = new BitReader(bitstream);
    // This reads the bit stream and adds all the points found,
    readBitStream(br, div, line, false, len, base);
    if (hasLabel) {
        int labelOffset = reader.getu3();
        Label label;
        if ((labelOffset & 0x800000) == 0) {
            label = lblFile.fetchLabel(labelOffset & 0x7fffff);
        } else {
            int netoff = labelOffset & 0x3fffff;
            labelOffset = netFile.getLabelOffset(netoff);
            label = lblFile.fetchLabel(labelOffset);
            RoadDef roadDef = new RoadDef(0, netoff, label.getText());
            line.setRoadDef(roadDef);
        }
        line.setLabel(label);
    }
    if (hasExtraBytes) {
        extractExtraBytes(reader, line);
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) RoadDef(uk.me.parabola.imgfmt.app.net.RoadDef) BitReader(uk.me.parabola.imgfmt.app.BitReader)

Aggregations

Label (uk.me.parabola.imgfmt.app.Label)35 BufferedImgFileReader (uk.me.parabola.imgfmt.app.BufferedImgFileReader)7 ImgFileReader (uk.me.parabola.imgfmt.app.ImgFileReader)7 POIRecord (uk.me.parabola.imgfmt.app.lbl.POIRecord)5 Point (uk.me.parabola.imgfmt.app.trergn.Point)4 ArrayList (java.util.ArrayList)2 BitReader (uk.me.parabola.imgfmt.app.BitReader)2 City (uk.me.parabola.imgfmt.app.lbl.City)2 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)2 RoadDef (uk.me.parabola.imgfmt.app.net.RoadDef)2 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)2 HashMap (java.util.HashMap)1 Random (java.util.Random)1 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)1 BitWriter (uk.me.parabola.imgfmt.app.BitWriter)1 BufferedImgFileWriter (uk.me.parabola.imgfmt.app.BufferedImgFileWriter)1 Exit (uk.me.parabola.imgfmt.app.Exit)1 ImgFileWriter (uk.me.parabola.imgfmt.app.ImgFileWriter)1 Section (uk.me.parabola.imgfmt.app.Section)1 DecodedText (uk.me.parabola.imgfmt.app.labelenc.DecodedText)1