Random geographic coordinates (on land, avoid ocean)

前端 未结 16 1128
死守一世寂寞
死守一世寂寞 2020-12-08 10:03

Any clever ideas on how to generate random coordinates (latitude / longitude) of places on Earth? Latitude / Longitude. Precision to 5 points and avoid bodies of water. <

16条回答
  •  北海茫月
    2020-12-08 10:41

    I guess you could use a world map, define a few points on it to delimit most of water bodies as you say and use a polygon.contains method to validate the coordinates.

    A faster algorithm would be to use this map, take some random point and check the color beneath, if it's blue, then water... when you have the coordinates, you convert them to lat/long.

提交回复
热议问题