[Tilesathome] Frustrated about oceantiles

Martijn van Oosterhout kleptog at gmail.com
Tue Dec 16 14:14:54 GMT 2008


On Tue, Dec 16, 2008 at 1:01 PM, Dirk-Lüder Kreie <osm-list at deelkar.net> wrote:
> close-areas.pl needs a isClockwise(poly) function. I don't know a good
> algorithm off my head, and don't have time to research, but anyone who
> does, feel free to add.

isClockwise() is easy, it's simply if( calculateArea(poly) > 0 ) then
clockwise else anticlockwise;

calculateArea(poly):
  area=0
  for(i=0;i<poly.points-1;i++)
  {
      area += poly.point[i].x * poly.point[i+1].y - poly.point[i].y *
poly.point[i+1].x
  }

I wasn't aware the algorithm was the problem...

Have a nice day,
-- 
Martijn van Oosterhout <kleptog at gmail.com> http://svana.org/kleptog/




More information about the Tilesathome mailing list