Marker outside oddly shaped target area

For the "J"-shaped forest area in the above screenshot, Street Complete asks for forest's the leaf type. The marker for the questions is located on a meadow outside the area (probably at its geometrical center).
How to Reproduce Go to N 51,0356643, E 7,3105947 in the StreetComplete app
Expected Behavior The question's map marker is located inside the corresponding area.
Versions affected Android, v52.0.
I've seen this a few times, afaik always for the leaf type quest, but it didn't bother me because it was clear enough (so far) which oddly shaped forest it was asked about.
The code to calculate the center of a polygon is here:
https://github.com/streetcomplete/StreetComplete/blob/49f23daa82b22128b7cc2e885b9d53ebbd651ab1/app/src/main/java/de/westnordost/streetcomplete/util/math/SphericalEarthMath.kt#L362-L386
so, currently the center of the polygon is used, not the centroid. There is no particular reason for that. Maybe using the center of the polygon can be calculated faster, not sure. In any case, the centroid algorithm would need to be added in a PR, we do not use a geo-math-library for such calculations
It's a minor issue. I spotted it for the first time. It got aggravated in this rare case by the area being very narrow, i.e., hardly visible on the map. In most other cases the user can probably guess which area the question belongs to.
Thanks for providing a pointer to the current algorithm! Maybe I'll find time to create a PR.
I'll release a new minor update in a week or so, so now is a good timeframe to implement this when you want to see this change live quickly. If you are not interested anymore in implementing this, I will mark this as "help wanted".
Unfortunately, I'm not able to spend time on this issue, at the moment. Feel free to mark it as "help wanted"!
Correction: "centroid" is by definition not necessarily within the boundary of the polygon.
MapBox implemented an algorithm finding the polygon pole of inaccessibility, the most distant internal point from the polygon outline in JavaScript: https://github.com/mapbox/polylabel
There is not one port of it to Java, ... but three??
- https://mvnrepository.com/artifact/org.geotools/gt-polygon-labeller (source code unknown, probably somewhere in the geotools repo)
- https://mvnrepository.com/artifact/com.github.nyukhalov/polylabel-java (https://github.com/nyukhalov/polylabel-java)
- <not on maven central> (https://github.com/MichaelOwenDyer/polylabel-java)
I am reluctant to add a Java dependency for this. Mabye someone would like to port this to platform independent Kotlin code (Kotlin multiplatform)?
It is about 200 lines of code (production code, not counting unit tests).