use of uk.me.parabola.imgfmt.fs.ImgChannel 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]);
}
use of uk.me.parabola.imgfmt.fs.ImgChannel 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);
}
use of uk.me.parabola.imgfmt.fs.ImgChannel 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]);
}
use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.
the class FileInfo method typInfo.
/**
* Read information from the TYP file that we might need when combining it with other files.
* @param filename The name of the file.
* @param info The information will be stored here.
*/
private static void typInfo(String filename, FileInfo info) {
try (ImgChannel chan = new FileImgChannel(filename, "r");
BufferedImgFileReader fr = new BufferedImgFileReader(chan)) {
fr.position(0x15);
info.setCodePage(fr.getChar());
} catch (IOException e) {
e.printStackTrace();
}
}
use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.
the class FileInfo method treInfo.
/**
* Obtain the information that we need from the TRE section.
* @param imgFs The filesystem
* @param ent The filename within the filesystem of the TRE file.
* @param info This is where the information will be saved.
* @throws FileNotFoundException If the file is not found in the filesystem.
*/
private static void treInfo(FileSystem imgFs, DirectoryEntry ent, FileInfo info) throws FileNotFoundException {
try (ImgChannel treChan = imgFs.open(ent.getFullName(), "r");
TREFileReader treFile = new TREFileReader(treChan)) {
info.setBounds(treFile.getBounds());
info.setLicenceInfo(treFile.getMapInfo(info.getCodePage()));
info.setHexname(((TREHeader) treFile.getHeader()).getMapId());
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
throw new FileNotFoundException();
}
}
Aggregations