Search in sources :

Example 1 with MpsFileReader

use of uk.me.parabola.imgfmt.mps.MpsFileReader in project mkgmap by openstreetmap.

the class GmapsuppTest method testDifferentFamilies.

/**
 * Test the case where we are combining img files with different family
 * and product ids.
 */
@Test
public void testDifferentFamilies() throws IOException {
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", "--family-id=101", "--product-id=1", "--series-name=tst series1", Args.TEST_RESOURCE_IMG + "63240001.img", "--family-id=102", "--product-id=2", "--series-name=tst series2", Args.TEST_RESOURCE_IMG + "63240002.img");
    MpsFileReader reader = getMpsFile();
    List<MapBlock> list = reader.getMaps();
    reader.close();
    assertEquals("number of map blocks", 2, list.size());
    // Directly check the family id's
    assertEquals("family in map1", 101, list.get(0).getFamilyId());
    assertEquals("family in map2", 102, list.get(1).getFamilyId());
    // Check more things
    int count = 0;
    for (MapBlock map : list) {
        count++;
        assertEquals("family in map" + count, 100 + count, map.getFamilyId());
        assertEquals("product in map" + count, count, map.getProductId());
        assertEquals("series name in map" + count, "tst series" + count, map.getSeriesName());
    }
}
Also used : MapBlock(uk.me.parabola.imgfmt.mps.MapBlock) MpsFileReader(uk.me.parabola.imgfmt.mps.MpsFileReader) Test(org.junit.Test)

Example 2 with MpsFileReader

use of uk.me.parabola.imgfmt.mps.MpsFileReader in project mkgmap by openstreetmap.

the class GmapsuppTest method testMpsFile.

/**
 * Check the values inside the MPS file, when the family id etc is
 * common to all files.
 */
@Test
public void testMpsFile() throws IOException {
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", "--family-id=150", "--product-id=24", "--series-name=tst series", "--family-name=tst family", "--area-name=tst area", Args.TEST_RESOURCE_IMG + "63240001.img", Args.TEST_RESOURCE_IMG + "63240002.img");
    MpsFileReader reader = getMpsFile();
    List<MapBlock> list = reader.getMaps();
    reader.close();
    assertEquals("number of map blocks", 2, list.size());
    // All maps will have the same parameters apart from map name here
    int count = 0;
    for (MapBlock map : list) {
        assertEquals("map number", 63240001 + count++, map.getMapNumber());
        assertEquals("family id", 150, map.getFamilyId());
        assertEquals("product id", 24, map.getProductId());
        assertEquals("series name", "tst series", map.getSeriesName());
        assertEquals("area name", "tst area", map.getAreaName());
        assertEquals("map description", "uk test " + count, map.getMapDescription());
    }
}
Also used : MapBlock(uk.me.parabola.imgfmt.mps.MapBlock) MpsFileReader(uk.me.parabola.imgfmt.mps.MpsFileReader) Test(org.junit.Test)

Example 3 with MpsFileReader

use of uk.me.parabola.imgfmt.mps.MpsFileReader in project mkgmap by openstreetmap.

the class GmapsuppTest method testProductBlocks.

/**
 * The mps file has a block for each family/product in the map set.
 */
@Test
public void testProductBlocks() throws IOException {
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", "--family-id=101", "--product-id=1", "--family-name=tst family1", "--series-name=tst series1", Args.TEST_RESOURCE_IMG + "63240001.img", "--family-id=102", "--product-id=2", "--family-name=tst family2", "--series-name=tst series2", Args.TEST_RESOURCE_IMG + "63240002.img");
    MpsFileReader reader = getMpsFile();
    List<ProductBlock> products = reader.getProducts();
    products.sort((o1, o2) -> {
        if (o1.getFamilyId() == o2.getFamilyId())
            return 0;
        else if (o1.getFamilyId() > o2.getFamilyId())
            return 1;
        else
            return -1;
    });
    ProductBlock block = products.get(0);
    assertEquals("product block first family", 101, block.getFamilyId());
    assertEquals("product block first product id", 1, block.getProductId());
    assertEquals("product block first family name", "tst family1", block.getDescription());
    block = products.get(1);
    assertEquals("product block second family", 102, block.getFamilyId());
    assertEquals("product block first product id", 2, block.getProductId());
    assertEquals("product block first family name", "tst family2", block.getDescription());
}
Also used : ProductBlock(uk.me.parabola.imgfmt.mps.ProductBlock) MpsFileReader(uk.me.parabola.imgfmt.mps.MpsFileReader) Test(org.junit.Test)

Example 4 with MpsFileReader

use of uk.me.parabola.imgfmt.mps.MpsFileReader in project mkgmap by openstreetmap.

the class GmapsuppTest method testProductWithSeveralMaps.

/**
 * Make sure that if we have multiple maps in the same family, which after
 * all is the common case, that we only get one product block.
 */
@Test
public void testProductWithSeveralMaps() throws IOException {
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--gmapsupp", "--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");
    MpsFileReader reader = getMpsFile();
    assertEquals("number of map blocks", 2, reader.getMaps().size());
    assertEquals("number of product blocks", 1, reader.getProducts().size());
}
Also used : MpsFileReader(uk.me.parabola.imgfmt.mps.MpsFileReader) Test(org.junit.Test)

Example 5 with MpsFileReader

use of uk.me.parabola.imgfmt.mps.MpsFileReader in project mkgmap by openstreetmap.

the class GmapsuppTest method getMpsFile.

private MpsFileReader getMpsFile() throws IOException {
    FileSystem fs = openFs(GMAPSUPP_IMG);
    MpsFileReader reader = new MpsFileReader(fs.open("MAKEGMAP.MPS", "r"), 0);
    TestUtils.registerFile(reader);
    return reader;
}
Also used : FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) MpsFileReader(uk.me.parabola.imgfmt.mps.MpsFileReader)

Aggregations

MpsFileReader (uk.me.parabola.imgfmt.mps.MpsFileReader)7 Test (org.junit.Test)5 MapBlock (uk.me.parabola.imgfmt.mps.MapBlock)4 FileSystem (uk.me.parabola.imgfmt.fs.FileSystem)2 ProductBlock (uk.me.parabola.imgfmt.mps.ProductBlock)2 File (java.io.File)1 IOException (java.io.IOException)1