use of uk.me.parabola.imgfmt.app.SectionWriter 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.SectionWriter 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);
}
use of uk.me.parabola.imgfmt.app.SectionWriter in project mkgmap by openstreetmap.
the class SRTFile method write.
/**
* Write out the file.
* This file has an unusual layout. There are several header like structures within
* the main body of the file, with the real header being very small.
*/
public void write() {
ImgFileWriter writer = getWriter();
writeDescription(writer);
// Position at the start of the writable area.
position(header.getHeaderLength());
SectionWriter subWriter = header.makeSectionWriter(writer);
int header3Len = sort.getHeader3Len();
if (header3Len == 0)
header3Len = sort.isMulti() ? SRTHeader.HEADER3_MULTI_LEN : SRTHeader.HEADER3_LEN;
subWriter.position(header3Len);
writeSrt4Chars(subWriter);
writeSrt5Expansions(subWriter);
if (sort.isMulti()) {
for (int i = 0; i <= sort.getMaxPage(); i++) srt8Starts.add(-1);
writeSrt8(subWriter);
writeSrt7(subWriter);
}
subWriter.close();
// Header 2 is just after the real header
writer.position(header.getHeaderLength());
header.writeHeader2(writer);
// Header 3 is after the description
writer.position(header.getHeaderLength() + description.length() + 1 + SRTHeader.HEADER2_LEN);
header.writeHeader3(writer);
header.writeHeader(writer);
}
use of uk.me.parabola.imgfmt.app.SectionWriter in project mkgmap by openstreetmap.
the class TYPFile method write.
public void write() {
ImgFileWriter writer = getWriter();
writer.position(TYPHeader.HEADER_LEN);
writeSection(writer, header.getPolygonData(), header.getPolygonIndex(), data.getPolygons());
writeSection(writer, header.getLineData(), header.getLineIndex(), data.getLines());
writeSection(writer, header.getPointData(), header.getPointIndex(), data.getPoints());
SectionWriter subWriter = header.getShapeStacking().makeSectionWriter(writer);
data.getStacking().write(subWriter);
Utils.closeFile(subWriter);
writeSection(writer, header.getIconData(), header.getIconIndex(), data.getIcons());
writeLabels(writer);
writeStrIndex(writer);
writerTypeIndex(writer);
zapZero(header.getShapeStacking(), header.getLabels(), header.getStringIndex(), header.getTypeIndex());
log.debug("syncing TYP file");
position(0);
getHeader().writeHeader(getWriter());
}
use of uk.me.parabola.imgfmt.app.SectionWriter in project mkgmap by openstreetmap.
the class TYPFile method writerTypeIndex.
private void writerTypeIndex(ImgFileWriter in) {
SectionWriter writer = header.getTypeIndex().makeSectionWriter(in);
int psize = Utils.numberToPointerSize(header.getLabels().getSize());
header.getTypeIndex().setItemSize((char) (3 + psize));
for (Map.Entry<Integer, Integer> ent : typeToStr.entrySet()) {
writer.put3(ent.getKey());
writer.putN(psize, ent.getValue());
}
Utils.closeFile(writer);
}
Aggregations