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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations