Search in sources :

Example 6 with ImgChannel

use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.

the class FileInfo method lblInfo.

/**
 * Obtain the information we need from a LBL file.
 */
private static void lblInfo(FileSystem imgFs, DirectoryEntry ent, FileInfo info) throws FileNotFoundException {
    ImgChannel chan = imgFs.open(ent.getFullName(), "r");
    lblInfo(chan, info);
}
Also used : FileImgChannel(uk.me.parabola.imgfmt.sys.FileImgChannel) ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel)

Example 7 with ImgChannel

use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.

the class FileCopier method addFile.

private void addFile(FileSystem outfs, FileInfo info) {
    String filename = info.getFilename();
    FileCopier fc = new FileCopier(filename);
    try {
        ImgChannel chan = outfs.create(createImgFilename(filename));
        ((FileLink) chan).link(info.subFiles().get(0), fc.file(chan));
    } catch (FileExistsException e) {
        log.warn("Counld not copy " + filename, e);
    }
}
Also used : FileImgChannel(uk.me.parabola.imgfmt.sys.FileImgChannel) ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) FileLink(uk.me.parabola.imgfmt.sys.FileLink) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Example 8 with ImgChannel

use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.

the class FileCopier method addMdrFile.

/**
 * Add or retrieve the MDR file for the given familyId.
 * @param familyId The family id to create the mdr file for.
 * @param sort The sort for this family id.
 * @return If there is already an mdr file for this family then it is returned, else the newly created
 * one.
 */
private MdrBuilder addMdrFile(int familyId, Sort sort) {
    MdrBuilder mdrBuilder = mdrBuilderMap.get(familyId);
    if (mdrBuilder != null)
        return mdrBuilder;
    mdrBuilder = new MdrBuilder();
    try {
        String imgname = String.format("%08d.MDR", familyId);
        ImgChannel chan = imgFs.create(imgname);
        mdrBuilder.initForDevice(chan, sort, mdrConfig);
    } catch (FileExistsException e) {
        System.err.println("Could not create duplicate MDR file");
    }
    mdrBuilderMap.put(familyId, mdrBuilder);
    return mdrBuilder;
}
Also used : FileImgChannel(uk.me.parabola.imgfmt.sys.FileImgChannel) ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Example 9 with ImgChannel

use of uk.me.parabola.imgfmt.fs.ImgChannel 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);
        }
    }
}
Also used : FileImgChannel(uk.me.parabola.imgfmt.sys.FileImgChannel) ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) SRTFile(uk.me.parabola.imgfmt.app.srt.SRTFile) FileNotWritableException(uk.me.parabola.imgfmt.FileNotWritableException) Sort(uk.me.parabola.imgfmt.app.srt.Sort) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Example 10 with ImgChannel

use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.

the class ArgsTest method testDisplayPriority.

@Test
public void testDisplayPriority() throws FileNotFoundException {
    TestUtils.registerFile("osmmap.img");
    int pri = 42;
    Outputs op = TestUtils.run("--draw-priority=" + pri, Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz");
    op.checkNoError();
    FileSystem fs = openFs(Args.DEF_MAP_FILENAME);
    ImgChannel chan = fs.open(Args.DEF_MAP_ID + ".TRE", "r");
    TREFileReader treFile = new TREFileReader(chan);
    assertEquals("display priority", pri, ((TREHeader) treFile.getHeader()).getDisplayPriority());
}
Also used : ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) Outputs(func.lib.Outputs) TREFileReader(uk.me.parabola.imgfmt.app.trergn.TREFileReader) Test(org.junit.Test)

Aggregations

ImgChannel (uk.me.parabola.imgfmt.fs.ImgChannel)18 FileImgChannel (uk.me.parabola.imgfmt.sys.FileImgChannel)9 FileSystem (uk.me.parabola.imgfmt.fs.FileSystem)8 Test (org.junit.Test)6 File (java.io.File)5 IOException (java.io.IOException)5 FileExistsException (uk.me.parabola.imgfmt.FileExistsException)5 ByteBuffer (java.nio.ByteBuffer)4 SRTFile (uk.me.parabola.imgfmt.app.srt.SRTFile)3 Sort (uk.me.parabola.imgfmt.app.srt.Sort)3 TREFileReader (uk.me.parabola.imgfmt.app.trergn.TREFileReader)3 FileNotFoundException (java.io.FileNotFoundException)2 ExitException (uk.me.parabola.imgfmt.ExitException)2 FileSystemParam (uk.me.parabola.imgfmt.FileSystemParam)2 DirectoryEntry (uk.me.parabola.imgfmt.fs.DirectoryEntry)2 FileLink (uk.me.parabola.imgfmt.sys.FileLink)2 Outputs (func.lib.Outputs)1 Closeable (java.io.Closeable)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 LinkedHashMap (java.util.LinkedHashMap)1