use of uk.me.parabola.imgfmt.FileExistsException 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.FileExistsException in project mkgmap by openstreetmap.
the class FileCopier method addFile.
private void addFile(FileSystem outfs, FileInfo info) {
String filename = info.getFilename();
FileCopier fc = new FileCopier(filename);
try {
ImgChannel chan = outfs.create(createImgFilename(filename));
((FileLink) chan).link(info.subFiles().get(0), fc.file(chan));
} catch (FileExistsException e) {
log.warn("Counld not copy " + filename, e);
}
}
use of uk.me.parabola.imgfmt.FileExistsException in project mkgmap by openstreetmap.
the class FileCopier method addMdrFile.
/**
* Add or retrieve the MDR file for the given familyId.
* @param familyId The family id to create the mdr file for.
* @param sort The sort for this family id.
* @return If there is already an mdr file for this family then it is returned, else the newly created
* one.
*/
private MdrBuilder addMdrFile(int familyId, Sort sort) {
MdrBuilder mdrBuilder = mdrBuilderMap.get(familyId);
if (mdrBuilder != null)
return mdrBuilder;
mdrBuilder = new MdrBuilder();
try {
String imgname = String.format("%08d.MDR", familyId);
ImgChannel chan = imgFs.create(imgname);
mdrBuilder.initForDevice(chan, sort, mdrConfig);
} catch (FileExistsException e) {
System.err.println("Could not create duplicate MDR file");
}
mdrBuilderMap.put(familyId, mdrBuilder);
return mdrBuilder;
}
use of uk.me.parabola.imgfmt.FileExistsException in project mkgmap by openstreetmap.
the class FileCopier method writeSrtFile.
/**
* Write the SRT file.
*
* @param imgFs The filesystem to create the SRT file in.
* @throws FileNotWritableException If it cannot be created.
*/
private void writeSrtFile(FileSystem imgFs) throws FileNotWritableException {
for (Map.Entry<Integer, Sort> ent : sortMap.entrySet()) {
Sort sort = ent.getValue();
int familyId = ent.getKey();
if (sort.getId1() == 0 && sort.getId2() == 0)
return;
try {
ImgChannel channel = imgFs.create(String.format("%08d.SRT", familyId));
SRTFile srtFile = new SRTFile(channel);
srtFile.setSort(sort);
srtFile.write();
// Do not close srtFile here
} catch (FileExistsException e) {
// well it shouldn't exist!
log.error("could not create SRT file as it exists already");
throw new FileNotWritableException("already existed", e);
}
}
}
use of uk.me.parabola.imgfmt.FileExistsException 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);
}
}
Aggregations