Search in sources :

Example 1 with Subdivision

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

the class AbstractTestMap method makeMap.

protected void makeMap(String[] args) {
    // Default to nowhere in particular.
    double lat = 51.724;
    double lng = 0.2487;
    // Arguments allow you to place the map where ever you wish.
    if (args.length > 1) {
        lat = Double.valueOf(args[0]);
        lng = Double.valueOf(args[1]);
    }
    log.debug("this is a test make map program. Start", lat, '/', lng);
    FileSystemParam params = new FileSystemParam();
    params.setBlockSize(512);
    params.setMapDescription("OSM street map");
    Map map;
    try {
        map = Map.createMap("32860003", ".", params, "32860003", SrtTextReader.sortForCodepage(1252));
    } catch (FileExistsException e) {
        throw new ExitException("File exists already", e);
    } catch (FileNotWritableException e) {
        throw new ExitException("Could not create or write file", e);
    }
    map.addInfo("Program released under the GPL");
    map.addInfo("This map data is made available under the Open Database License:");
    // There has to be (at least) two copyright messages or else the map
    // does not show up.  The second one will be displayed at startup,
    // although the conditions where that happens are not known.
    map.addCopyright("program licenced under GPL v2");
    // This one gets shown when you switch on, so put the actual
    // map copyright here.  This is made up data, so no copyright applies.
    map.addCopyright("No copyright");
    Area area = new Area(lat, lng, lat + 1, lng + 1);
    map.setBounds(area);
    // There must always be an empty zoom level at the least detailed level.
    log.info("area " + area);
    log.info(" or " + lat + '/' + lng);
    Zoom z1 = map.createZoom(1, 24);
    Subdivision topdiv = map.topLevelSubdivision(area, z1);
    // Create a most detailed view
    Zoom z = map.createZoom(0, 24);
    Subdivision div = map.createSubdivision(topdiv, area, z);
    div.startDivision();
    drawTestMap(map, div, lat, lng);
    map.close();
}
Also used : Area(uk.me.parabola.imgfmt.app.Area) FileSystemParam(uk.me.parabola.imgfmt.FileSystemParam) FileNotWritableException(uk.me.parabola.imgfmt.FileNotWritableException) Zoom(uk.me.parabola.imgfmt.app.trergn.Zoom) Subdivision(uk.me.parabola.imgfmt.app.trergn.Subdivision) Map(uk.me.parabola.imgfmt.app.map.Map) ExitException(uk.me.parabola.imgfmt.ExitException) FileExistsException(uk.me.parabola.imgfmt.FileExistsException)

Example 2 with Subdivision

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

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

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

the class MapBuilder method makeSubdivision.

/**
 * Make an individual subdivision for the map.  To do this we need a link
 * to its parent and the zoom level that we are working at.
 *
 * @param map	The map to add this subdivision into.
 * @param parent The parent division.
 * @param ma	 The area of the map that we are fitting into this division.
 * @param z	  The zoom level.
 * @return The new subdivsion.
 */
private Subdivision makeSubdivision(Map map, Subdivision parent, MapArea ma, Zoom z) {
    List<MapPoint> points = ma.getPoints();
    List<MapLine> lines = ma.getLines();
    List<MapShape> shapes = ma.getShapes();
    Subdivision div = map.createSubdivision(parent, ma.getFullBounds(), z);
    if (ma.hasPoints())
        div.setHasPoints(true);
    if (ma.hasIndPoints())
        div.setHasIndPoints(true);
    if (ma.hasLines())
        div.setHasPolylines(true);
    if (ma.hasShapes())
        div.setHasPolygons(true);
    div.startDivision();
    processPoints(map, div, points);
    processLines(map, div, lines);
    processShapes(map, div, shapes);
    div.endDivision();
    return div;
}
Also used : MapLine(uk.me.parabola.mkgmap.general.MapLine) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) Subdivision(uk.me.parabola.imgfmt.app.trergn.Subdivision) MapShape(uk.me.parabola.mkgmap.general.MapShape)

Example 5 with Subdivision

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

the class MapBuilder method makeTopArea.

/**
 * Create the top level subdivision.
 *
 * There must be an empty zoom level at the least detailed level. As it
 * covers the whole area in one it must be zoomed out enough so that
 * this can be done.
 *
 * Note that the width is a 16 bit quantity, but the top bit is a
 * flag and so that leaves only 15 bits into which the actual width
 * can fit.
 *
 * @param src  The source of map data.
 * @param map  The map being created.
 * @param zoom The zoom level.
 * @return The new top level subdivision.
 */
private static Subdivision makeTopArea(MapDataSource src, Map map, Zoom zoom) {
    Subdivision topdiv = map.topLevelSubdivision(src.getBounds(), zoom);
    topdiv.setLast(true);
    return topdiv;
}
Also used : Subdivision(uk.me.parabola.imgfmt.app.trergn.Subdivision)

Aggregations

Subdivision (uk.me.parabola.imgfmt.app.trergn.Subdivision)8 ArrayList (java.util.ArrayList)4 ExitException (uk.me.parabola.imgfmt.ExitException)2 Point (uk.me.parabola.imgfmt.app.trergn.Point)2 Zoom (uk.me.parabola.imgfmt.app.trergn.Zoom)2 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)2 FileExistsException (uk.me.parabola.imgfmt.FileExistsException)1 FileNotWritableException (uk.me.parabola.imgfmt.FileNotWritableException)1 FileSystemParam (uk.me.parabola.imgfmt.FileSystemParam)1 Area (uk.me.parabola.imgfmt.app.Area)1 Map (uk.me.parabola.imgfmt.app.map.Map)1 InternalFiles (uk.me.parabola.imgfmt.app.trergn.InternalFiles)1 Polygon (uk.me.parabola.imgfmt.app.trergn.Polygon)1 Polyline (uk.me.parabola.imgfmt.app.trergn.Polyline)1 LevelInfo (uk.me.parabola.mkgmap.general.LevelInfo)1 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)1 MapLine (uk.me.parabola.mkgmap.general.MapLine)1 MapShape (uk.me.parabola.mkgmap.general.MapShape)1 OverviewMapDataSource (uk.me.parabola.mkgmap.reader.overview.OverviewMapDataSource)1