use of uk.me.parabola.imgfmt.app.net.Numbers in project mkgmap by openstreetmap.
the class RoadHelper method convertNodesForHouseNumbers.
/**
* Make sure that each node that is referenced by the house
* numbers is a number node. Some of them will later be changed
* to routing nodes.
* Only called if numbers is non-null and not empty.
*/
private void convertNodesForHouseNumbers(MapRoad road) {
int rNodNumber = 0;
for (Numbers n : numbers) {
int node = n.getNodeNumber();
n.setIndex(rNodNumber++);
road.getPoints().get(node).setNumberNode(true);
}
}
use of uk.me.parabola.imgfmt.app.net.Numbers in project mkgmap by openstreetmap.
the class MapBuilder method processRoads.
private void processRoads(Map map, MapDataSource src) {
LBLFile lbl = map.getLblFile();
MapPoint searchPoint = new MapPoint();
for (MapLine line : src.getLines()) {
if (line.isRoad()) {
String cityName = line.getCity();
String cityCountryName = line.getCountry();
String cityRegionName = line.getRegion();
String zipStr = line.getZip();
if (cityName == null && locationAutofill.contains("nearest")) {
// Get name of next city if untagged
searchPoint.setLocation(line.getLocation());
MapPoint nextCity = locator.findNextPoint(searchPoint);
if (nextCity != null) {
cityName = nextCity.getCity();
// city/region/country fields should match to the found city
cityCountryName = nextCity.getCountry();
cityRegionName = nextCity.getRegion();
// use the zip code only if no zip code is known
if (zipStr == null)
zipStr = nextCity.getZip();
}
}
MapRoad road = (MapRoad) line;
road.resetImgData();
City roadCity = calcCity(lbl, cityName, cityRegionName, cityCountryName);
if (roadCity != null)
road.addRoadCity(roadCity);
if (zipStr != null) {
road.addRoadZip(lbl.createZip(zipStr));
}
List<Numbers> numbers = road.getRoadDef().getNumbersList();
if (numbers != null) {
for (Numbers num : numbers) {
for (int i = 0; i < 2; i++) {
boolean left = (i == 0);
ZipCodeInfo zipInfo = num.getZipCodeInfo(left);
if (zipInfo != null && zipInfo.getZipCode() != null) {
Zip zip = zipInfo.getImgZip();
if (zipInfo.getImgZip() == null) {
zip = lbl.createZip(zipInfo.getZipCode());
zipInfo.setImgZip(zip);
}
if (zip != null)
road.addRoadZip(zip);
}
CityInfo cityInfo = num.getCityInfo(left);
if (cityInfo != null) {
City city = cityInfo.getImgCity();
if (city == null) {
city = calcCity(lbl, cityInfo.getCity(), cityInfo.getRegion(), cityInfo.getCountry());
cityInfo.setImgCity(city);
}
if (city != null)
road.addRoadCity(city);
}
}
}
}
}
}
}
use of uk.me.parabola.imgfmt.app.net.Numbers 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);
}
}
use of uk.me.parabola.imgfmt.app.net.Numbers in project mkgmap by openstreetmap.
the class NumberException method readSingleSide.
/**
* If the road has numbers on just one side, then there is a shortened reading routine.
* The left variables are mostly used during reading regardless of which side of the
* road has numbers. Make everything work here.
* @param numbers The output list that the number record should be added to.
*/
private void readSingleSide(List<Numbers> numbers) {
rightBase = leftBase;
rightStart = leftStart;
rightEnd = leftEnd;
rightLastEndDiff = leftLastEndDiff;
adjustValues();
Numbers n = new Numbers();
n.setIndex(nodeCounter);
if (leftStyle == NONE)
n.setNumbers(Numbers.RIGHT, rightStyle, rightStart, rightEnd);
else
n.setNumbers(Numbers.LEFT, leftStyle, leftStart, leftEnd);
numbers.add(n);
nodeCounter++;
}
use of uk.me.parabola.imgfmt.app.net.Numbers in project mkgmap by openstreetmap.
the class NumberException method fetchNumbers.
/**
* Read the house numbers for a stretch of road.
*
* The start and end positions of the the left hand side of the road is first, followed
* by the right hand side of the road.
*
* The differences to the last point are stored. It is also possible to
* @param numbers When numbers are read, they are saved here.
*/
private void fetchNumbers(List<Numbers> numbers) {
// If one side has no numbers, then there is only one set of numbers to calculate, but
// changes to base are applied to both sides.
boolean doSingleSide = (leftStyle == NONE || rightStyle == NONE);
if (leftStyle == NONE)
leftBase = rightBase;
// Check for command to copy the base number
boolean doSameBase = false;
if (!doSingleSide) {
doSameBase = br.get1();
if (doSameBase)
copyBase();
}
// int abc = br.get(3);
boolean doRightOverride = false;
if (!doSingleSide)
doRightOverride = !br.get1();
boolean doReadStart = !br.get1();
boolean doReadEnd = !br.get1();
// item.addText("cmd: fetch numbers abc: %x", abc);
int startDiff = 0, endDiff = leftLastEndDiff;
if (doReadStart) {
startDiff = startReader.read();
}
if (doReadEnd) {
endDiff = endReader.read();
}
leftStart = leftBase + startDiff;
leftEnd = leftStart + endDiff;
leftBase = leftEnd;
leftLastEndDiff = endDiff;
if (doSingleSide) {
readSingleSide(numbers);
restoreReaders();
return;
}
// start diff falls through at least when doSameBase is in force
if (!doSameBase)
startDiff = 0;
// default to the saved value.
if (doRightOverride || !doReadEnd)
endDiff = rightLastEndDiff;
doReadStart = false;
doReadEnd = false;
if (!doSameBase)
doReadStart = !br.get1();
if (doRightOverride)
doReadEnd = !br.get1();
if (doReadStart)
startDiff = startReader.read();
if (doReadEnd)
endDiff = endReader.read();
rightStart = rightBase + startDiff;
rightEnd = rightStart + endDiff;
rightBase = rightEnd;
rightLastEndDiff = endDiff;
adjustValues();
Numbers n = new Numbers();
n.setIndex(nodeCounter);
n.setNumbers(Numbers.LEFT, leftStyle, leftStart, leftEnd);
n.setNumbers(Numbers.RIGHT, rightStyle, rightStart, rightEnd);
numbers.add(n);
nodeCounter++;
restoreReaders();
}
Aggregations