Search in sources :

Example 6 with Point

use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.

the class OverviewBuilder method readShapes.

/**
 * Read the polygons from the .img file and add them to the overview map.
 * We read from the least detailed level (apart from the empty one).
 *
 * @param mapReader Map reader on the detailed .img file.
 */
private void readShapes(MapReader mapReader) {
    Zoom[] levels = mapReader.getLevels();
    for (int l = 1; l < levels.length; l++) {
        int min = levels[l].getLevel();
        int res = levels[l].getResolution();
        List<Polygon> list = mapReader.shapesForLevel(min, MapReader.WITH_EXT_TYPE_DATA);
        for (Polygon shape : list) {
            if (log.isDebugEnabled())
                log.debug("got polygon", shape);
            if (shape.getType() == 0x4b) {
                hasBackground = true;
            }
            MapShape ms = new MapShape();
            List<Coord> points = shape.getPoints();
            if (log.isDebugEnabled())
                log.debug("polygon point list", points);
            if (points.size() < 3)
                continue;
            ms.setType(shape.getType());
            if (shape.getLabel() != null)
                ms.setName(shape.getLabel().getText());
            ms.setMaxResolution(res);
            ms.setMinResolution(res);
            ms.setPoints(points);
            overviewSource.addShape(ms);
        }
    }
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) Zoom(uk.me.parabola.imgfmt.app.trergn.Zoom) Polygon(uk.me.parabola.imgfmt.app.trergn.Polygon) MapShape(uk.me.parabola.mkgmap.general.MapShape) Point(uk.me.parabola.imgfmt.app.trergn.Point) MapPoint(uk.me.parabola.mkgmap.general.MapPoint)

Example 7 with Point

use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.

the class MapReader method pointsForLevel.

/**
 * Get a list of all the points for a given level.
 * @param level The level, lower numbers are the most detailed.
 */
public List<Point> pointsForLevel(int level, boolean withExtType) {
    List<Point> points = new ArrayList<Point>();
    Subdivision[] subdivisions = treFile.subdivForLevel(level);
    for (Subdivision sd : subdivisions) {
        List<Point> subdivPoints = rgnFile.pointsForSubdiv(sd, withExtType);
        points.addAll(subdivPoints);
    }
    return points;
}
Also used : ArrayList(java.util.ArrayList) Point(uk.me.parabola.imgfmt.app.trergn.Point) Subdivision(uk.me.parabola.imgfmt.app.trergn.Subdivision)

Example 8 with Point

use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.

the class MapBuilder method processPoints.

/**
 * Step through the points, filter and create a map point which is then added
 * to the map.
 *
 * Note that the location and resolution of map elements is relative to the
 * subdivision that they occur in.
 *
 * @param map	The map to add points to.
 * @param div	The subdivision that the points belong to.
 * @param points The points to be added.
 */
private void processPoints(Map map, Subdivision div, List<MapPoint> points) {
    LBLFile lbl = map.getLblFile();
    div.startPoints();
    int res = div.getResolution();
    boolean haveIndPoints = false;
    int pointIndex = 1;
    // points (not 1)
    for (MapPoint point : points) {
        if (point.isCity() && point.getMinResolution() <= res) {
            ++pointIndex;
            haveIndPoints = true;
        }
    }
    for (MapPoint point : points) {
        if (point.isCity() || point.getMinResolution() > res)
            continue;
        String name = point.getName();
        Point p = div.createPoint(name);
        p.setType(point.getType());
        if (point.hasExtendedType()) {
            ExtTypeAttributes eta = point.getExtTypeAttributes();
            if (eta != null) {
                eta.processLabels(lbl);
                p.setExtTypeAttributes(eta);
            }
        }
        Coord coord = point.getLocation();
        try {
            p.setLatitude(coord.getLatitude());
            p.setLongitude(coord.getLongitude());
        } catch (AssertionError ae) {
            log.error("Problem with point of type 0x" + Integer.toHexString(point.getType()) + " at " + coord.toOSMURL());
            log.error("  Subdivision shift is " + div.getShift() + " and its centre is at " + div.getCenter().toOSMURL());
            log.error("  " + ae.getMessage());
            continue;
        }
        POIRecord r = poimap.get(point);
        if (r != null)
            p.setPOIRecord(r);
        map.addMapObject(p);
        if (!point.hasExtendedType()) {
            if (name != null && div.getZoom().getLevel() == 0) {
                if (pointIndex > 255)
                    log.error("Too many POIs at location " + div.getCenter().toOSMURL() + " - " + name + " will be ignored");
                else if (point.isExit()) {
                    Exit e = ((MapExitPoint) point).getExit();
                    if (e != null)
                        e.getHighway().addExitPoint(name, pointIndex, div);
                } else if (makePOIIndex)
                    lbl.createPOIIndex(name, pointIndex, div, point.getType());
            }
            ++pointIndex;
        }
    }
    if (haveIndPoints) {
        div.startIndPoints();
        // reset to 1
        pointIndex = 1;
        for (MapPoint point : points) {
            if (!point.isCity() || point.getMinResolution() > res)
                continue;
            String name = point.getName();
            Point p = div.createPoint(name);
            p.setType(point.getType());
            Coord coord = point.getLocation();
            try {
                p.setLatitude(coord.getLatitude());
                p.setLongitude(coord.getLongitude());
            } catch (AssertionError ae) {
                log.error("Problem with point of type 0x" + Integer.toHexString(point.getType()) + " at " + coord.toOSMURL());
                log.error("  Subdivision shift is " + div.getShift() + " and its centre is at " + div.getCenter().toOSMURL());
                log.error("  " + ae.getMessage());
                continue;
            }
            map.addMapObject(p);
            if (name != null && div.getZoom().getLevel() == 0) {
                // retrieve the City created earlier for this
                // point and store the point info in it
                City c = cityMap.get(point);
                if (pointIndex > 255) {
                    System.err.println("Can't set city point index for " + name + " (too many indexed points in division)\n");
                } else {
                    c.setPointIndex((byte) pointIndex);
                    c.setSubdivision(div);
                }
            }
            ++pointIndex;
        }
    }
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) ExtTypeAttributes(uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point) City(uk.me.parabola.imgfmt.app.lbl.City) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point) Exit(uk.me.parabola.imgfmt.app.Exit)

Example 9 with Point

use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.

the class OverviewBuilder method readLines.

/**
 * Read the lines from the .img file and add them to the overview map.
 * We read from the least detailed level (apart from the empty one).
 *
 * @param mapReader Map reader on the detailed .img file.
 */
private void readLines(MapReader mapReader) {
    Zoom[] levels = mapReader.getLevels();
    for (int l = 1; l < levels.length; l++) {
        int min = levels[l].getLevel();
        int res = levels[l].getResolution();
        List<Polyline> lineList = mapReader.linesForLevel(min);
        // System.out.println(lineList.size() + " lines in lowest resolution " + levels[1].getResolution());
        for (Polyline line : lineList) {
            if (log.isDebugEnabled())
                log.debug("got line", line);
            MapLine ml = new MapLine();
            List<Coord> points = line.getPoints();
            if (log.isDebugEnabled())
                log.debug("line point list", points);
            if (points.size() < 2)
                continue;
            ml.setType(line.getType());
            if (line.getLabel() != null)
                ml.setName(line.getLabel().getText());
            ml.setMaxResolution(res);
            ml.setMinResolution(res);
            ml.setPoints(points);
            overviewSource.addLine(ml);
        }
    }
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) MapLine(uk.me.parabola.mkgmap.general.MapLine) Polyline(uk.me.parabola.imgfmt.app.trergn.Polyline) Zoom(uk.me.parabola.imgfmt.app.trergn.Zoom) Point(uk.me.parabola.imgfmt.app.trergn.Point) MapPoint(uk.me.parabola.mkgmap.general.MapPoint)

Aggregations

Point (uk.me.parabola.imgfmt.app.trergn.Point)9 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)5 Coord (uk.me.parabola.imgfmt.app.Coord)4 Zoom (uk.me.parabola.imgfmt.app.trergn.Zoom)3 Area (uk.me.parabola.imgfmt.app.Area)2 Label (uk.me.parabola.imgfmt.app.Label)2 City (uk.me.parabola.imgfmt.app.lbl.City)2 POIRecord (uk.me.parabola.imgfmt.app.lbl.POIRecord)2 Polyline (uk.me.parabola.imgfmt.app.trergn.Polyline)2 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)2 MapShape (uk.me.parabola.mkgmap.general.MapShape)2 ArrayList (java.util.ArrayList)1 IdentityHashMap (java.util.IdentityHashMap)1 Test (org.junit.Test)1 Exit (uk.me.parabola.imgfmt.app.Exit)1 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)1 MapReader (uk.me.parabola.imgfmt.app.map.MapReader)1 Mdr5Record (uk.me.parabola.imgfmt.app.mdr.Mdr5Record)1 ExtTypeAttributes (uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes)1 Polygon (uk.me.parabola.imgfmt.app.trergn.Polygon)1