Search in sources :

Example 1 with MapFilterChain

use of uk.me.parabola.mkgmap.filters.MapFilterChain in project mkgmap by openstreetmap.

the class MapArea method addPolygons.

/**
 * Add the polygons
 * @param src The map data.
 * @param resolution The current resolution of the layer.
 */
private void addPolygons(MapDataSource src, final int resolution) {
    MapFilterChain chain = new MapFilterChain() {

        public void doFilter(MapElement element) {
            MapShape shape = (MapShape) element;
            addShape(shape);
        }
    };
    PolygonSubdivSizeSplitterFilter filter = new PolygonSubdivSizeSplitterFilter();
    FilterConfig config = new FilterConfig();
    config.setResolution(resolution);
    config.setBounds(bounds);
    filter.init(config);
    for (MapShape s : src.getShapes()) {
        if (s.getMaxResolution() < resolution)
            continue;
        if (splitPolygonsIntoArea || this.bounds.isEmpty() || this.bounds.contains(s.getBounds()))
            // if splitPolygonsIntoArea, don't want to have other splitting as well.
            // PolygonSubdivSizeSplitterFilter is a bit drastic - filters by both size and number of points
            // so use splitPolygonsIntoArea logic for this as well. This is fine as long as there
            // aren't bits of the shape outside the initial area.
            addShape(s);
        else
            filter.doFilter(s, chain);
    }
}
Also used : PolygonSubdivSizeSplitterFilter(uk.me.parabola.mkgmap.filters.PolygonSubdivSizeSplitterFilter) MapElement(uk.me.parabola.mkgmap.general.MapElement) FilterConfig(uk.me.parabola.mkgmap.filters.FilterConfig) MapFilterChain(uk.me.parabola.mkgmap.filters.MapFilterChain) MapShape(uk.me.parabola.mkgmap.general.MapShape)

Example 2 with MapFilterChain

use of uk.me.parabola.mkgmap.filters.MapFilterChain in project mkgmap by openstreetmap.

the class MapArea method addLines.

/**
 * Add the lines, making sure that they are not too big for resolution
 * that we are working with.
 * @param src The map data.
 * @param resolution The current resolution of the layer.
 */
private void addLines(MapDataSource src, final int resolution) {
    // Split lines for size, such that it is appropriate for the
    // resolution that it is at.
    MapFilterChain chain = new MapFilterChain() {

        public void doFilter(MapElement element) {
            MapLine line = (MapLine) element;
            addLine(line);
        }
    };
    LineSizeSplitterFilter filter = new LineSizeSplitterFilter();
    FilterConfig config = new FilterConfig();
    config.setResolution(resolution);
    config.setBounds(bounds);
    filter.init(config);
    for (MapLine l : src.getLines()) {
        if (l.getMaxResolution() < resolution)
            continue;
        // %%% ??? if not appearing at this level no need to filter
        filter.doFilter(l, chain);
    }
}
Also used : MapElement(uk.me.parabola.mkgmap.general.MapElement) MapLine(uk.me.parabola.mkgmap.general.MapLine) LineSizeSplitterFilter(uk.me.parabola.mkgmap.filters.LineSizeSplitterFilter) FilterConfig(uk.me.parabola.mkgmap.filters.FilterConfig) MapFilterChain(uk.me.parabola.mkgmap.filters.MapFilterChain)

Aggregations

FilterConfig (uk.me.parabola.mkgmap.filters.FilterConfig)2 MapFilterChain (uk.me.parabola.mkgmap.filters.MapFilterChain)2 MapElement (uk.me.parabola.mkgmap.general.MapElement)2 LineSizeSplitterFilter (uk.me.parabola.mkgmap.filters.LineSizeSplitterFilter)1 PolygonSubdivSizeSplitterFilter (uk.me.parabola.mkgmap.filters.PolygonSubdivSizeSplitterFilter)1 MapLine (uk.me.parabola.mkgmap.general.MapLine)1 MapShape (uk.me.parabola.mkgmap.general.MapShape)1