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