Search in sources :

Example 11 with Label

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

the class Subdivision method createPolygon.

public Polygon createPolygon(String name) {
    Label label = lblFile.newLabel(name);
    Polygon pg = new Polygon(this);
    pg.setLabel(label);
    return pg;
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 12 with Label

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

the class TREFile method writeCopyrights.

/**
 * Write out the copyrights.  This is just a list of pointers to strings
 * in the label section basically.
 */
private void writeCopyrights() {
    // Write out the pointers to the labels that hold the copyright strings
    header.setCopyrightPos(position());
    ImgFileWriter writer = getWriter();
    for (Label l : copyrights) {
        header.incCopyrightSize();
        writer.put3(l.getOffset());
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) BufferedImgFileWriter(uk.me.parabola.imgfmt.app.BufferedImgFileWriter) ImgFileWriter(uk.me.parabola.imgfmt.app.ImgFileWriter)

Example 13 with Label

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

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

the class NETFileReader method readLabels.

private void readLabels(ImgFileReader reader, RoadDef road) {
    for (int i = 0; i < 4; i++) {
        int lab = reader.getu3();
        Label label = labels.fetchLabel(lab & 0x7fffff);
        road.addLabel(label);
        if ((lab & 0x800000) != 0)
            break;
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 15 with Label

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

the class Polyline method write.

/**
 * Format and write the contents of the object to the given
 * file.
 *
 * @param file A reference to the file that should be written to.
 */
public void write(ImgFileWriter file) {
    // Prepare for writing by doing all the required calculations.
    LinePreparer w;
    try {
        // Prepare the information that we need.
        w = new LinePreparer(this);
    } catch (AssertionError ae) {
        log.error("Problem writing line (" + getClass() + ") of type 0x" + Integer.toHexString(getType()) + " containing " + points.size() + " points and starting at " + points.get(0).toOSMURL());
        log.error("  Subdivision shift is " + getSubdiv().getShift() + " and its centre is at " + getSubdiv().getCenter().toOSMURL());
        log.error("  " + ae.getMessage());
        if (roaddef != null)
            log.error("  Way is " + roaddef);
        return;
    }
    int minPointsRequired = (this instanceof Polygon) ? 3 : 2;
    BitWriter bw = w.makeShortestBitStream(minPointsRequired);
    if (bw == null) {
        log.error("Level " + getSubdiv().getZoom().getLevel() + " " + ((this instanceof Polygon) ? "polygon" : "polyline") + " has less than " + minPointsRequired + " points, discarding");
        return;
    }
    // The type of feature, also contains a couple of flags hidden inside.
    byte b1 = (byte) getType();
    if (direction)
        // Polylines only.
        b1 |= FLAG_DIR;
    // allow for the sizes
    int blen = bw.getLength() - 1;
    assert blen > 0 : "zero length bitstream";
    assert blen < 0x10000 : "bitstream too long " + blen;
    if (blen >= 0x100)
        b1 |= FLAG_2BYTE_LEN;
    file.put(b1);
    // The label, contains a couple of flags within it.
    int loff = getLabel().getOffset();
    if (w.isExtraBit())
        loff |= FLAG_EXTRABIT;
    // so that we can change it to the index in the net section
    if (roaddef != null) {
        roaddef.addLabel(getLabel());
        roaddef.addOffsetTarget(file.position(), FLAG_NETINFO | (loff & FLAG_EXTRABIT));
        // also add ref label(s) if present
        if (refLabels != null)
            for (Label rl : refLabels) roaddef.addLabel(rl);
    }
    file.put3(loff);
    // The delta of the longitude from the subdivision centre point
    // note that this has already been calculated.
    file.putChar((char) getDeltaLong());
    file.putChar((char) getDeltaLat());
    if (log.isDebugEnabled())
        log.debug("out center", getDeltaLat(), getDeltaLong());
    if (blen < 0x100)
        file.put((byte) (blen & 0xff));
    else
        file.putChar((char) (blen & 0xffff));
    file.put(bw.getBytes(), 0, blen + 1);
}
Also used : BitWriter(uk.me.parabola.imgfmt.app.BitWriter) Label(uk.me.parabola.imgfmt.app.Label)

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