I've implemented a point-in-polygon algorithm based on http://alienryderflex.com/polygon/.
It works fine but, as it says in the article:
If the test point is on the border of the polygon, this algorithm will deliver unpredictable results
It turns out I need the algorithm to return true when the test point is on the border/edge (and the vertices) of the polygon.
Is there either:
Expanding the polygon a bit is an option but this can be tricky with concave polygons.
My recommendation would be to shift the point into different directions (up/down/left/right) by a tiny amount and do the calculation for each of these shifted points. Then count it as being inside if at least one of the shifted points is determined to be inside.
Another option is to let the line on which the intersections are counted run in different directions, not only horizontally.
But then it might not be worth the while because, as your linked article states: "That is not generally a problem, since the edge of the polygon is infinitely thin anyway, and points that fall right on the edge can go either way without hurting the look of the polygon."