Search in sources :

Example 1 with FileSystemParam

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

the class AbstractTestMap method makeMap.

protected void makeMap(String[] args) {
    // Default to nowhere in particular.
    double lat = 51.724;
    double lng = 0.2487;
    // Arguments allow you to place the map where ever you wish.
    if (args.length > 1) {
        lat = Double.valueOf(args[0]);
        lng = Double.valueOf(args[1]);
    }
    log.debug("this is a test make map program. Start", lat, '/', lng);
    FileSystemParam params = new FileSystemParam();
    params.setBlockSize(512);
    params.setMapDescription("OSM street map");
    Map map;
    try {
        map = Map.createMap("32860003", ".", params, "32860003", SrtTextReader.sortForCodepage(1252));
    } catch (FileExistsException e) {
        throw new ExitException("File exists already", e);
    } catch (FileNotWritableException e) {
        throw new ExitException("Could not create or write file", e);
    }
    map.addInfo("Program released under the GPL");
    map.addInfo("This map data is made available under the Open Database License:");
    // There has to be (at least) two copyright messages or else the map
    // does not show up.  The second one will be displayed at startup,
    // although the conditions where that happens are not known.
    map.addCopyright("program licenced under GPL v2");
    // This one gets shown when you switch on, so put the actual
    // map copyright here.  This is made up data, so no copyright applies.
    map.addCopyright("No copyright");
    Area area = new Area(lat, lng, lat + 1, lng + 1);
    map.setBounds(area);
    // There must always be an empty zoom level at the least detailed level.
    log.info("area " + area);
    log.info(" or " + lat + '/' + lng);
    Zoom z1 = map.createZoom(1, 24);
    Subdivision topdiv = map.topLevelSubdivision(area, z1);
    // Create a most detailed view
    Zoom z = map.createZoom(0, 24);
    Subdivision div = map.createSubdivision(topdiv, area, z);
    div.startDivision();
    drawTestMap(map, div, lat, lng);
    map.close();
}
Also used : Area(uk.me.parabola.imgfmt.app.Area) FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) FileNotWritableException(uk.me.parabola.imgfmt.FileNotWritableException) Zoom(uk.me.parabola.imgfmt.app.trergn.Zoom) Subdivision(uk.me.parabola.imgfmt.app.trergn.Subdivision) Map(uk.me.parabola.imgfmt.app.map.Map) ExitException(uk.me.parabola.imgfmt.ExitException) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Example 2 with FileSystemParam

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

the class TYPFileTest method testWrite.

@Test
public void testWrite() throws Exception {
    TestUtils.registerFile("test.typ");
    FileSystemParam params = new FileSystemParam();
    try (FileSystem fs = ImgFS.createFs("test.typ", params)) {
        ImgChannel channel = fs.create("XXX.TYP");
        TYPFile typFile = new TYPFile(channel);
        assertNotNull("typ file is created", typFile);
    }
}
Also used : ImgChannel(uk.me.parabola.imgfmt.fs.ImgChannel) FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) Test(org.junit.Test)

Example 3 with FileSystemParam

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

the class FileCopier method createGmapsupp.

/**
 * Create the output file.
 *
 * @return The gmapsupp file.
 * @throws FileNotWritableException If it cannot be created for any reason.
 */
private FileSystem createGmapsupp() throws FileNotWritableException {
    // Create this file, containing all the sub files
    FileSystemParam params = new FileSystemParam();
    params.setMapDescription(overallDescription);
    params.setGmapsupp(true);
    params.setHideGmapsuppOnPC(hideGmapsuppOnPC);
    params.setProductVersion(productVersion);
    FileSystem outfs = ImgFS.createFs(Utils.joinPath(outputDir, GMAPSUPP), params);
    mpsFile = createMpsFile(outfs);
    mpsFile.setMapsetName(mapsetName);
    return outfs;
}
Also used : FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem)

Example 4 with FileSystemParam

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

the class OverviewBuilder method writeOverviewMap.

/**
 * Write out the overview map.
 */
private void writeOverviewMap() {
    if (overviewSource.mapLevels() == null)
        return;
    MapBuilder mb = new MapBuilder();
    mb.setEnableLineCleanFilters(false);
    FileSystemParam params = new FileSystemParam();
    params.setMapDescription(areaName);
    mb.setCopyrights(creMsgList(copyrightMsgs));
    mb.setMapInfo(creMsgList(licenseInfos));
    try {
        if (codepage == null) {
            // should not happen
            codepage = 0;
        }
        Sort sort = SrtTextReader.sortForCodepage(codepage);
        Map map = Map.createMap(overviewMapname, outputDir, params, overviewMapnumber, sort);
        if (!demProps.isEmpty()) {
            map.config(demProps);
            mb.config(demProps);
        }
        if (encodingType != null) {
            map.getLblFile().setEncoder(encodingType, codepage);
        }
        mb.makeMap(map, overviewSource);
        map.close();
    } catch (FileExistsException e) {
        throw new ExitException("Could not create overview map", e);
    } catch (FileNotWritableException e) {
        throw new ExitException("Could not write to overview map", e);
    }
}
Also used : FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) FileNotWritableException(uk.me.parabola.imgfmt.FileNotWritableException) Sort(uk.me.parabola.imgfmt.app.srt.Sort) MapBuilder(uk.me.parabola.mkgmap.build.MapBuilder) Map(uk.me.parabola.imgfmt.app.map.Map) ExitException(uk.me.parabola.imgfmt.ExitException) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Example 5 with FileSystemParam

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

the class ImgFS method sync.

/**
 * Sync with the underlying file.  All unwritten data is written out to
 * the underlying file.
 *
 * @throws IOException If an error occurs during the write.
 */
public void sync() throws IOException {
    if (readOnly)
        return;
    assert fileBlockManager.getMaxBlockAllocated() == 0;
    FileSystemParam param = fsparam;
    int totalBlocks = calcBlockParam(param);
    fileBlockManager.setBlockSize(param.getBlockSize());
    headerBlockManager.setBlockSize(param.getBlockSize());
    file.position(param.getReservedDirectoryBlocks() * param.getBlockSize());
    fileBlockManager.setCurrentBlock(param.getReservedDirectoryBlocks());
    for (FileNode n : openNodes) {
        n.close();
    }
    header.createHeader(param);
    header.setNumBlocks(totalBlocks);
    header.sync();
    directory.sync();
}
Also used : FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam)

Aggregations

FileSystemParam (uk.me.parabola.imgfmt.FileSystemParam)9 FileExistsException (uk.me.parabola.imgfmt.FileExistsException)4 ExitException (uk.me.parabola.imgfmt.ExitException)3 FileNotWritableException (uk.me.parabola.imgfmt.FileNotWritableException)3 Map (uk.me.parabola.imgfmt.app.map.Map)3 FileSystem (uk.me.parabola.imgfmt.fs.FileSystem)3 File (java.io.File)2 Sort (uk.me.parabola.imgfmt.app.srt.Sort)2 ImgChannel (uk.me.parabola.imgfmt.fs.ImgChannel)2 MapBuilder (uk.me.parabola.mkgmap.build.MapBuilder)2 IOException (java.io.IOException)1 Test (org.junit.Test)1 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)1 Area (uk.me.parabola.imgfmt.app.Area)1 MDRFile (uk.me.parabola.imgfmt.app.mdr.MDRFile)1 MdrConfig (uk.me.parabola.imgfmt.app.mdr.MdrConfig)1 SRTFile (uk.me.parabola.imgfmt.app.srt.SRTFile)1 Subdivision (uk.me.parabola.imgfmt.app.trergn.Subdivision)1 Zoom (uk.me.parabola.imgfmt.app.trergn.Zoom)1 DirectoryEntry (uk.me.parabola.imgfmt.fs.DirectoryEntry)1