use of uk.me.parabola.imgfmt.app.srt.SRTFile in project mkgmap by openstreetmap.
the class SrtTextReader method main.
/**
* Read in a sort description text file and create a SRT from it.
* @param args First arg is the text input file, the second is the name of the output file. The defaults are
* in.txt and out.srt.
*/
public static void main(String[] args) throws IOException {
String infile = "in.txt";
if (args.length > 0)
infile = args[0];
String outfile = "out.srt";
if (args.length > 1)
outfile = args[1];
try {
Files.delete(Paths.get(outfile, ""));
} catch (Exception e) {
}
ImgChannel chan = new FileImgChannel(outfile, "rw");
SRTFile sf = new SRTFile(chan);
SrtTextReader tr = new SrtTextReader(infile);
Sort sort1 = tr.getSort();
sf.setSort(sort1);
sf.write();
sf.close();
chan.close();
}
use of uk.me.parabola.imgfmt.app.srt.SRTFile in project mkgmap by openstreetmap.
the class FileCopier method writeSrtFile.
/**
* Write the SRT file.
*
* @param imgFs The filesystem to create the SRT file in.
* @throws FileNotWritableException If it cannot be created.
*/
private void writeSrtFile(FileSystem imgFs) throws FileNotWritableException {
for (Map.Entry<Integer, Sort> ent : sortMap.entrySet()) {
Sort sort = ent.getValue();
int familyId = ent.getKey();
if (sort.getId1() == 0 && sort.getId2() == 0)
return;
try {
ImgChannel channel = imgFs.create(String.format("%08d.SRT", familyId));
SRTFile srtFile = new SRTFile(channel);
srtFile.setSort(sort);
srtFile.write();
// Do not close srtFile here
} catch (FileExistsException e) {
// well it shouldn't exist!
log.error("could not create SRT file as it exists already");
throw new FileNotWritableException("already existed", e);
}
}
}
use of uk.me.parabola.imgfmt.app.srt.SRTFile in project mkgmap by openstreetmap.
the class MdrBuilder method init.
/**
* Create the mdr file and initialise.
* It has a name that is based on the overview-mapname option, as does
* the associated MDX file.
*
* @param args The command line arguments.
*/
public void init(CommandArgs args) {
String name = args.get("overview-mapname", "osmmap");
String outputDir = args.getOutputDir();
outputName = Utils.joinPath(outputDir, name + "_mdr.img");
ImgChannel mdrChan;
try {
// Create the .img file system/archive
FileSystemParam params = new FileSystemParam();
tmpName = File.createTempFile("mdr", null, new File(outputDir));
tmpName.deleteOnExit();
imgfs = ImgFS.createFs(tmpName.getPath(), params);
// Create the MDR file within the .img
mdrChan = imgfs.create(name.toUpperCase(Locale.ENGLISH) + ".MDR");
} catch (IOException e) {
throw new ExitException("Could not create global index file");
}
// Create the sort description
Sort sort = SrtTextReader.sortForCodepage(args.getCodePage());
// Set the options that we are using for the mdr.
MdrConfig config = new MdrConfig();
config.setHeaderLen(568);
config.setWritable(true);
config.setForDevice(false);
config.setOutputDir(outputDir);
config.setSort(sort);
config.setIndexOptions(args);
// Wrap the MDR channel with the MDRFile object
mdrFile = new MDRFile(mdrChan, config);
try {
ImgChannel srtChan = imgfs.create(name.toUpperCase(Locale.ENGLISH) + ".SRT");
SRTFile srtFile = new SRTFile(srtChan);
srtFile.setSort(sort);
srtFile.write();
// Do not close srtFile here
} catch (FileExistsException e) {
throw new ExitException("Could not create SRT file within index file");
}
}
Aggregations