use of uk.me.parabola.imgfmt.MapFailedException in project mkgmap by openstreetmap.
the class RoadDef method writeRgnOffsets.
/**
* Write into the RGN the offset in net1 of this road.
* @param rgn A writer for the rgn file.
*/
void writeRgnOffsets(ImgFileWriter rgn) {
if (offsetNet1 >= 0x400000)
throw new MapFailedException("Overflow of the NET1. The tile (" + log.threadTag() + ") must be split so that there are fewer roads in it");
for (Offset off : rgnOffsets) {
rgn.position(off.getPosition());
rgn.put3(offsetNet1 | off.getFlags());
}
}
use of uk.me.parabola.imgfmt.MapFailedException in project mkgmap by openstreetmap.
the class MapBuilder method makeMap.
/**
* Main method to create the map, just calls out to several routines
* that do the work.
*
* @param map The map.
* @param src The map data.
*/
public void makeMap(Map map, LoadableMapDataSource src) {
RGNFile rgnFile = map.getRgnFile();
TREFile treFile = map.getTreFile();
lblFile = map.getLblFile();
NETFile netFile = map.getNetFile();
DEMFile demFile = map.getDemFile();
if (routeCenterBoundaryType != 0 && netFile != null && src instanceof MapperBasedMapDataSource) {
for (RouteCenter rc : src.getRoadNetwork().getCenters()) {
((MapperBasedMapDataSource) src).addBoundaryLine(rc.getArea(), routeCenterBoundaryType, rc.reportSizes());
}
}
if (mapInfo.isEmpty())
getMapInfo();
normalizeCountries(src);
processCities(map, src);
processRoads(map, src);
processPOIs(map, src);
processOverviews(map, src);
processInfo(map, src);
makeMapAreas(map, src);
if (driveOnLeft == null) {
// check if source gives info about driving side
if (src instanceof MapperBasedMapDataSource) {
driveOnLeft = ((MapperBasedMapDataSource) src).getDriveOnLeft();
}
}
if (driveOnLeft == null)
driveOnLeft = false;
treFile.setDriveOnLeft(driveOnLeft);
treFile.setLastRgnPos(rgnFile.position() - RGNHeader.HEADER_LEN);
rgnFile.write();
treFile.write(rgnFile.haveExtendedTypes());
lblFile.write();
lblFile.writePost();
if (netFile != null) {
RoadNetwork network = src.getRoadNetwork();
netFile.setNetwork(network.getRoadDefs());
NODFile nodFile = map.getNodFile();
if (nodFile != null) {
nodFile.setNetwork(network.getCenters(), network.getRoadDefs(), network.getBoundary());
nodFile.setDriveOnLeft(driveOnLeft);
nodFile.write();
}
netFile.write(lblFile.numCities(), lblFile.numZips());
if (nodFile != null) {
nodFile.writePost();
}
netFile.writePost(rgnFile.getWriter());
}
warnAbout3ByteImgRefs();
if (demFile != null) {
try {
long t1 = System.currentTimeMillis();
java.awt.geom.Area demArea = null;
if (demPolygon != null) {
Area bbox = src.getBounds();
// the rectangle is a bit larger to avoid problems at tile boundaries
Rectangle2D r = new Rectangle2D.Double(bbox.getMinLong() - 2, bbox.getMinLat() - 2, bbox.getWidth() + 4, bbox.getHeight() + 4);
if (demPolygon.intersects(r) && !demPolygon.contains(r)) {
demArea = demPolygon;
}
}
if (demArea == null && src instanceof OverviewMapDataSource) {
Path2D demPoly = ((OverviewMapDataSource) src).getTileAreaPath();
if (demPoly != null) {
demArea = new java.awt.geom.Area(demPoly);
}
}
Area treArea = demFile.calc(src.getBounds(), demArea, pathToHGT, demDists, demOutsidePolygonHeight, demInterpolationMethod);
map.setBounds(treArea);
long t2 = System.currentTimeMillis();
log.info("DEM file calculation for", map.getFilename(), "took", (t2 - t1), "ms");
demFile.write();
} catch (MapFailedException e) {
log.error("exception while creating DEM file", e.getMessage());
// TODO: better remove DEM file?
throw new MapFailedException("DEM");
}
}
treFile.writePost();
}
use of uk.me.parabola.imgfmt.MapFailedException in project mkgmap by openstreetmap.
the class Main method mainStart.
/**
* The main program to make or combine maps. We now use a two pass process,
* first going through the arguments and make any maps and collect names
* to be used for creating summary files like the TDB and gmapsupp.
*
* @param args The command line arguments.
*/
private static int mainStart(String... args) {
Instant start = Instant.now();
System.out.println("Time started: " + new Date());
// We need at least one argument.
if (args.length < 1) {
printUsage();
printHelp(System.err, getLang(), "options");
return 0;
}
Main mm = new Main();
int numExitExceptions = 0;
try {
// Read the command line arguments and process each filename found.
CommandArgsReader commandArgs = new CommandArgsReader(mm);
commandArgs.setValidOptions(getValidOptions(System.err));
commandArgs.readArgs(args);
} catch (OutOfMemoryError e) {
++numExitExceptions;
System.err.println(e);
if (mm.maxJobs > 1)
System.err.println("Try using the mkgmap --max-jobs option with a value less than " + mm.maxJobs + " to reduce the memory requirement, or use the Java -Xmx option to increase the available heap memory.");
else
System.err.println("Try using the Java -Xmx option to increase the available heap memory.");
} catch (MapFailedException e) {
// one of the combiners failed
e.printStackTrace();
++numExitExceptions;
} catch (ExitException e) {
++numExitExceptions;
String message = e.getMessage();
Throwable cause = e.getCause();
while (cause != null) {
message += "\r\n" + cause.toString();
cause = cause.getCause();
}
System.err.println(message);
}
System.out.println("Number of ExitExceptions: " + numExitExceptions);
System.out.println("Time finished: " + new Date());
Duration duration = Duration.between(start, Instant.now());
long seconds = duration.getSeconds();
if (seconds > 0) {
long hours = seconds / 3600;
seconds -= hours * 3600;
long minutes = seconds / 60;
seconds -= minutes * 60;
System.out.println("Total time taken: " + (hours > 0 ? hours + (hours > 1 ? " hours " : " hour ") : "") + (minutes > 0 ? minutes + (minutes > 1 ? " minutes " : " minute ") : "") + (seconds > 0 ? seconds + (seconds > 1 ? " seconds" : " second") : ""));
} else
System.out.println("Total time taken: " + duration.getNano() / 1000000 + " ms");
if (numExitExceptions > 0 || mm.getProgramRC() != 0) {
return 1;
}
return 0;
}
use of uk.me.parabola.imgfmt.MapFailedException 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);
}
}
use of uk.me.parabola.imgfmt.MapFailedException in project mkgmap by openstreetmap.
the class TypCompiler method standAloneRun.
private void standAloneRun(String in, String out) {
CharsetProbe probe = new CharsetProbe();
String readCharset = probe.probeCharset(in);
TypData data;
try {
data = compile(in, readCharset, null);
} catch (SyntaxException e) {
System.out.println(e.getMessage());
return;
} catch (FileNotFoundException e) {
throw new MapFailedException("Could not open TYP file " + in + " to read");
}
try {
writeTyp(data, new File(out));
} catch (IOException e) {
System.out.println("Error writing file: " + e.getMessage());
}
}
Aggregations