use of uk.me.parabola.imgfmt.app.typ.TypLabelException in project mkgmap by openstreetmap.
the class TypCompiler method makeMap.
/**
* The integration with mkgmap.
*
* @param args The options that are in force.
* @param filename The input filename.
* @return Returns the name of the file that was written. It depends on the family id.
*/
public String makeMap(CommandArgs args, String filename) {
assert filename.toLowerCase().endsWith(".txt");
CharsetProbe probe = new CharsetProbe();
String readCharset = probe.probeCharset(filename);
TypData data;
try {
data = compile(filename, readCharset, args.getSort());
} catch (SyntaxException e) {
throw new MapFailedException("Compiling TYP txt file: " + e.getMessage());
} catch (FileNotFoundException e) {
throw new MapFailedException("Could not open TYP file " + filename + " to read");
}
TypParam param = data.getParam();
int family = args.get("family-id", -1);
int product = args.get("product-id", -1);
int cp = args.get("code-page", -1);
if (family != -1)
param.setFamilyId(family);
if (product != -1)
param.setProductId(product);
if (cp != -1)
param.setCodePage(cp);
File outFile = new File(filename);
String outName = outFile.getName();
int last;
if (outName.length() > 4 && (last = outName.lastIndexOf('.')) > 0)
outName = outName.substring(0, last);
outName += ".typ";
outFile = new File(args.getOutputDir(), outName);
try {
writeTyp(data, outFile);
} catch (TypLabelException e) {
throw new MapFailedException("TYP file cannot be written in code page " + data.getSort().getCodepage());
} catch (IOException e) {
throw new MapFailedException("Error while writing typ file", e);
}
return outFile.getPath();
}
Aggregations