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());
}
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;
}
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);
}
}
Aggregations