2

My question is, will the code given in http://pietschsoft.com/post/2008/07/Virtual-Earth-Polygon-Search-Is-Point-Within-Polygon.aspx work to find a point in one of areas mentioned in below file (page 7-9): http://www.weather.gov/directives/sym/pd01008006curr.pdf looking forward,

2 Answers2

0

I believe it will fail in some cases. The algorithm you linked to, which is correct for planar geometry, is incorrect for spherical geometry. Consider the rectangles which cross the 180th meridian, e.g. the rectangle labelled "M". The algorithm would consider that rectangle as covering the americas, Africa, and Europe, but not Asia or the Pacific.

jameshfisher
  • 34,029
  • 31
  • 121
  • 167
0

A point-in-polygon algorithm usually just counts the number of times it crosses a line by "drawing" one out in any particular direction. It would then know if it's in the polygon or not by knowing how many times it crossed that line (even number it was outside, odd number it is inside). The code on that site looks like it just flips a boolean instead of adding to a counter but it's the same thing.

I must confess I have not read the PDF you linked too (too long!) but I've not come across an instance where the algorithm fails.

One tip might be to draw a rough square around the outermost extremeties of the polygon first and check whether it falls within that to avoid having to test each point).

Valerion
  • 823
  • 8
  • 15
  • Hello Valerion! thank you for your quick reply, you dont need to go through the whole pdf document, just go to page number 9 directly, you will see some stereographic projected areas, my question is just will this code be okay to use for that areas to check if a point is within any one of these areas http://www.weather.gov/directives/sym/pd01008006curr.pdf go to page 9 of this document, –  Jun 09 '09 at 14:35
  • Ok those are some large areas! Checking within a rectangle should be dead simple, but obviously the whole curvature-of-the-earth thing is maybe a bigger issue here. – Valerion Jun 09 '09 at 16:23
  • Thank you Valerion, Yes exactly, you are right , Then in your opinion what could be the good solution to check if a particular point exists within any one of these these areas? looking forward –  Jun 16 '09 at 15:21