Is point in polygon (map related)?

Summary

This was for a project where i wanted app functionality to depend if the user was "on the lot" or not. In the location sensor locationchanged event, pointInPoly is called. The user latitude and longitude in a list make up the point input. The points list from a polygon in the map make up the poly input. UserInPoly toggles the stroke color of the polygon based on if the user is inside or outside the poly.

What is your question @chafa ? It is not necessary to develop your own pointInPolygon Procedure.

Developers can determine if a point (a latitude/longitude) is in a polygon using the advice here Location sensor (ringed fence / circular ringed fence).

For a circle:
DistanceToPoint( latitude , longitude , centroid )

Computes the distance between the Circle and the given latitude and longitude . If centroids is true , the distance is computed from the center of the Circle to the given point. Otherwise, the distance is computed from the closest point on the Circle to the given point. Further, this method will return 0 if centroids is false and the point is in the Circle . If an error occurs, -1 will be returned.

For a polygon:
DistanceToPoint( latitude , longitude , centroid )

Computes the distance between the Polygon and the given latitude and longitude . If centroids is true , the distance is computed from the center of the Polygon to the given point. Otherwise, the distance is computed from the closest point on the Polygon to the given point. Further, this method will return 0 if centroids is false and the point is in the Polygon . If an error occurs, -1 will be returned.

Said another way, if the centroid is set to false in the examples, 0 is returned using the Block if the point is in the Polygon.

see the Maps documentation Map components

Regards,
Steve

From what I could make out of the given procedure, it looks like it is taking advantage of the parity (odd/even) of the number of times you cross the perimeter of the polygon when you travel across it. If you cross the perimeter an even number of times, you are still inside/outside. If you cross the perimeter an odd number of times, you have switched your inside/outside state.

I did not go to the trouble of checking the algebra for each line segment check to see if it was checking for a line segment crossing, or a crossing of the extended line containing that segment, or the trouble to think about if that made a difference.

I am also unsure where the start and end of the line crossing path are.

The perimeter crossing count check is usually applied for odd perimeter shapes, like crescents or spirals.

Any way, the blocks are useless without an .aia export or block-level draggable .png export:

Please download and post each of those event block(s)/procedures here ...
(sample video)

On further reading of the Polygon component's distance from point block doc, it's quite plausible that this algorithm is hidden behind the distance=0 calculation.

It's an interesting algorithm to study, given the time.

In GIS, Spatial Analysis, the PIP (Point in Polygon) algorithm to ascertain if a Point is INSIDE or OUTSIDE a polygon : -

  1. a straight line drawn in the vertical from the point.
  2. If the line cuts the polygon ODD number of times, then the point is INSIDE the polygon.
  3. If the line cuts the polygon EVEN number of times, then the point is OUTSIDE the polygon .