Search in sources :

Example 1 with Point

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

the class MDRFile method addPoint.

public void addPoint(Point point, Mdr5Record city, boolean isCity) {
    assert currentMap > 0;
    int fullType = point.getType();
    if (!MdrUtils.canBeIndexed(fullType))
        return;
    if (!poiExclTypes.isEmpty()) {
        int t = (fullType < 0xff) ? fullType << 8 : fullType;
        if (poiExclTypes.contains(t))
            return;
    }
    Label label = point.getLabel();
    String name = label.getText();
    int strOff = createString(name);
    Mdr11Record poi = mdr11.addPoi(currentMap, point, name, strOff);
    poi.setCity(city);
    poi.setIsCity(isCity);
    poi.setType(fullType);
    mdr4.addType(fullType);
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) Point(uk.me.parabola.imgfmt.app.trergn.Point)

Example 2 with Point

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

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

the class MapBuilder method preserveHorizontalAndVerticalLines.

/**
 * Preserve shape points which a) lie on the shape boundary or
 * b) which appear multiple times in the shape (excluding the start
 * point which should always be identical to the end point).
 * The preserved points are kept treated specially in the
 * Line-Simplification-Filters, this should avoid artifacts like
 * white triangles in the sea for lower resolutions.
 * @param res the current resolution
 * @param shapes list of shapes
 */
private static void preserveHorizontalAndVerticalLines(int res, List<MapShape> shapes) {
    if (res == 24)
        return;
    for (MapShape shape : shapes) {
        if (shape.getMinResolution() > res)
            continue;
        int minLat = shape.getBounds().getMinLat();
        int maxLat = shape.getBounds().getMaxLat();
        int minLon = shape.getBounds().getMinLong();
        int maxLon = shape.getBounds().getMaxLong();
        List<Coord> points = shape.getPoints();
        int n = shape.getPoints().size();
        IdentityHashMap<Coord, Coord> coords = new IdentityHashMap<>(n);
        Coord first = points.get(0);
        Coord prev = first;
        Coord last = first;
        for (int i = 1; i < points.size(); ++i) {
            last = points.get(i);
            // to connect holes
            if (coords.get(last) == null) {
                coords.put(last, last);
            } else {
                if (!last.preserved()) {
                    last.preserved(true);
                }
            }
            // on the bbox of the shape.
            if (last.getLatitude() == prev.getLatitude() && (last.getLatitude() == minLat || last.getLatitude() == maxLat) || last.getLongitude() == prev.getLongitude() && (last.getLongitude() == minLon || last.getLongitude() == maxLon)) {
                last.preserved(true);
                prev.preserved(true);
            }
            prev = last;
        }
    }
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) IdentityHashMap(java.util.IdentityHashMap) MapShape(uk.me.parabola.mkgmap.general.MapShape) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point)

Example 4 with Point

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

the class MdrBuilder method addPoints.

/**
 * Read points from this map and add them to the index.
 * @param mr The currently open map.
 * @param maps Maps of regions, cities countries etc.
 */
private void addPoints(MapReader mr, AreaMaps maps) {
    List<Point> list = mr.pointsForLevel(0, MapReader.WITHOUT_EXT_TYPE_DATA);
    for (Point p : list) {
        Label label = p.getLabel();
        if (p.getNumber() > 256) {
            continue;
        }
        Mdr5Record mdrCity = null;
        boolean isCity;
        if (p.getType() >= 0x1 && p.getType() <= 0x11) {
            // This is itself a city, it gets a reference to its own MDR 5 record.
            // and we also use it to set the name of the city.
            mdrCity = maps.cities.get((p.getSubdiv().getNumber() << 8) + p.getNumber());
            if (mdrCity != null) {
                mdrCity.setLblOffset(label.getOffset());
                mdrCity.setName(label.getText());
            }
            isCity = true;
        } else {
            // This is not a city, but we have information about which city
            // it is in.  If so then add the mdr5 record number of the city.
            POIRecord poi = p.getPOIRecord();
            City c = poi.getCity();
            if (c != null)
                mdrCity = getMdr5FromCity(maps, c);
            isCity = false;
        }
        if (label != null && !label.getText().trim().isEmpty())
            mdrFile.addPoint(p, mdrCity, isCity);
    }
}
Also used : Mdr5Record(uk.me.parabola.imgfmt.app.mdr.Mdr5Record) Label(uk.me.parabola.imgfmt.app.Label) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) Point(uk.me.parabola.imgfmt.app.trergn.Point) City(uk.me.parabola.imgfmt.app.lbl.City)

Example 5 with Point

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

the class OverviewBuilder method readPoints.

/**
 * Read the points 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 readPoints(MapReader mapReader) {
    Area bounds = overviewSource.getBounds();
    Zoom[] levels = mapReader.getLevels();
    for (int l = 1; l < levels.length; l++) {
        int min = levels[l].getLevel();
        int res = levels[l].getResolution();
        List<Point> pointList = mapReader.pointsForLevel(min, MapReader.WITH_EXT_TYPE_DATA);
        for (Point point : pointList) {
            if (log.isDebugEnabled())
                log.debug("got point", point);
            if (bounds.contains(point.getLocation()) == false) {
                if (log.isDebugEnabled())
                    log.debug(point, "dropped, is outside of tile boundary");
                continue;
            }
            MapPoint mp = new MapPoint();
            mp.setType(point.getType());
            if (point.getLabel() != null) {
                mp.setName(point.getLabel().getText());
            }
            mp.setMaxResolution(res);
            mp.setMinResolution(res);
            mp.setLocation(point.getLocation());
            overviewSource.addPoint(mp);
        }
    }
}
Also used : Area(uk.me.parabola.imgfmt.app.Area) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) Zoom(uk.me.parabola.imgfmt.app.trergn.Zoom) Point(uk.me.parabola.imgfmt.app.trergn.Point) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) 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