use of uk.me.parabola.imgfmt.app.Section in project mkgmap by openstreetmap.
the class Mdr1SubHeader method writeFileHeader.
protected void writeFileHeader(ImgFileWriter writer) {
writer.putChar((char) HEADER_SIZE);
for (int n = 1; n <= MAX_SECTION; n++) {
Section section = sections[n];
// has the same length as subsection 1.
if (n == 2)
writer.putInt(section.getPosition());
else {
// section.writeSectionInfo(writer);
writer.putInt(section.getPosition());
int size = section.getSize();
if (size == 0)
writer.putInt(0);
else
writer.putInt(size / section.getItemSize());
}
}
}
use of uk.me.parabola.imgfmt.app.Section 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());
}
use of uk.me.parabola.imgfmt.app.Section 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);
}
Aggregations