Question: Function socialbookmarksTableData(data) is called by another function to generate the content of a table -- data is a JSON object. Inside the function i call 2 other functions that use getJSON and POST (with json as a return object) to get some data. The problem is: though the functions execute correctly i get undefined value for the 2 variables (bookmarkingSites, bookmarkCategories). Help with a solution please. 

```
    function socialbookmarksGetBookmarkCategories(bookmarkID)
    {
        var toReturn = '';
        $.post("php/socialbookmark-get-bookmark-categories.php",{
            bookmarkID: bookmarkID
        },function(data){
            $.each(data,function(i,categID){
                toReturn += '<option value ="' + data[i].categID + '">' + data[i].categName + '</option>';
            })
            return toReturn;
        },"JSON");
    }

    function socialbookmarksGetBookmarkSites()
    {
        var bookmarkingSites = '';
        $.getJSON("php/socialbookmark-get-bookmarking-sites.php",function(bookmarks){

            for(var i = 0; i < bookmarks.length; i++){
                //alert( bookmarks[i].id);
                bookmarkingSites += '<option value = "' + bookmarks[i].id + '">' + bookmarks[i].title + '</option>';
            }
            return bookmarkingSites;
        });
    }
    function socialbookmarksTableData(data)
    {
        var toAppend = '';
        var bookmarkingSites = socialbookmarksGetBookmarkSites();

        $.each(data.results, function(i, id){

            var bookmarkCategories = socialbookmarksGetBookmarkCategories(data.results[i].bookmarkID);
    //rest of the code is not important
        });
    $("#searchTable tbody").append(toAppend);
}

```

Answer: 
The `android.graphics.Path` class doesn't have such a method. The Canvas class does have a clipping region that can be set to a path, there is no way to test it against a point. You might try Canvas.quickReject, testing against a single point rectangle (or a 1x1 `Rect`). I don't know if that would really check against the path or just the enclosing rectangle, though.

The Region class clearly only keeps track of the containing rectangle. 

You might consider drawing each of your regions into an 8-bit alpha layer Bitmap with each `Path` filled in it's own 'color' value (make sure anti-aliasing is turned off in your `Paint`). This creates kind of a mask for each path filled with an index to the path that filled it. Then you could just use the pixel value as an index into your list of paths.

```
Bitmap lookup = Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8);
//do this so that regions outside any path have a default
//path index of 255
lookup.eraseColor(0xFF000000);

Canvas canvas = new Canvas(lookup);
Paint paint = new Paint();

//these are defaults, you only need them if reusing a Paint
paint.setAntiAlias(false);
paint.setStyle(Paint.Style.FILL);

for(int i=0;i<paths.size();i++)
    {
    paint.setColor(i<<24); // use only alpha value for color 0xXX000000
    canvas.drawPath(paths.get(i), paint); 
    }

```

Then look up points,

```
int pathIndex = lookup.getPixel(x, y);
pathIndex >>>= 24;

```

Be sure to check for 255 (no path) if there are unfilled points.
For completeness, I want to make a couple notes here:

As of API 19, there is an [intersection operation](http://developer.android.com/reference/android/graphics/Path.html#op(android.graphics.Path,%20android.graphics.Path,%20android.graphics.Path.Op)) for Paths. You could create a very small square path around your test point, intersect it with the Path, and see if the result is empty or not.

You can convert Paths to Regions and do a [contains()](http://developer.android.com/reference/android/graphics/Region.html#contains(int,%20int)) operation. However Regions work in integer coordinates, and I think they use transformed (pixel) coordinates, so you'll have to work with that. I also suspect that the conversion process is computationally intensive.

The edge-crossing algorithm that Hans posted is good and quick, but you have to be very careful for certain corner cases such as when the ray passes directly through a vertex, or intersects a horizontal edge, or when round-off error is a problem, which it always is.

The [winding number](https://en.wikipedia.org/wiki/Point_in_polygon#Winding_number_algorithm) method is pretty much fool proof, but involves a lot of trig and is computationally expensive.

[This paper by Dan Sunday](http://geomalgorithms.com/a03-_inclusion.html) gives a hybrid algorithm that's as accurate as the winding number but as computationally simple as the ray-casting algorithm. It blew me away how elegant it was.

See <https://stackoverflow.com/a/33974251/338479> for my code which will do point-in-path calculation for a path consisting of line segments, arcs, and circles.