mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

queryRenderedFeatures on FillLayer with holes

Open tobrun opened this issue 8 years ago • 8 comments
trafficstars

A user reached out about queryRenderedFeatures returning features when clicking on a hole of a FillLayer. I was able to reproduce this issue only on lower zoom levels. In gif below you can see it working correctly for higher zoom levels but when zooming out it breaks.

ezgif com-video-to-gif 6

Note for this test, I was using: queryRenderedFeatures(PointF coordinates, String layerIds) to get more precise results as the default Android binding implementation that relies on RectF.

tobrun avatar Aug 02 '17 11:08 tobrun

Adding a proposed solution from @mb12 in #10086 (that issue was closed as duplicate):

    bool polygonIntersectsMultiPolygon(const GeometryCoordinates& polygon, const GeometryCollection& multiPolygon) {
        std::vector<GeometryCollection> actualPolygonArray = classifyRings(multiPolygon);
        for (const GeometryCollection& actualPolygon : actualPolygonArray) {
            size_t polysize = actualPolygon.size();
            if(polysize) {
                bool inside_outer_ring = polygonIntersectsPolygon(polygon, actualPolygon[0]);
                if(inside_outer_ring) {
                    //point should be inside_outer_ring and outside all inner rings
                    for(size_t holeIndex=1; holeIndex<polysize; ++holeIndex) {
                        bool inside_hole = polygonIntersectsPolygon(polygon, actualPolygon[holeIndex]);
                        if(inside_hole) {
                            return false;
                        }
                    }
                    return true;
                }
            }
        }
        return false;
    }

tobrun avatar Oct 06 '17 12:10 tobrun

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] avatar Dec 03 '18 06:12 stale[bot]

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] avatar Jun 02 '19 15:06 stale[bot]

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] avatar Nov 30 '19 10:11 stale[bot]

@tobrun @kkaefer The proposed solution in https://github.com/mapbox/mapbox-gl-native/issues/9686#issuecomment-334737165 looks promising. Re-opening this ticket as I still believe this would be a helpful feature/fix.

samfader avatar Feb 28 '20 01:02 samfader

/fyi: @tmpsantos

zugaldia avatar Mar 04 '20 02:03 zugaldia

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] avatar Aug 31 '20 06:08 stale[bot]

@tobrun it is not alarming for TWC's customer but they would still like to get this fixed. Any idea it could be resurfaced?

erinc35 avatar Jan 02 '23 06:01 erinc35