use of uk.me.parabola.imgfmt.app.lbl.POIRecord 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.lbl.POIRecord in project mkgmap by openstreetmap.
the class MapBuilder method processExit.
private void processExit(Map map, MapExitPoint mep) {
LBLFile lbl = map.getLblFile();
String ref = mep.getMotorwayRef();
String OSMId = mep.getOSMId();
if (ref != null) {
Highway hw = highways.get(ref);
if (hw == null)
hw = makeHighway(map, ref);
if (hw == null) {
log.warn("Can't create exit", mep.getName(), "(OSM id", OSMId, ") on unknown highway", ref);
return;
}
String exitName = mep.getName();
String exitTo = mep.getTo();
Exit exit = new Exit(hw);
String facilityDescription = mep.getFacilityDescription();
log.info("Creating", ref, "exit", exitName, "(OSM id", OSMId + ") to", exitTo, "with facility", ((facilityDescription == null) ? "(none)" : facilityDescription));
if (facilityDescription != null) {
// description is TYPE,DIR,FACILITIES,LABEL
// (same as Polish Format)
String[] atts = facilityDescription.split(",");
int type = 0;
if (atts.length > 0)
type = Integer.decode(atts[0]);
char direction = ' ';
if (atts.length > 1) {
direction = atts[1].charAt(0);
if (direction == '\'' && atts[1].length() > 1)
direction = atts[1].charAt(1);
}
int facilities = 0x0;
if (atts.length > 2)
facilities = Integer.decode(atts[2]);
String description = "";
if (atts.length > 3)
description = atts[3];
// FIXME - handle multiple facilities?
boolean last = true;
ExitFacility ef = lbl.createExitFacility(type, direction, facilities, description, last);
exit.addFacility(ef);
}
mep.setExit(exit);
POIRecord r = lbl.createExitPOI(exitName, exit);
if (exitTo != null) {
Label ed = lbl.newLabel(exitTo);
exit.setDescription(ed);
}
poimap.put(mep, r);
// FIXME - set bottom bits of
// type to reflect facilities available?
}
}
use of uk.me.parabola.imgfmt.app.lbl.POIRecord in project mkgmap by openstreetmap.
the class MdrBuilder method addPoints.
/**
* Read points from this map and add them to the index.
* @param mr The currently open map.
* @param maps Maps of regions, cities countries etc.
*/
private void addPoints(MapReader mr, AreaMaps maps) {
List<Point> list = mr.pointsForLevel(0, MapReader.WITHOUT_EXT_TYPE_DATA);
for (Point p : list) {
Label label = p.getLabel();
if (p.getNumber() > 256) {
continue;
}
Mdr5Record mdrCity = null;
boolean isCity;
if (p.getType() >= 0x1 && p.getType() <= 0x11) {
// This is itself a city, it gets a reference to its own MDR 5 record.
// and we also use it to set the name of the city.
mdrCity = maps.cities.get((p.getSubdiv().getNumber() << 8) + p.getNumber());
if (mdrCity != null) {
mdrCity.setLblOffset(label.getOffset());
mdrCity.setName(label.getText());
}
isCity = true;
} else {
// This is not a city, but we have information about which city
// it is in. If so then add the mdr5 record number of the city.
POIRecord poi = p.getPOIRecord();
City c = poi.getCity();
if (c != null)
mdrCity = getMdr5FromCity(maps, c);
isCity = false;
}
if (label != null && !label.getText().trim().isEmpty())
mdrFile.addPoint(p, mdrCity, isCity);
}
}
use of uk.me.parabola.imgfmt.app.lbl.POIRecord in project mkgmap by openstreetmap.
the class RGNFileReader method fetchPointsCommon.
/**
* The indexed points and the points sections are both read just the same.
*/
private void fetchPointsCommon(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);
byte t = reader.get();
int val = reader.getu3();
boolean hasSubtype = false;
if ((val & 0x800000) != 0)
hasSubtype = true;
boolean hasPoi = false;
if ((val & 0x400000) != 0)
hasPoi = true;
Label l;
int labelOffset = val & 0x3fffff;
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);
p.setDeltaLong((short) reader.getChar());
p.setDeltaLat((short) reader.getChar());
if (hasSubtype) {
byte st = reader.get();
p.setType(((t & 0xff) << 8) | (st & 0xff));
// p.setHasSubtype(true);
} else {
p.setType(t & 0xff);
}
p.setNumber(number++);
points.add(p);
}
}
use of uk.me.parabola.imgfmt.app.lbl.POIRecord in project mkgmap by openstreetmap.
the class MapBuilder method processPOIs.
private void processPOIs(Map map, MapDataSource src) {
LBLFile lbl = map.getLblFile();
boolean checkedForPoiDispFlag = false;
for (MapPoint p : src.getPoints()) {
// special handling for highway exits
if (p.isExit()) {
processExit(map, (MapExitPoint) p);
} else // * all POIs except roads in case the no-poi-address option is set
if (!p.isCity() && !p.hasExtendedType() && poiAddresses) {
String countryStr = p.getCountry();
String regionStr = p.getRegion();
String zipStr = p.getZip();
String cityStr = p.getCity();
if (locationAutofill.contains("nearest") && (countryStr == null || regionStr == null || (zipStr == null && cityStr == null))) {
MapPoint nextCity = locator.findNearbyCityByName(p);
if (nextCity == null)
nextCity = locator.findNextPoint(p);
if (nextCity != null) {
if (countryStr == null)
countryStr = nextCity.getCountry();
if (regionStr == null)
regionStr = nextCity.getRegion();
if (zipStr == null) {
String cityZipStr = nextCity.getZip();
if (cityZipStr != null && cityZipStr.indexOf(',') < 0)
zipStr = cityZipStr;
}
if (cityStr == null)
cityStr = nextCity.getCity();
}
}
if (countryStr != null && !checkedForPoiDispFlag) {
// Different countries require different address notation
poiDisplayFlags = locator.getPOIDispFlag(countryStr);
checkedForPoiDispFlag = true;
}
POIRecord r = lbl.createPOI(p.getName());
if (cityStr != null || regionStr != null || countryStr != null) {
r.setCity(calcCity(lbl, cityStr, regionStr, countryStr));
}
if (zipStr != null) {
Zip zip = lbl.createZip(zipStr);
r.setZip(zip);
}
if (p.getStreet() != null) {
Label streetName = lbl.newLabel(p.getStreet());
r.setStreetName(streetName);
}
String houseNumber = p.getHouseNumber();
if (houseNumber != null && !houseNumber.isEmpty()) {
if (!r.setSimpleStreetNumber(houseNumber))
r.setComplexStreetNumber(lbl.newLabel(houseNumber));
}
String phone = p.getPhone();
if (phone != null && !phone.isEmpty()) {
if (!r.setSimplePhoneNumber(phone))
r.setComplexPhoneNumber(lbl.newLabel(phone));
}
poimap.put(p, r);
}
}
lbl.allPOIsDone();
}
Aggregations