Search in sources :

Example 1 with Polyline

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

the class MapReader method linesForLevel.

/**
 * Get a list of all the lines for a given level.
 * @param level The level, lower numbers are the most detailed.
 */
public List<Polyline> linesForLevel(int level) {
    ArrayList<Polyline> lines = new ArrayList<Polyline>();
    Subdivision[] subdivisions = treFile.subdivForLevel(level);
    for (Subdivision div : subdivisions) {
        List<Polyline> subdivLines = rgnFile.linesForSubdiv(div);
        lines.addAll(subdivLines);
    }
    return lines;
}
Also used : Polyline(uk.me.parabola.imgfmt.app.trergn.Polyline) ArrayList(java.util.ArrayList) Subdivision(uk.me.parabola.imgfmt.app.trergn.Subdivision)

Example 2 with Polyline

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

the class SimpleTest method testBasic.

/**
 * A very basic check that the size of all the sections has not changed.
 * This can be used to make sure that a change that is not expected to
 * change the output does not do so.
 *
 * The sizes will have to be always changed when the output does change
 * though.
 */
@Test
public void testBasic() throws FileNotFoundException {
    Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--preserve-element-order", Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz");
    MapReader mr = new MapReader(Args.DEF_MAP_ID + ".img");
    TestUtils.registerFile(mr);
    // FileSystem fs = ImgFS.openFs(Args.DEF_MAP_ID + ".img");
    assertNotNull("file exists", mr);
    Area bounds = mr.getTreBounds();
    Area expBox = new Area(2402404, -11185, 2407064, -6524);
    assertEquals("bounds of map", expBox, bounds);
    List<Point> list = mr.pointsForLevel(0, MapReader.WITH_EXT_TYPE_DATA);
    assertEquals("number of points at level 0", 204, list.size());
    List<Polyline> list1 = mr.linesForLevel(0);
    assertEquals("number of lines at level 0", 3382, list1.size());
}
Also used : Area(uk.me.parabola.imgfmt.app.Area) MapReader(uk.me.parabola.imgfmt.app.map.MapReader) Polyline(uk.me.parabola.imgfmt.app.trergn.Polyline) Point(uk.me.parabola.imgfmt.app.trergn.Point) Test(org.junit.Test)

Example 3 with Polyline

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

the class MakeTestLangMap method drawStreetnames.

private void drawStreetnames(Map map, Subdivision div, double slat, double slon) {
    char[] hexChars = "0123456789ABCDEF".toCharArray();
    double lat = slat + 0.004;
    double lon = slon + 0.002;
    div.startLines();
    map.setLabelCharset("simple8", true);
    double space = 0.002;
    double size = 0.006;
    for (int y = 0; y < 16; y++) {
        int start = 128 + 8 * y;
        char[] out = new char[19];
        out[0] = hexChars[(start & 0xf0) >> 4];
        out[1] = hexChars[(start & 0x0f)];
        out[2] = ' ';
        for (int i = 0; i < 8; i++) {
            out[3 + 2 * i] = (char) ('A' + i);
            out[3 + 2 * i + 1] = (char) (start + i);
        }
        String name = new String(out);
        Polyline l = div.createLine(new String[] { name, null, null, null });
        double baseLat = lat + y * space;
        Coord co = new Coord(baseLat, lon);
        l.addCoord(co);
        co = new Coord(baseLat, lon + size);
        l.addCoord(co);
        l.setType(6);
        map.addMapObject(l);
    }
    map.addPolylineOverview(new PolylineOverview(0x600, 10));
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) PolylineOverview(uk.me.parabola.imgfmt.app.trergn.PolylineOverview) Polyline(uk.me.parabola.imgfmt.app.trergn.Polyline)

Example 4 with Polyline

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

Polyline (uk.me.parabola.imgfmt.app.trergn.Polyline)4 Coord (uk.me.parabola.imgfmt.app.Coord)2 Point (uk.me.parabola.imgfmt.app.trergn.Point)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Area (uk.me.parabola.imgfmt.app.Area)1 MapReader (uk.me.parabola.imgfmt.app.map.MapReader)1 PolylineOverview (uk.me.parabola.imgfmt.app.trergn.PolylineOverview)1 Subdivision (uk.me.parabola.imgfmt.app.trergn.Subdivision)1 Zoom (uk.me.parabola.imgfmt.app.trergn.Zoom)1 MapLine (uk.me.parabola.mkgmap.general.MapLine)1 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)1