Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Areas not filled in overlapping map regions #806

Closed
mopfattn opened this issue Feb 21, 2021 · 3 comments
Closed

Areas not filled in overlapping map regions #806

mopfattn opened this issue Feb 21, 2021 · 3 comments

Comments

@mopfattn
Copy link

When overlapping map regions are installed, the areas are not correctly filled.

Example: I have installed the Bavaria and Austria maps (from openandromaps.org) which have an overlapping part. The areas in this overlapping part (e.g. lakes, woods) are not correctly filled.

Both Bavaria and Austria installed:

overlapping_maps

Only Bavaria installed:

non_overlapping_maps

Using vtm-android 0.15.0 with diffeent themes, all themes are affected by this issue.

With MapsForge I was using the MultiMapDataStore with DataPolicy.DEDUPLICATE. For VTM I'm using the MultiMapFileTileSource which doesn't provide a similar option.

@devemux86
Copy link
Collaborator

See #224.

This is an OpenGL issue with overlapping areas without tessellation.

You can use the mesh=true option in the water rules in your theme.

For questions or discussion please use the forum.

@ondrap
Copy link

ondrap commented Mar 4, 2021

I know this really hacky, and only probabilistically correct, but... it works for me ;)

public class DedupMultiTileSource extends MultiMapFileTileSource {
    private static class DedupDataSink implements ITileDataSink {
        final private ITileDataSink parent;
        final private HashSet<Integer> undupSet = new HashSet<>(2000);

        DedupDataSink(ITileDataSink parent) {
            this.parent = parent;
        }

        private static int genHashCode(MapElement elem) {
            final int prime = 31;
            int result = 1;
            result = prime * result + elem.layer;
            for (int i=0; i < elem.tags.size(); i++) {
                Tag tag = elem.tags.get(i);
                if (tag.key != null) {
                    result = prime * result + tag.key.hashCode();
                }
                if (tag.value != null) {
                    result = prime * result + tag.value.hashCode();
                }
            }
            for (int i=0; i < elem.pointNextPos; i++) {
                result = prime * result + Float.floatToIntBits(elem.points[i]);
            }
            if (elem.labelPosition != null) {
                result = prime * result + elem.labelPosition.hashCode();
            }
            return result;
        }


        @Override
        public void process(MapElement mapElement) {
            int elHash = genHashCode(mapElement);
            if (!undupSet.contains(elHash)) {
                parent.process(mapElement);
                undupSet.add(elHash);
            }
        }

        @Override
        public void setTileImage(Bitmap bitmap) {
            parent.setTileImage(bitmap);
        }

        @Override
        public void completed(QueryResult queryResult) {
            parent.completed(queryResult);
        }
    }

    private static class DedupDataSource implements ITileDataSource {
        final private ITileDataSource parent;

        DedupDataSource(ITileDataSource parent) {
            this.parent = parent;
        }

        @Override
        public void query(MapTile mapTile, ITileDataSink iTileDataSink) {
            DedupDataSink dedupSink = new DedupDataSink(iTileDataSink);
            parent.query(mapTile, dedupSink);
        }

        @Override
        public void dispose() {
            parent.dispose();
        }

        @Override
        public void cancel() {
            parent.cancel();
        }
    }

    @Override
    public ITileDataSource getDataSource() {
        return new DedupDataSource(super.getDataSource());
    }
}

@devemux86 devemux86 added this to the 0.18.0 milestone Feb 8, 2022
@devemux86
Copy link
Collaborator

devemux86 commented Feb 8, 2022

Fixed in #903 #905.

@devemux86 devemux86 added the bug label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants