use of uk.me.parabola.imgfmt.app.trergn.TREFile 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.app.trergn.TREFile in project mkgmap by openstreetmap.
the class Map method createMap.
/**
* Create a complete map. This consists of (at least) three
* files that all have the same basename and different extensions.
*
* @param mapname The name of the map. This is an 8 digit number as a
* string.
* @param params Parameters that describe the file system that the map
* will be created in.
* @return A map object that holds together all the files that make it up.
* @throws FileExistsException If the file already exists and we do not
* want to overwrite it.
* @throws FileNotWritableException If the file cannot
* be opened for write.
*/
public static Map createMap(String mapname, String outputdir, FileSystemParam params, String mapnumber, Sort sort) throws FileExistsException, FileNotWritableException {
Map m = new Map();
m.mapName = mapname;
String outFilename = Utils.joinPath(outputdir, mapname, "img");
FileSystem fs = ImgFS.createFs(outFilename, params);
m.filename = outFilename;
m.fileSystem = fs;
m.rgnFile = new RGNFile(m.fileSystem.create(mapnumber + ".RGN"));
m.treFile = new TREFile(m.fileSystem.create(mapnumber + ".TRE"));
m.lblFile = new LBLFile(m.fileSystem.create(mapnumber + ".LBL"), sort);
int mapid;
try {
mapid = Integer.parseInt(mapnumber);
} catch (NumberFormatException e) {
mapid = 0;
}
m.mapId = mapid;
m.treFile.setMapId(mapid);
m.fileSystem = fs;
return m;
}
Aggregations