from arcgis Javascript api:
function polygonContainPoint(pt,polygon) {
var rings = polygon.rings,
ring, bresult = false,
pt1, pt2, ringlength, j, i, indexrings, ringslength = rings.length;
for (indexrings = 0; indexrings < ringslength; indexrings++) {
ring = rings[indexrings];
ringlength = ring.length;
j = 0;
for (i = 0; i < ringlength; i++) {
j++;
if (j === ringlength) {
j = 0;
}
pt1 = ring[i];
pt2 = ring[j];
if ((pt1[1] < pt.y && pt2[1] >= pt.y || pt2[1] < pt.y && pt1[1] >= pt.y) && (pt1[0] + (pt.y - pt1[1]) / (pt2[1] - pt1[1]) * (pt2[0] - pt1[0]) < pt.x)) {
bresult = !bresult;
}
}
}
return bresult;
}
var rings = polygon.rings,
ring, bresult = false,
pt1, pt2, ringlength, j, i, indexrings, ringslength = rings.length;
for (indexrings = 0; indexrings < ringslength; indexrings++) {
ring = rings[indexrings];
ringlength = ring.length;
j = 0;
for (i = 0; i < ringlength; i++) {
j++;
if (j === ringlength) {
j = 0;
}
pt1 = ring[i];
pt2 = ring[j];
if ((pt1[1] < pt.y && pt2[1] >= pt.y || pt2[1] < pt.y && pt1[1] >= pt.y) && (pt1[0] + (pt.y - pt1[1]) / (pt2[1] - pt1[1]) * (pt2[0] - pt1[0]) < pt.x)) {
bresult = !bresult;
}
}
}
return bresult;
}