use of uk.me.parabola.mkgmap.general.ZipCodeInfo in project mkgmap by openstreetmap.
the class CityZipWriter method compile.
public boolean compile(List<Numbers> numbers) {
try {
// left and right entry in zip or city table
// current num
int[] indexes = { defaultIndex, defaultIndex };
// previous num
int[] refIndexes = { defaultIndex, defaultIndex };
int lastEncodedNodeIndex = -1;
boolean needsWrite = false;
for (Numbers num : numbers) {
for (int side = 0; side < 2; side++) {
indexes[side] = defaultIndex;
boolean left = (side == 0);
switch(type) {
case "zip":
ZipCodeInfo zipInfo = num.getZipCodeInfo(left);
if (zipInfo != null) {
if (zipInfo.getImgZip() != null) {
indexes[side] = zipInfo.getImgZip().getIndex();
}
}
break;
case "city":
CityInfo cityInfo = num.getCityInfo(left);
if (cityInfo != null) {
if (cityInfo.getImgCity() != null) {
indexes[side] = cityInfo.getImgCity().getIndex();
}
}
break;
default:
break;
}
}
if (indexes[0] == refIndexes[0] && indexes[1] == refIndexes[1])
continue;
needsWrite = true;
if (num.getIndex() > 0) {
int range = num.getIndex() - 1;
if (lastEncodedNodeIndex > 0)
range -= lastEncodedNodeIndex;
encode(range, refIndexes);
}
refIndexes[0] = indexes[0];
refIndexes[1] = indexes[1];
lastEncodedNodeIndex = num.getIndex();
}
if (needsWrite) {
int lastIndexWithNumbers = numbers.get(numbers.size() - 1).getIndex();
int range = lastIndexWithNumbers - lastEncodedNodeIndex;
encode(range, indexes);
} else {
// probably not needed
buf.reset();
}
} catch (Abandon e) {
return false;
}
return true;
}
use of uk.me.parabola.mkgmap.general.ZipCodeInfo in project mkgmap by openstreetmap.
the class RoadDef method resetImgData.
public void resetImgData() {
zipList = null;
cityList = null;
if (numbersList != null) {
for (Numbers num : numbersList) {
for (int side = 0; side < 2; side++) {
boolean left = side == 0;
CityInfo ci = num.getCityInfo(left);
if (ci != null)
ci.setImgCity(null);
ZipCodeInfo z = num.getZipCodeInfo(left);
if (z != null)
z.setImgZip(null);
}
}
}
}
Aggregations