Search in sources :

Example 6 with ImgFileWriter

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

the class NODFile method writeBoundary.

/**
 * Write the boundary node table (NOD3).
 */
private void writeBoundary() {
    log.info("writeBoundary");
    Collections.sort(boundary);
    ImgFileWriter writer = new SectionWriter(getWriter(), nodHeader.getBoundarySection());
    boolean debug = log.isDebugEnabled();
    for (RouteNode node : boundary) {
        if (debug)
            log.debug("wrting nod3", writer.position());
        node.writeNod3OrNod4(writer);
    }
    if (debug)
        log.debug("ending nod3", writer.position());
    nodHeader.setBoundarySize(writer.position());
}
Also used : SectionWriter(uk.me.parabola.imgfmt.app.SectionWriter) ImgFileWriter(uk.me.parabola.imgfmt.app.ImgFileWriter) BufferedImgFileWriter(uk.me.parabola.imgfmt.app.BufferedImgFileWriter)

Example 7 with ImgFileWriter

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

the class NODFile method writeRoadData.

/**
 * Write the road data (NOD2).
 */
private void writeRoadData() {
    log.info("writeRoadData");
    ImgFileWriter writer = new SectionWriter(getWriter(), nodHeader.getRoadSection());
    boolean debug = log.isDebugEnabled();
    for (RoadDef rd : roads) {
        if (debug)
            log.debug("wrting nod2", writer.position());
        rd.writeNod2(writer);
    }
    if (debug)
        log.debug("ending nod2", writer.position());
    nodHeader.setRoadSize(writer.position());
}
Also used : SectionWriter(uk.me.parabola.imgfmt.app.SectionWriter) ImgFileWriter(uk.me.parabola.imgfmt.app.ImgFileWriter) BufferedImgFileWriter(uk.me.parabola.imgfmt.app.BufferedImgFileWriter)

Example 8 with ImgFileWriter

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

the class NODFile method writePost.

public void writePost() {
    ImgFileWriter writer = new SectionWriter(getWriter(), nodHeader.getNodeSection());
    for (RouteCenter rc : centers) {
        rc.writePost(writer);
    }
    // Refresh the header
    position(0);
    getHeader().writeHeader(getWriter());
}
Also used : SectionWriter(uk.me.parabola.imgfmt.app.SectionWriter) ImgFileWriter(uk.me.parabola.imgfmt.app.ImgFileWriter) BufferedImgFileWriter(uk.me.parabola.imgfmt.app.BufferedImgFileWriter)

Example 9 with ImgFileWriter

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

the class NODFile method writeHighClassBoundary.

/**
 * Write the high class boundary node table (NOD4).
 * Like NOD3, but contains only nodes on roads with class > 0
 */
private void writeHighClassBoundary() {
    log.info("writeBoundary");
    // Collections.sort(boundary); // already sorted for NOD3
    Section section = nodHeader.getHighClassBoundary();
    int pos = section.getPosition();
    // align on 0x200
    pos = (pos + 0x200) & ~0x1ff;
    int numBytesToWrite = pos - section.getPosition();
    for (int i = 0; i < numBytesToWrite; i++) getWriter().put((byte) 0);
    section.setPosition(pos);
    ImgFileWriter writer = new SectionWriter(getWriter(), section);
    boolean debug = log.isDebugEnabled();
    for (RouteNode node : boundary) {
        if (node.getNodeClass() == 0)
            continue;
        if (debug)
            log.debug("wrting nod4", writer.position());
        node.writeNod3OrNod4(writer);
    }
    if (debug)
        log.debug("ending nod4", writer.position());
    nodHeader.setHighClassBoundarySize(writer.position());
}
Also used : SectionWriter(uk.me.parabola.imgfmt.app.SectionWriter) Section(uk.me.parabola.imgfmt.app.Section) ImgFileWriter(uk.me.parabola.imgfmt.app.ImgFileWriter) BufferedImgFileWriter(uk.me.parabola.imgfmt.app.BufferedImgFileWriter)

Example 10 with ImgFileWriter

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

the class NODFile method writeNodes.

/**
 * Write the nodes (NOD 1).  This is done first as the offsets into
 * this section are needed to write NOD2.
 */
private void writeNodes() {
    ImgFileWriter writer = getWriter();
    nodHeader.setNodeStart(writer.position());
    Section section = nodHeader.getNodeSection();
    writer = new SectionWriter(writer, section);
    int[] classBoundaries = nodHeader.getClassBoundaries();
    for (RouteCenter cp : centers) {
        cp.write(writer, classBoundaries);
    }
    for (int i = 4; i >= 0; --i) {
        if (classBoundaries[i] > writer.position())
            classBoundaries[i] = writer.position();
    }
    nodHeader.setNodeSize(writer.position());
    log.debug("the nod offset", Integer.toHexString(getWriter().position()));
    Section.close(writer);
}
Also used : SectionWriter(uk.me.parabola.imgfmt.app.SectionWriter) Section(uk.me.parabola.imgfmt.app.Section) ImgFileWriter(uk.me.parabola.imgfmt.app.ImgFileWriter) BufferedImgFileWriter(uk.me.parabola.imgfmt.app.BufferedImgFileWriter)

Aggregations

ImgFileWriter (uk.me.parabola.imgfmt.app.ImgFileWriter)13 BufferedImgFileWriter (uk.me.parabola.imgfmt.app.BufferedImgFileWriter)11 SectionWriter (uk.me.parabola.imgfmt.app.SectionWriter)7 Section (uk.me.parabola.imgfmt.app.Section)2 ArrayImgWriter (func.lib.ArrayImgWriter)1 Test (org.junit.Test)1 FileBackedImgFileWriter (uk.me.parabola.imgfmt.app.FileBackedImgFileWriter)1 Label (uk.me.parabola.imgfmt.app.Label)1 TypData (uk.me.parabola.imgfmt.app.typ.TypData)1 TypLine (uk.me.parabola.imgfmt.app.typ.TypLine)1