[OSM-dev] Algorithm help
osm.list at randomjunk.co.uk
Thu May 29 13:17:41 BST 2008
On Thu, May 29, 2008 at 9:07 AM, SteveC <steve at asklater.com> wrote:
> if the polygon is p1,p2,p3,p4...
> c = centre point of polygon
> v1 = the vector from c to p1 (p1 - c)
> v2 = the vector from c to p2 (p2 - c)
> take the cross product of v1 and v2
> if its positive in the z axis its one way, if its negative its the other
This only works for nice, simple polygons, of the type that are
probably few and far between in OSM data. It'll work on roundabouts
though which is my major use case for potlatch. The algorithm FAQ had
a nice way using the cross product that will work for all polygons, by
requiring some careful point selection.
More information about the dev