Search in sources :

Example 1 with MapBuilder

use of uk.me.parabola.mkgmap.build.MapBuilder 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 2 with MapBuilder

use of uk.me.parabola.mkgmap.build.MapBuilder in project mkgmap by openstreetmap.

the class MapMaker method makeMap.

/**
 * Make a map from the given map data source.
 *
 * @param args User supplied arguments.
 * @param src The data source to load.
 * @param mapNameExt
 * @return The output filename for the map.
 */
private String makeMap(CommandArgs args, LoadableMapDataSource src, String mapNamePrefix) {
    if (src.getBounds().isEmpty())
        return null;
    FileSystemParam params = new FileSystemParam();
    params.setBlockSize(args.getBlockSize());
    params.setMapDescription(args.getDescription());
    log.info("Started making", args.getMapname(), "(" + args.getDescription() + ")");
    try {
        Map map = Map.createMap(mapNamePrefix + args.getMapname(), args.getOutputDir(), params, args.getMapname(), sort);
        setOptions(map, args);
        MapBuilder builder = new MapBuilder();
        builder.config(args.getProperties());
        if (!OverviewBuilder.OVERVIEW_PREFIX.equals(mapNamePrefix)) {
            if (args.getProperties().containsKey("route") || args.getProperties().containsKey("net"))
                builder.setDoRoads(true);
        }
        builder.makeMap(map, src);
        // Collect information on map complete.
        String outName = map.getFilename();
        log.info("finished making map", outName, "closing");
        map.close();
        return outName;
    } catch (FileExistsException e) {
        throw new MapFailedException("File exists already", e);
    } catch (FileNotWritableException e) {
        throw new MapFailedException("Could not create or write to file", e);
    }
}
Also used : FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) MapFailedException(uk.me.parabola.imgfmt.MapFailedException) FileNotWritableException(uk.me.parabola.imgfmt.FileNotWritableException) MapBuilder(uk.me.parabola.mkgmap.build.MapBuilder) Map(uk.me.parabola.imgfmt.app.map.Map) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Aggregations

FileExistsException (uk.me.parabola.imgfmt.FileExistsException)2 FileNotWritableException (uk.me.parabola.imgfmt.FileNotWritableException)2 FileSystemParam (uk.me.parabola.imgfmt.FileSystemParam)2 Map (uk.me.parabola.imgfmt.app.map.Map)2 MapBuilder (uk.me.parabola.mkgmap.build.MapBuilder)2 ExitException (uk.me.parabola.imgfmt.ExitException)1 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)1 Sort (uk.me.parabola.imgfmt.app.srt.Sort)1