use of uk.me.parabola.imgfmt.fs.DirectoryEntry 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();
}
use of uk.me.parabola.imgfmt.fs.DirectoryEntry 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);
}
use of uk.me.parabola.imgfmt.fs.DirectoryEntry in project mkgmap by openstreetmap.
the class FileInfo method imgInfo.
/**
* An IMG file, this involves real work. We have to read in the file and
* extract several pieces of information from it.
*
* @param inputName The name of the file.
* @return The information obtained.
* @throws FileNotFoundException If the file doesn't exist.
*/
private static FileInfo imgInfo(String inputName) throws FileNotFoundException {
try (FileSystem imgFs = ImgFS.openFs(inputName)) {
FileSystemParam params = imgFs.fsparam();
log.info("Desc", params.getMapDescription());
log.info("Blocksize", params.getBlockSize());
FileInfo info = new FileInfo(inputName, UNKNOWN_KIND);
info.setDescription(params.getMapDescription());
File f = new File(inputName);
String name = f.getName();
if (OverviewBuilder.isOverviewImg(name))
name = OverviewBuilder.getMapName(name);
int dot = name.lastIndexOf('.');
if (dot < 0) {
name = "0";
} else {
if (dot > name.length())
dot = name.length();
if (dot > 8)
dot = 8;
name = name.substring(0, dot);
}
info.setMapname(name);
boolean hasTre = false;
DirectoryEntry treEnt = null;
List<DirectoryEntry> entries = imgFs.list();
for (DirectoryEntry ent : entries) {
if (ent.isSpecial())
continue;
log.info("file", ent.getFullName());
String ext = ent.getExt();
if ("TRE".equals(ext)) {
info.setTresize(ent.getSize());
info.setInnername(ent.getName());
hasTre = true;
treEnt = ent;
} else if ("RGN".equals(ext)) {
int size = ent.getSize();
info.setRgnsize(size);
} else if ("LBL".equals(ext)) {
info.setLblsize(ent.getSize());
lblInfo(imgFs, ent, info);
} else if ("NET".equals(ext)) {
info.setNetsize(ent.getSize());
} else if ("NOD".equals(ext)) {
info.setNodsize(ent.getSize());
} else if ("DEM".equals(ext)) {
info.setDemsize(ent.getSize());
} else if ("MDR".equals(ext)) {
// It is not actually a regular img file, so change the kind.
info.setKind(MDR_KIND);
} else if ("MPS".equals(ext)) {
// This is a gmapsupp file containing several maps.
info.setKind(GMAPSUPP_KIND);
info.mpsName = ent.getFullName();
}
info.subFiles.add(new SubFileInfo(ent.getFullName(), ent.getSize()));
}
if (hasTre)
treInfo(imgFs, treEnt, info);
if (info.getKind() == UNKNOWN_KIND && hasTre)
info.setKind(IMG_KIND);
return info;
}
}
use of uk.me.parabola.imgfmt.fs.DirectoryEntry in project mkgmap by openstreetmap.
the class GmapiBuilder method unzipImg.
private static void unzipImg(String srcImgName, Path destDir) throws IOException {
FileSystem fs = ImgFS.openFs(srcImgName);
for (DirectoryEntry ent : fs.list()) {
String fullname = ent.getFullName();
try (ImgChannel f = fs.open(fullname, "r")) {
String name = displayName(fullname);
if (Objects.equals(name, "."))
continue;
Files.createDirectories(destDir);
copyToFile(f, destDir.resolve(name));
}
}
}
Aggregations