use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class PlacesFile method createZip.
Zip createZip(String code) {
Zip z = postalCodes.get(code);
if (z == null) {
z = new Zip();
Label l = lblFile.newLabel(code);
z.setLabel(l);
zipList.add(z);
postalCodes.put(code, z);
}
return z;
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class MDRFile method addPoint.
public void addPoint(Point point, Mdr5Record city, boolean isCity) {
assert currentMap > 0;
int fullType = point.getType();
if (!MdrUtils.canBeIndexed(fullType))
return;
if (!poiExclTypes.isEmpty()) {
int t = (fullType < 0xff) ? fullType << 8 : fullType;
if (poiExclTypes.contains(t))
return;
}
Label label = point.getLabel();
String name = label.getText();
int strOff = createString(name);
Mdr11Record poi = mdr11.addPoi(currentMap, point, name, strOff);
poi.setCity(city);
poi.setIsCity(isCity);
poi.setType(fullType);
mdr4.addType(fullType);
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class LBLFileReader method saveLabel.
/**
* We have a label and we need to save it.
*
* @param labelOffset The offset of the label we are about to save.
* @param currentOffset The current offset that last read from.
* @param multiplier The label offset multiplier.
* @return The offset of the next label.
*/
private int saveLabel(int labelOffset, int currentOffset, int multiplier) {
DecodedText encText = textDecoder.getText();
String text = encText.getText();
Label label = new Label(text);
assert (labelOffset & (multiplier - 1)) == 0;
int adustedOffset = labelOffset / multiplier;
label.setOffset(adustedOffset);
labels.put(adustedOffset, label);
// inside the decoder.
return currentOffset + 1 + encText.getOffsetAdjustment();
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class RGNFileReader method fetchPointsCommonExtType.
/**
* The indexed points and the points sections are both read just the same.
*/
private void fetchPointsCommonExtType(Subdivision sd, long start, long end, List<Point> points) {
position(start);
ImgFileReader reader = getReader();
int number = points.size() + 1;
while (position() < end) {
Point p = new Point(sd);
int type = reader.get() << 8;
byte b = reader.get();
type |= 0x10000 + (b & 0x1f);
p.setType(type);
p.setDeltaLong((short) reader.getChar());
p.setDeltaLat((short) reader.getChar());
Label l;
if ((b & 0x20) != 0) {
int labelOffset = reader.getu3();
boolean hasPoi = (labelOffset & 0x400000) != 0;
if (hasPoi) {
POIRecord record = lblFile.fetchPoi(labelOffset);
if (record != null) {
l = record.getNameLabel();
p.setPOIRecord(record);
} else
l = lblFile.fetchLabel(0);
} else {
l = lblFile.fetchLabel(labelOffset);
}
p.setLabel(l);
}
if ((b & 0x80) != 0) {
extractExtraBytes(reader, p);
}
p.setNumber(number++);
points.add(p);
}
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class RGNFileReader method readLineCommonExtType.
/**
* Common code to read extended type lines or polygons for a given sub division.
* @param reader The reader for the img file.
* @param div The subdivision.
* @param line The line or shape that is to be populated.
*/
private void readLineCommonExtType(ImgFileReader reader, Subdivision div, Polyline line) {
int type = reader.get();
type = (type & 0xff) << 8;
byte b1 = reader.get();
boolean hasExtraBytes = (b1 & 0x80) != 0;
boolean hasLabel = (b1 & 0x20) != 0;
type |= 0x10000 + (b1 & 0x1f);
line.setType(type);
line.setDeltaLong((short) reader.getChar());
line.setDeltaLat((short) reader.getChar());
b1 = reader.get();
int len;
// one byte or two byte length field?
if ((b1 & 0x01) != 0) {
len = (b1 >> 1) & 0x7f;
assert len < 0x7f;
} else {
byte b2 = reader.get();
len = (((b2 & 0xff) << 8) + (b1 & 0xff)) >> 2;
assert len >= 0x7f;
}
// the encoded value includes the base field
--len;
assert len > 0;
int base = reader.get();
byte[] bitstream = reader.get(len);
BitReader br = new BitReader(bitstream);
// This reads the bit stream and adds all the points found,
readBitStream(br, div, line, false, len, base);
if (hasLabel) {
int labelOffset = reader.getu3();
Label label;
if ((labelOffset & 0x800000) == 0) {
label = lblFile.fetchLabel(labelOffset & 0x7fffff);
} else {
int netoff = labelOffset & 0x3fffff;
labelOffset = netFile.getLabelOffset(netoff);
label = lblFile.fetchLabel(labelOffset);
RoadDef roadDef = new RoadDef(0, netoff, label.getText());
line.setRoadDef(roadDef);
}
line.setLabel(label);
}
if (hasExtraBytes) {
extractExtraBytes(reader, line);
}
}
Aggregations