Assuming the polygons do not overlap (or that if they do, you're only interested in the top-most polygon), you can employ the "point-in-polygon" solution that involves a canvas:
- Create a canvas big enough to hold all your polygons.
- Draw each polygon in a different colour, one after the other
- Look up what colour the pixel is where the point is located
- This will tell you the polygon that's there.
Note that you don't even need them to be human-distinguishable colours, you could literally use #000000
, #000001
, #000002
and so on, and use the colour's hex code as the index of the polygon.