2

I am making a map with some countries and I would like to draw points which are randomly position inside those countries. I was trying to use bounding box, but the points were very often drawn outside the country.

I have found the point-in-polygon function http://bl.ocks.org/bycoffe/5575904

It checks if the point intersects with some line coordinates and I don't know how to get those from my map.

Regards, Almbu

AlmBu
  • 31
  • 2
  • It may be easier to generate random points in the bounding box and discard those that are not within the actual shape. – Lars Kotthoff May 21 '15 at 16:12
  • Thanks for your reply, Lars Kotthoff. I am able to generate the points in the bounding box. I can read the bounds, and then I generate new position based on those bounds values. But I don't know how to figure out which one are within the actual shape. – AlmBu May 21 '15 at 19:10
  • [This question](https://stackoverflow.com/questions/2174640/hit-testing-svg-shapes) has a few hints on that. – Lars Kotthoff May 21 '15 at 19:41
  • It seems that getIntersectionList is not supported in all browsers. Is there any other way? – AlmBu May 22 '15 at 06:07
  • Yes, have a look at the second answer. – Lars Kotthoff May 22 '15 at 17:39

0 Answers0