use of uk.me.parabola.imgfmt.app.typ.TypParam 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();
}
use of uk.me.parabola.imgfmt.app.typ.TypParam in project mkgmap by openstreetmap.
the class TypTextReaderTest method testIdSection.
@Test
public void testIdSection() {
tr = makeTyp("[_id]\n" + "FID=24\n" + "ProductCode=2\n" + "CodePage=1251\n" + "[End]");
TypParam param = tr.getData().getParam();
assertEquals(24, param.getFamilyId());
assertEquals(2, param.getProductId());
assertEquals(1251, param.getCodePage());
}
Aggregations