use of uk.me.parabola.imgfmt.app.net.NumberPreparer in project mkgmap by openstreetmap.
the class NumberRangeTest method run.
private void run(String[] strings) {
List<Numbers> numbers = new ArrayList<Numbers>();
for (String s : strings) {
Numbers n = new Numbers(s);
n.setIndex(n.getNodeNumber());
numbers.add(n);
}
NumberPreparer np = new NumberPreparer(numbers);
BitWriter bitWriter = np.fetchBitStream();
bytesUsed += bitWriter.getLength();
// Now read it back in
byte[] bytes = new byte[bitWriter.getLength()];
System.arraycopy(bitWriter.getBytes(), 0, bytes, 0, bytes.length);
NumberReader nr = new NumberReader(new BitReader(bytes));
nr.setNumberOfNodes(numbers.get(numbers.size() - 1).getIndex() + 1);
List<Numbers> list = nr.readNumbers(np.getSwapped());
// Have to fix up the node numbers
for (Numbers n : list) {
n.setNodeNumber(n.getIndex());
}
// Test that they are the same.
String orig = numbers.toString();
String calculated = list.toString();
if (!orig.equals(calculated)) {
System.out.printf("Fail: expecting: %s\n Got: %s\n", orig, calculated);
}
}
Aggregations