use of uk.me.parabola.imgfmt.app.map.Map 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();
}
use of uk.me.parabola.imgfmt.app.map.Map in project mkgmap by openstreetmap.
the class MapBuilder method getMapInfo.
/**
* Set all the information that appears in the header.
*/
private void getMapInfo() {
if (licenseFileName != null) {
List<String> licenseArray = new ArrayList<>();
try {
File file = new File(licenseFileName);
licenseArray = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
} catch (Exception e) {
throw new ExitException("Error reading license file " + licenseFileName, e);
}
if ((licenseArray.size() > 0) && licenseArray.get(0).startsWith("\ufeff"))
licenseArray.set(0, licenseArray.get(0).substring(1));
UnaryOperator<String> replaceVariables = s -> s.replace("$MKGMAP_VERSION$", Version.VERSION).replace("$JAVA_VERSION$", System.getProperty("java.version")).replace("$YEAR$", Integer.toString(now.getYear())).replace("$LONGDATE$", now.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG))).replace("$SHORTDATE$", now.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT))).replace("$TIME$", now.toLocalTime().toString().substring(0, 5));
licenseArray.replaceAll(replaceVariables);
mapInfo.addAll(licenseArray);
} else {
mapInfo.add("Map data (c) OpenStreetMap and its contributors");
mapInfo.add("http://www.openstreetmap.org/copyright");
mapInfo.add("");
mapInfo.add("This map data is made available under the Open Database License:");
mapInfo.add("http://opendatacommons.org/licenses/odbl/1.0/");
mapInfo.add("Any rights in individual contents of the database are licensed under the");
mapInfo.add("Database Contents License: http://opendatacommons.org/licenses/dbcl/1.0/");
mapInfo.add("");
// Pad the version number with spaces so that version
// strings that are different lengths do not change the size and
// offsets of the following sections.
mapInfo.add("Map created with mkgmap-r" + String.format("%-10s", Version.VERSION));
mapInfo.add("Program released under the GPL");
}
}
use of uk.me.parabola.imgfmt.app.map.Map 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);
}
}
use of uk.me.parabola.imgfmt.app.map.Map 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);
}
}
Aggregations