Search in sources :

Example 1 with Area

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

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

the class DEMFile method calcTREBounds.

private Area calcTREBounds(Area area, int alignment) {
    int treTop = area.getMaxLat() + 1;
    int treLeft = area.getMinLong() - 1;
    int treBottom = area.getMinLat() + 1;
    int treRight = area.getMaxLong() - 1;
    while (treTop % alignment != 0) ++treTop;
    while (treLeft % alignment != 0) --treLeft;
    while (treBottom % alignment != 0) ++treBottom;
    while (treRight % alignment != 0) --treRight;
    treBottom -= alignment;
    treRight += alignment;
    treRight = Math.min(treRight, Utils.MAX_LON_MAP_UNITS);
    treLeft = Math.max(treLeft, Utils.MIN_LON_MAP_UNITS);
    treTop = Math.min(treTop, Utils.MAX_LAT_MAP_UNITS);
    treBottom = Math.max(treBottom, Utils.MIN_LAT_MAP_UNITS);
    Area treArea = new Area(treBottom, treLeft, treTop, treRight);
    return treArea;
}
Also used : Area(uk.me.parabola.imgfmt.app.Area)

Example 3 with Area

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

the class DEMFile method calc.

/**
 * Calculate the DEM data for a tile.
 *
 * @param area
 *            the bounding box of the tile
 * @param demPolygonMapUnits
 *            a bounding polygon which might be smaller than the area
 * @param pathToHGT
 *            comma separated list of directories or zip files
 * @param pointDistances
 *            list of distances which determine the resolution
 * @param outsidePolygonHeight
 *            the height value that should be used for points outside of the
 *            bounding polygon
 * @return a new bounding box that should be used for the TRE file
 */
public Area calc(Area area, java.awt.geom.Area demPolygonMapUnits, String pathToHGT, List<Integer> pointDistances, short outsidePolygonHeight, InterpolationMethod interpolationMethod) {
    // HGT area is extended by EXTRA degrees in each direction
    HGTConverter hgtConverter = new HGTConverter(pathToHGT, area, demPolygonMapUnits, EXTRA);
    hgtConverter.setInterpolationMethod(interpolationMethod);
    hgtConverter.setOutsidePolygonHeight(outsidePolygonHeight);
    log.info("orig bounds", area);
    int alignment = 4;
    Area treArea = calcTREBounds(area, alignment);
    log.info("TRE bounds", treArea);
    int top = treArea.getMaxLat() * 256;
    int bottom = treArea.getMinLat() * 256;
    int left = treArea.getMinLong() * 256;
    int right = treArea.getMaxLong() * 256;
    int zoom = 0;
    int lastDist = pointDistances.get(pointDistances.size() - 1);
    for (int pointDist : pointDistances) {
        int distance = pointDist;
        if (distance == -1) {
            int res = (hgtConverter.getHighestRes() > 0) ? hgtConverter.getHighestRes() : 1200;
            distance = (int) Math.round((1 << 29) / (res * 45.0D));
        }
        // last 4 bits of distance should be 0
        distance = ((distance + 8) / 16) * 16;
        int xTop = top;
        int xLeft = left;
        // widening of HGT area
        if (distance < (int) Math.floor((EXTRA / 45.0D * (1 << 29)))) {
            xTop = moveUp(top, distance);
            xLeft = moveLeft(left, distance);
        }
        DEMSection section = new DEMSection(zoom++, xTop, xLeft, xTop - bottom, right - xLeft, hgtConverter, distance, pointDist == lastDist);
        demHeader.addSection(section);
    }
    return treArea;
}
Also used : Area(uk.me.parabola.imgfmt.app.Area) HGTConverter(uk.me.parabola.mkgmap.reader.hgt.HGTConverter)

Example 4 with Area

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

the class OsmHandler method setBBox.

/**
 * Actually set the bounding box.  The boundary values are given.
 */
protected void setBBox(double minlat, double minlong, double maxlat, double maxlong) {
    if (minlat == maxlat || minlong == maxlong) {
        // silently ignore bounds with dim 0
        return;
    }
    Area bbox = new Area(minlat, minlong, maxlat, maxlong);
    saver.setBoundingBox(bbox);
}
Also used : Area(uk.me.parabola.imgfmt.app.Area)

Example 5 with Area

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

Aggregations

Area (uk.me.parabola.imgfmt.app.Area)49 Test (org.junit.Test)26 Coord (uk.me.parabola.imgfmt.app.Coord)14 ArrayList (java.util.ArrayList)9 List (java.util.List)7 MapShape (uk.me.parabola.mkgmap.general.MapShape)4 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)3 Way (uk.me.parabola.mkgmap.reader.osm.Way)3 Rectangle (java.awt.Rectangle)2 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ExitException (uk.me.parabola.imgfmt.ExitException)2 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)2 Point (uk.me.parabola.imgfmt.app.trergn.Point)2 Zoom (uk.me.parabola.imgfmt.app.trergn.Zoom)2 Element (uk.me.parabola.mkgmap.reader.osm.Element)2 Node (uk.me.parabola.mkgmap.reader.osm.Node)2 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1