Search in sources :

Example 11 with FileSystem

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

the class GmapsuppTest method testBasic.

@Test
public void testBasic() throws IOException {
    File f = new File(GMAPSUPP_IMG);
    assertFalse("does not pre-exist", f.exists());
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", Args.TEST_RESOURCE_IMG + "63240001.img", Args.TEST_RESOURCE_IMG + "63240002.img");
    assertTrue("gmapsupp.img is created", f.exists());
    FileSystem fs = openFs(GMAPSUPP_IMG);
    DirectoryEntry entry = fs.lookup("63240001.TRE");
    assertNotNull("first file TRE", entry);
    assertEquals("first file TRE size", getFileSize(Args.TEST_RESOURCE_IMG + "63240001.img", "63240001.TRE"), entry.getSize());
    entry = fs.lookup("63240002.TRE");
    assertNotNull("second file TRE", entry);
    assertEquals("second file TRE size", getFileSize(Args.TEST_RESOURCE_IMG + "63240002.img", "63240002.TRE"), entry.getSize());
}
Also used : FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) DirectoryEntry(uk.me.parabola.imgfmt.fs.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 12 with FileSystem

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

the class GmapsuppTest method testTwoFamilyIndex.

/**
 * If there are files in two (or more) families then there should be a MDR and SRT for each.
 */
@Test
public void testTwoFamilyIndex() throws IOException {
    TestUtils.registerFile("osmmap_mdr.img", "osmmap.img", "osmmap.tbd", "osmmap.mdx");
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", "--index", "--latin1", "--family-id=101", "--product-id=1", "--family-name=tst family1", "--series-name=tst series1", Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz", "--family-id=202", "--family-name=tst family2", "--series-name=tst series2", Args.TEST_RESOURCE_OSM + "uk-test-2.osm.gz");
    assertFalse(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);
    fs = openFs(GMAPSUPP_IMG);
    r = fs.open("00000202.MDR", "r");
    r.position(2);
    buf.clear();
    read = r.read(buf);
    assertEquals(1024, read);
    r = fs.open("00000202.SRT", "r");
    buf = ByteBuffer.allocate(512);
    read = r.read(buf);
    assertEquals(512, read);
    r = fs.open("00000101.SRT", "r");
    buf.clear();
    read = r.read(buf);
    assertEquals(512, read);
}
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)

Example 13 with FileSystem

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

the class GmapsuppTest method testWithIndex.

@Test
public void testWithIndex() throws IOException {
    new File("osmmap_mdr.img").delete();
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", "--index", "--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");
    assertFalse(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)

Example 14 with FileSystem

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

the class IndexTest method testCreateIndex.

@Test
public void testCreateIndex() throws IOException {
    File f = new File(MDR_IMG);
    f.delete();
    assertFalse("does not pre-exist", f.exists());
    Outputs outputs = TestUtils.run(Args.TEST_STYLE_ARG, "--index", "--latin1", "--family-id=1002", "--overview-mapname=" + OVERVIEW_NAME, Args.TEST_RESOURCE_IMG + "63240001.img", Args.TEST_RESOURCE_IMG + "63240002.img");
    outputs.checkNoError();
    TestUtils.registerFile(MDR_IMG);
    TestUtils.registerFile(OVERVIEW_NAME + ".tdb");
    TestUtils.registerFile(OVERVIEW_NAME + ".mdx");
    TestUtils.registerFile(OVERVIEW_NAME + ".img");
    assertTrue(MDR_IMG + " is created", f.exists());
    FileSystem fs = openFs(MDR_IMG);
    DirectoryEntry entry = fs.lookup(OVERVIEW_NAME.toUpperCase() + ".MDR");
    assertNotNull("Contains the MDR file", entry);
    entry = fs.lookup(OVERVIEW_NAME.toUpperCase() + ".SRT");
    assertNotNull("contains the SRT file", entry);
    fs.close();
}
Also used : FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) Outputs(func.lib.Outputs) DirectoryEntry(uk.me.parabola.imgfmt.fs.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 15 with FileSystem

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

the class SimpleRouteTest method testSize.

/**
 * Simple test to ensure that nothing has changed.  Of course
 * if the output should have changed, then this will have to be altered
 * to match.
 */
@Test
public void testSize() throws FileNotFoundException {
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--preserve-element-order", "--route", Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz", Args.TEST_RESOURCE_MP + "test1.mp");
    FileSystem fs = openFs(Args.DEF_MAP_ID + ".img");
    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(127586));
                break;
            case "TRE":
                count++;
                System.out.println("TRE size " + size);
                // Size varies depending on svn modified status
                assertThat("TRE size", size, new RangeMatcher(1427, 2));
                break;
            case "LBL":
                count++;
                assertEquals("LBL size", 28742, size);
                break;
            case "NET":
                count++;
                assertEquals("NET size", 66859, size);
                break;
            case "NOD":
                count++;
                assertEquals("NOD size", 170201, size);
                break;
        }
    }
    assertTrue("enough checks run", count == 5);
    fs = openFs(Args.DEF_MAP_FILENAME2);
    assertNotNull("file exists", fs);
    entries = fs.list();
    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(2727));
                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;
            case "NET":
                count++;
                assertEquals("NET size", 1301, size);
                break;
            case "NOD":
                count++;
                assertEquals("NOD size", 3584, size);
                break;
        }
    }
    assertTrue("enough checks run", count == 5);
}
Also used : RangeMatcher(func.lib.RangeMatcher) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) DirectoryEntry(uk.me.parabola.imgfmt.fs.DirectoryEntry) 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