use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class LBLFileReader method readPoiInfo.
/**
* Read all the POI information.
* This will create a POIRecord, but we just get the name at the minute.
*
* TODO: not finished
*/
private void readPoiInfo() {
ImgFileReader reader = getReader();
PlacesHeader placeHeader = header.getPlaceHeader();
int poiGlobalFlags = placeHeader.getPOIGlobalFlags();
int start = placeHeader.getPoiPropertiesStart();
int end = placeHeader.getPoiPropertiesEnd();
reader.position(start);
PoiMasks localMask = makeLocalMask(placeHeader);
while (reader.position() < end) {
int poiOffset = position() - start;
int val = reader.getu3();
int labelOffset = val & 0x3fffff;
boolean override = (val & 0x800000) != 0;
POIRecord poi = new POIRecord();
poi.setLabel(fetchLabel(labelOffset));
// We have what we want, but now have to find the start of the
// next record as they are not fixed length.
int flags;
boolean hasStreet;
boolean hasStreetNum;
boolean hasCity;
boolean hasZip;
boolean hasPhone;
boolean hasHighwayExit;
boolean hasTides;
if (override) {
flags = reader.get();
hasStreetNum = (flags & localMask.streetNumMask) != 0;
hasStreet = (flags & localMask.streetMask) != 0;
hasCity = (flags & localMask.cityMask) != 0;
hasZip = (flags & localMask.zipMask) != 0;
hasPhone = (flags & localMask.phoneMask) != 0;
hasHighwayExit = (flags & localMask.highwayExitMask) != 0;
hasTides = (flags & localMask.tidesMask) != 0;
} else {
flags = poiGlobalFlags;
hasStreetNum = (flags & POIRecord.HAS_STREET_NUM) != 0;
hasStreet = (flags & POIRecord.HAS_STREET) != 0;
hasCity = (flags & POIRecord.HAS_CITY) != 0;
hasZip = (flags & POIRecord.HAS_ZIP) != 0;
hasPhone = (flags & POIRecord.HAS_PHONE) != 0;
hasHighwayExit = (flags & POIRecord.HAS_EXIT) != 0;
hasTides = (flags & POIRecord.HAS_TIDE_PREDICTION) != 0;
}
if (hasStreetNum) {
byte b = reader.get();
if ((b & 0x80) == 0) {
int mpoffset = (b << 16) & 0xff0000;
mpoffset |= reader.getChar() & 0xffff;
poi.setComplexStreetNumber(fetchLabel(mpoffset));
} else {
poi.setSimpleStreetNumber(reader.getBase11str(b, '-'));
}
}
if (hasStreet) {
// label for street
int streetNameOffset = reader.getu3();
Label label = fetchLabel(streetNameOffset);
poi.setStreetName(label);
}
if (hasCity) {
int cityIndex = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumCities()));
poi.setCity(cities.get(cityIndex - 1));
}
if (hasZip) {
int zipIndex = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumZips()));
poi.setZip(zips.get(zipIndex - 1));
}
if (hasPhone) {
byte b = reader.get();
if ((b & 0x80) == 0) {
// Yes this is a bit strange it is a byte followed by a char
int mpoffset = (b << 16) & 0xff0000;
mpoffset |= reader.getChar() & 0xffff;
poi.setComplexPhoneNumber(fetchLabel(mpoffset));
} else {
poi.setSimplePhoneNumber(reader.getBase11str(b, '-'));
}
}
if (hasHighwayExit) {
int lblinfo = reader.getu3();
int highwayLabelOffset = lblinfo & 0x3FFFF;
boolean indexed = (lblinfo & 0x800000) != 0;
boolean overnightParking = (lblinfo & 0x400000) != 0;
int highwayIndex = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumHighways()));
if (indexed) {
int eidx = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumExits()));
}
}
if (hasTides) {
System.out.println("Map has tide prediction, please implement!");
}
pois.put(poiOffset, poi);
}
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class LBLFileReader method readRegions.
/**
* Read an cache the regions. These are used when reading cities.
*/
private void readRegions() {
ImgFileReader reader = getReader();
PlacesHeader placeHeader = header.getPlaceHeader();
int start = placeHeader.getRegionsStart();
int end = placeHeader.getRegionsEnd();
regions.add(null);
reader.position(start);
int index = 1;
while (reader.position() < end) {
int country = reader.getChar();
int offset = reader.getu3();
Label label = fetchLabel(offset);
if (label != null) {
Region region = new Region(countries.get(country));
region.setIndex(index);
region.setLabel(label);
regions.add(region);
}
index++;
}
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class PlacesFile method createExitPOI.
POIRecord createExitPOI(String name, Exit exit) {
assert !poisClosed;
// TODO...
POIRecord p = new POIRecord();
Label l = lblFile.newLabel(name);
p.setLabel(l);
p.setExit(exit);
pois.add(p);
return p;
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class PlacesFile method createCity.
City createCity(Region region, String name, boolean unique) {
String uniqueCityName = name.toUpperCase() + "_R" + region.getLabel().getOffset();
// if unique is true, make sure that the name really is unique
if (unique && cities.get(uniqueCityName) != null) {
do {
// add semi-random suffix.
uniqueCityName += "_" + random.nextInt(0x10000);
} while (cities.get(uniqueCityName) != null);
}
City c = null;
if (!unique)
c = cities.get(uniqueCityName);
if (c == null) {
c = new City(region);
Label l = lblFile.newLabel(name);
c.setLabel(l);
cityList.add(c);
cities.put(uniqueCityName, c);
assert cityList.size() == cities.size() : " cityList and cities are different lengths after inserting " + name + " and " + uniqueCityName;
}
return c;
}
use of uk.me.parabola.imgfmt.app.Label in project mkgmap by openstreetmap.
the class PlacesFile method createExitFacility.
public ExitFacility createExitFacility(int type, char direction, int facilities, String description, boolean last) {
Label d = lblFile.newLabel(description);
ExitFacility ef = new ExitFacility(type, direction, facilities, d, last, exitFacilities.size() + 1);
exitFacilities.add(ef);
return ef;
}
Aggregations