Check of point inside/outside polygon

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 26 06:32:00 PDT 2016


Ideally I need algorithm that can return bool if one polygon 
overlapped/intersected by another. But I do not know math.

After some googling I found topic on SO[1] about point 
inside/outside polygon. It's not directly what I need, but as 
temporal solution would be enough.

Maybe somebody already wrote this algorithm in D. Could you share 
it plz.

I tried to translate algorithm in D, but I do not understand some 
things. For example:

public static bool PointInPolygon(LatLong p, List<LatLong> poly) 
// Ok we are getting `p` - looking point, and `poly` -- our 
polygon. But what format it should have? WKT? Something else?

poly.Add(new LatLong { Lat = poly[0].Lat, Lon = poly[0].Lon }); 
// Why we add Lat and Long to poly? And again what it's format?

All other code look work in D to.


[1] 
http://stackoverflow.com/questions/924171/geo-fencing-point-inside-outside-polygon/6786279#6786279




More information about the Digitalmars-d-learn mailing list