use of uk.me.parabola.mkgmap.general.LevelInfo in project mkgmap by openstreetmap.
the class OverviewBuilder method readFileIntoOverview.
/**
* Add an individual .img file to the overview map.
*
* @param finfo Information about an individual map.
*/
private void readFileIntoOverview(FileInfo finfo) throws FileNotFoundException {
addMapCoverageArea(finfo);
MapReader mapReader = null;
String filename = finfo.getFilename();
if (codepage == null) {
codepage = finfo.getCodePage();
}
if (codepage != finfo.getCodePage()) {
System.err.println("WARNING: input file " + filename + " has different code page " + finfo.getCodePage());
}
try {
mapReader = new MapReader(filename);
if (encodingType == null) {
encodingType = mapReader.getEncodingType();
}
if (encodingType != mapReader.getEncodingType()) {
System.err.println("WARNING: input file " + filename + " has different charset type " + encodingType);
}
String[] msgs = mapReader.getCopyrights();
boolean found = false;
for (String[] block : copyrightMsgs) {
if (Arrays.deepEquals(block, msgs)) {
found = true;
break;
}
}
if (!found)
copyrightMsgs.add(msgs);
msgs = finfo.getLicenseInfo();
found = false;
for (String[] block : licenseInfos) {
if (Arrays.deepEquals(block, msgs)) {
found = true;
break;
}
}
if (!found)
licenseInfos.add(msgs);
Zoom[] levels = mapReader.getLevels();
if (wantedLevels == null) {
LevelInfo[] mapLevels;
if (isOverviewImg(filename)) {
mapLevels = new LevelInfo[levels.length - 1];
for (int i = 1; i < levels.length; i++) {
mapLevels[i - 1] = new LevelInfo(levels[i].getLevel(), levels[i].getResolution());
}
} else {
mapLevels = new LevelInfo[1];
mapLevels[0] = new LevelInfo(levels[1].getLevel(), levels[1].getResolution());
}
wantedLevels = mapLevels;
}
if (isOverviewImg(filename)) {
readPoints(mapReader);
readLines(mapReader);
readShapes(mapReader);
}
} catch (FileNotFoundException e) {
throw new ExitException("Could not open " + filename + " when creating overview file");
} finally {
Utils.closeFile(mapReader);
}
}
use of uk.me.parabola.mkgmap.general.LevelInfo in project mkgmap by openstreetmap.
the class PolishMapDataSource method imgId.
/**
* The initial 'IMG ID' section. Contains miscellaneous parameters for
* the map.
*
* @param name Command name.
* @param value Command value.
*/
private void imgId(String name, String value) {
if (name.equals("Copyright")) {
copyright = value;
} else if (name.equals("Levels")) {
int nlev = Integer.valueOf(value);
levels = new LevelInfo[nlev];
} else if (name.startsWith("Level")) {
int level = Integer.valueOf(name.substring(5));
int bits = Integer.valueOf(value);
LevelInfo info = new LevelInfo(level, bits);
int nlevels = levels.length;
if (level >= nlevels)
return;
levels[nlevels - level - 1] = info;
} else if (name.startsWith("Elevation")) {
char fc = value.charAt(0);
if (fc == 'm' || fc == 'M')
elevUnits = 'm';
} else if (name.equals("CodePage")) {
dec = Charset.forName("cp" + value).newDecoder();
dec.onUnmappableCharacter(CodingErrorAction.REPLACE);
} else if (name.endsWith("LeftSideTraffic")) {
if ("Y".equals(value)) {
setDriveOnLeft(true);
} else if ("N".equals(value)) {
setDriveOnLeft(false);
}
}
}
use of uk.me.parabola.mkgmap.general.LevelInfo in project mkgmap by openstreetmap.
the class PolishMapDataSource method extractResolution.
/**
* Extract resolution from the level.
*
* @param level The level (0..)
* @return The resolution.
* @see #extractResolution(String name)
*/
private int extractResolution(int level) {
int nlevels = levels.length;
// Some maps use EndLevel=9 to mean the highest level
if (level >= nlevels)
level = nlevels - 1;
LevelInfo li = levels[nlevels - level - 1];
return li.getBits();
}
Aggregations