Search in sources :

Example 1 with DetailMapBlock

use of uk.me.parabola.tdbfmt.DetailMapBlock in project mkgmap by openstreetmap.

the class TdbBuilder method addToTdb.

/**
 * Add the information about the current map to the tdb file.
 *
 * @param finfo Information about the current .img file.
 */
private void addToTdb(FileInfo finfo) {
    DetailMapBlock detail = new DetailMapBlock(tdbVersion);
    detail.setArea(finfo.getBounds());
    String mapname = finfo.getMapname();
    String mapdesc = finfo.getDescription();
    detail.setMapName(mapname);
    String desc = mapdesc + " (" + mapname + ')';
    detail.setDescription(desc);
    detail.setSubFiles(finfo.subFiles());
    log.info("overview-mapname", overviewMapname);
    log.info("overview-mapnumber", parent);
    detail.setParentMapNumber(parent);
    tdb.addDetail(detail);
    String[] msgs = finfo.getLicenseInfo();
    for (String m : msgs) tdb.addCopyright(m);
    MapReader mapReader = null;
    String filename = finfo.getFilename();
    try {
        mapReader = new MapReader(filename);
        msgs = mapReader.getCopyrights();
        boolean found = false;
        for (String[] block : copyrightMsgs) {
            if (Arrays.deepEquals(block, msgs)) {
                found = true;
                break;
            }
        }
        if (!found) {
            copyrightMsgs.add(msgs);
            for (String m : msgs) tdb.addCopyright(m);
        }
    } catch (FileNotFoundException e) {
        throw new ExitException("Could not open " + filename + " when creating tdb file");
    } finally {
        Utils.closeFile(mapReader);
    }
}
Also used : MapReader(uk.me.parabola.imgfmt.app.map.MapReader) DetailMapBlock(uk.me.parabola.tdbfmt.DetailMapBlock) FileNotFoundException(java.io.FileNotFoundException) ExitException(uk.me.parabola.imgfmt.ExitException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 ExitException (uk.me.parabola.imgfmt.ExitException)1 MapReader (uk.me.parabola.imgfmt.app.map.MapReader)1 DetailMapBlock (uk.me.parabola.tdbfmt.DetailMapBlock)1