Search in sources :

Example 6 with FileSystem

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

the class TYPFileTest method testWrite.

@Test
public void testWrite() throws Exception {
    TestUtils.registerFile("test.typ");
    FileSystemParam params = new FileSystemParam();
    try (FileSystem fs = ImgFS.createFs("test.typ", params)) {
        ImgChannel channel = fs.create("XXX.TYP");
        TYPFile typFile = new TYPFile(channel);
        assertNotNull("typ file is created", typFile);
    }
}
Also used : ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) Test(org.junit.Test)

Example 7 with FileSystem

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

the class FileCopier method createGmapsupp.

/**
 * Create the output file.
 *
 * @return The gmapsupp file.
 * @throws FileNotWritableException If it cannot be created for any reason.
 */
private FileSystem createGmapsupp() throws FileNotWritableException {
    // Create this file, containing all the sub files
    FileSystemParam params = new FileSystemParam();
    params.setMapDescription(overallDescription);
    params.setGmapsupp(true);
    params.setHideGmapsuppOnPC(hideGmapsuppOnPC);
    params.setProductVersion(productVersion);
    FileSystem outfs = ImgFS.createFs(Utils.joinPath(outputDir, GMAPSUPP), params);
    mpsFile = createMpsFile(outfs);
    mpsFile.setMapsetName(mapsetName);
    return outfs;
}
Also used : FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem)

Example 8 with FileSystem

use of uk.me.parabola.imgfmt.fs.FileSystem 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)

Example 9 with FileSystem

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

the class SimpleTest method testPolish.

@Test
public void testPolish() throws FileNotFoundException {
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, Args.TEST_RESOURCE_MP + "test1.mp");
    FileSystem fs = openFs(Args.DEF_MAP_FILENAME);
    assertNotNull("file exists", fs);
    List<DirectoryEntry> entries = fs.list();
    int count = 0;
    for (DirectoryEntry ent : entries) {
        String ext = ent.getExt();
        int size = ent.getSize();
        switch(ext) {
            case "RGN":
                count++;
                System.out.println("RGN size " + size);
                assertThat("RGN size", size, new RangeMatcher(2704));
                break;
            case "TRE":
                count++;
                System.out.println("TRE size " + size);
                // Size varies depending on svn modified status
                assertThat("TRE size", size, new RangeMatcher(770, 2));
                break;
            case "LBL":
                count++;
                assertEquals("LBL size", 999, size);
                break;
        }
    }
    assertTrue("enough checks run", count >= 3);
}
Also used : RangeMatcher(func.lib.RangeMatcher) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) DirectoryEntry(uk.me.parabola.imgfmt.fs.DirectoryEntry) Point(uk.me.parabola.imgfmt.app.trergn.Point) Test(org.junit.Test)

Example 10 with FileSystem

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

the class GmapsuppTest method testWithTwoIndexes.

@Test
public void testWithTwoIndexes() throws IOException {
    TestUtils.registerFile("osmmap_mdr.img", "osmmap.img", "osmmap.tbd", "osmmap.mdx");
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", "--index", "--tdbfile", "--latin1", "--family-id=101", "--product-id=1", "--family-name=tst family1", "--series-name=tst series1", Args.TEST_RESOURCE_IMG + "63240001.img", Args.TEST_RESOURCE_IMG + "63240002.img");
    assertTrue(new File("osmmap_mdr.img").exists());
    // All we are doing here is checking that the file was created and that it is
    // not completely empty.
    FileSystem fs = openFs(GMAPSUPP_IMG);
    ImgChannel r = fs.open("00000101.MDR", "r");
    r.position(2);
    ByteBuffer buf = ByteBuffer.allocate(1024);
    int read = r.read(buf);
    assertEquals(1024, read);
    buf.flip();
    byte[] b = new byte[3];
    buf.get(b, 0, 3);
    assertEquals('G', b[0]);
}
Also used : ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) File(java.io.File) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

FileSystem (uk.me.parabola.imgfmt.fs.FileSystem)19 Test (org.junit.Test)11 File (java.io.File)8 DirectoryEntry (uk.me.parabola.imgfmt.fs.DirectoryEntry)8 ImgChannel (uk.me.parabola.imgfmt.fs.ImgChannel)8 ByteBuffer (java.nio.ByteBuffer)4 FileSystemParam (uk.me.parabola.imgfmt.FileSystemParam)3 Outputs (func.lib.Outputs)2 RangeMatcher (func.lib.RangeMatcher)2 IOException (java.io.IOException)2 MpsFileReader (uk.me.parabola.imgfmt.mps.MpsFileReader)2 FileNotFoundException (java.io.FileNotFoundException)1 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)1 Point (uk.me.parabola.imgfmt.app.trergn.Point)1 RGNFile (uk.me.parabola.imgfmt.app.trergn.RGNFile)1 TREFile (uk.me.parabola.imgfmt.app.trergn.TREFile)1 TREFileReader (uk.me.parabola.imgfmt.app.trergn.TREFileReader)1 MapBlock (uk.me.parabola.imgfmt.mps.MapBlock)1 ProductBlock (uk.me.parabola.imgfmt.mps.ProductBlock)1 FileImgChannel (uk.me.parabola.imgfmt.sys.FileImgChannel)1