Search in sources :

Example 1 with Polygon

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

the class MapReader method shapesForLevel.

public List<Polygon> shapesForLevel(int level, boolean witExtTypeData) {
    ArrayList<Polygon> shapes = new ArrayList<Polygon>();
    Subdivision[] subdivisions = treFile.subdivForLevel(level);
    for (Subdivision div : subdivisions) {
        List<Polygon> subdivShapes = rgnFile.shapesForSubdiv(div, witExtTypeData);
        shapes.addAll(subdivShapes);
    }
    return shapes;
}
Also used : ArrayList(java.util.ArrayList) Subdivision(uk.me.parabola.imgfmt.app.trergn.Subdivision) Polygon(uk.me.parabola.imgfmt.app.trergn.Polygon)

Example 2 with Polygon

use of uk.me.parabola.imgfmt.app.trergn.Polygon 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)

Aggregations

Polygon (uk.me.parabola.imgfmt.app.trergn.Polygon)2 ArrayList (java.util.ArrayList)1 Coord (uk.me.parabola.imgfmt.app.Coord)1 Point (uk.me.parabola.imgfmt.app.trergn.Point)1 Subdivision (uk.me.parabola.imgfmt.app.trergn.Subdivision)1 Zoom (uk.me.parabola.imgfmt.app.trergn.Zoom)1 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)1 MapShape (uk.me.parabola.mkgmap.general.MapShape)1