Search in sources :

Example 1 with MdrConfig

use of uk.me.parabola.imgfmt.app.mdr.MdrConfig in project mkgmap by openstreetmap.

the class MdrBuilder method initForDevice.

/**
 * Create an mdr file, in the format used in a gmapsupp.
 *
 * @param chan Reference to an open file within the gmapsupp file.
 */
void initForDevice(ImgChannel chan, Sort sort, MdrConfig baseConfig) {
    // Set the options that we are using for the mdr.
    MdrConfig config = new MdrConfig(baseConfig);
    config.setHeaderLen(568);
    config.setWritable(true);
    config.setForDevice(true);
    config.setSort(sort);
    // Wrap the MDR channel with the MDRFile object
    mdrFile = new MDRFile(chan, config);
}
Also used : MdrConfig(uk.me.parabola.imgfmt.app.mdr.MdrConfig) MDRFile(uk.me.parabola.imgfmt.app.mdr.MDRFile)

Example 2 with MdrConfig

use of uk.me.parabola.imgfmt.app.mdr.MdrConfig in project mkgmap by openstreetmap.

the class FileCopier method init.

public void init(CommandArgs args) {
    areaName = args.get("area-name", null);
    mapsetName = args.get("mapset-name", "OSM map set");
    overallDescription = args.getDescription();
    outputDir = args.getOutputDir();
    hideGmapsuppOnPC = args.get("hide-gmapsupp-on-pc", false);
    productVersion = args.get("product-version", 100);
    mdrConfig = new MdrConfig();
    mdrConfig.setIndexOptions(args);
    try {
        imgFs = createGmapsupp();
    } catch (FileNotWritableException e) {
        throw new MapFailedException("Could not create gmapsupp.img file");
    }
}
Also used : FileNotWritableException(uk.me.parabola.imgfmt.FileNotWritableException) MapFailedException(uk.me.parabola.imgfmt.MapFailedException) MdrConfig(uk.me.parabola.imgfmt.app.mdr.MdrConfig)

Example 3 with MdrConfig

use of uk.me.parabola.imgfmt.app.mdr.MdrConfig 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");
    }
}
Also used : ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) SRTFile(uk.me.parabola.imgfmt.app.srt.SRTFile) FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) MdrConfig(uk.me.parabola.imgfmt.app.mdr.MdrConfig) Sort(uk.me.parabola.imgfmt.app.srt.Sort) MDRFile(uk.me.parabola.imgfmt.app.mdr.MDRFile) IOException(java.io.IOException) SRTFile(uk.me.parabola.imgfmt.app.srt.SRTFile) File(java.io.File) MDRFile(uk.me.parabola.imgfmt.app.mdr.MDRFile) ExitException(uk.me.parabola.imgfmt.ExitException) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Aggregations

MdrConfig (uk.me.parabola.imgfmt.app.mdr.MdrConfig)3 MDRFile (uk.me.parabola.imgfmt.app.mdr.MDRFile)2 File (java.io.File)1 IOException (java.io.IOException)1 ExitException (uk.me.parabola.imgfmt.ExitException)1 FileExistsException (uk.me.parabola.imgfmt.FileExistsException)1 FileNotWritableException (uk.me.parabola.imgfmt.FileNotWritableException)1 FileSystemParam (uk.me.parabola.imgfmt.FileSystemParam)1 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)1 SRTFile (uk.me.parabola.imgfmt.app.srt.SRTFile)1 Sort (uk.me.parabola.imgfmt.app.srt.Sort)1 ImgChannel (uk.me.parabola.imgfmt.fs.ImgChannel)1