use of uk.me.parabola.mkgmap.reader.MapperBasedMapDataSource 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();
}
Aggregations