Search in sources :

Example 1 with ProductBlock

use of uk.me.parabola.imgfmt.mps.ProductBlock 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 2 with ProductBlock

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

the class FileCopier method makeProductBlock.

private ProductBlock makeProductBlock(FileInfo info) {
    ProductBlock pb = new ProductBlock(info.getCodePage());
    pb.setFamilyId(info.getFamilyId());
    pb.setProductId(info.getProductId());
    pb.setDescription(info.getFamilyName());
    return pb;
}
Also used : ProductBlock(uk.me.parabola.imgfmt.mps.ProductBlock)

Example 3 with ProductBlock

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

the class FileCopier method addMpsFile.

/**
 * Add a complete pre-existing mps file to the mps file we are currently
 * building for this gmapsupp.
 * @param info The details of the gmapsupp file that we need to extract the
 */
private void addMpsFile(FileInfo info) {
    String name = info.getFilename();
    try (FileSystem fs = ImgFS.openFs(name)) {
        MpsFileReader mr = new MpsFileReader(fs.open(info.getMpsName(), "r"), info.getCodePage());
        for (MapBlock block : mr.getMaps()) mpsFile.addMap(block);
        for (ProductBlock b : mr.getProducts()) mpsFile.addProduct(b);
        mr.close();
    } catch (IOException e) {
        log.error("Could not read MPS file from gmapsupp", e);
    }
}
Also used : ProductBlock(uk.me.parabola.imgfmt.mps.ProductBlock) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) MapBlock(uk.me.parabola.imgfmt.mps.MapBlock) IOException(java.io.IOException) MpsFileReader(uk.me.parabola.imgfmt.mps.MpsFileReader)

Aggregations

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