Search in sources :

Example 1 with RouteCenter

use of uk.me.parabola.imgfmt.app.net.RouteCenter 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();
}
Also used : MapperBasedMapDataSource(uk.me.parabola.mkgmap.reader.MapperBasedMapDataSource) TREFile(uk.me.parabola.imgfmt.app.trergn.TREFile) MapFailedException(uk.me.parabola.imgfmt.MapFailedException) RGNFile(uk.me.parabola.imgfmt.app.trergn.RGNFile) Path2D(java.awt.geom.Path2D) Rectangle2D(java.awt.geom.Rectangle2D) RouteCenter(uk.me.parabola.imgfmt.app.net.RouteCenter) NODFile(uk.me.parabola.imgfmt.app.net.NODFile) DEMFile(uk.me.parabola.imgfmt.app.dem.DEMFile) Area(uk.me.parabola.imgfmt.app.Area) RoadNetwork(uk.me.parabola.imgfmt.app.net.RoadNetwork) NETFile(uk.me.parabola.imgfmt.app.net.NETFile) OverviewMapDataSource(uk.me.parabola.mkgmap.reader.overview.OverviewMapDataSource)

Aggregations

Path2D (java.awt.geom.Path2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)1 Area (uk.me.parabola.imgfmt.app.Area)1 DEMFile (uk.me.parabola.imgfmt.app.dem.DEMFile)1 NETFile (uk.me.parabola.imgfmt.app.net.NETFile)1 NODFile (uk.me.parabola.imgfmt.app.net.NODFile)1 RoadNetwork (uk.me.parabola.imgfmt.app.net.RoadNetwork)1 RouteCenter (uk.me.parabola.imgfmt.app.net.RouteCenter)1 RGNFile (uk.me.parabola.imgfmt.app.trergn.RGNFile)1 TREFile (uk.me.parabola.imgfmt.app.trergn.TREFile)1 MapperBasedMapDataSource (uk.me.parabola.mkgmap.reader.MapperBasedMapDataSource)1 OverviewMapDataSource (uk.me.parabola.mkgmap.reader.overview.OverviewMapDataSource)1