[josm-dev] Validator plugin WronglyOrderedWays false error

Karl Newman siliconfiend at gmail.com
Mon May 12 14:32:04 BST 2008


On Sun, May 11, 2008 at 4:50 AM, Roy Rankin <rrankin at ihug.com.au> wrote:

> Thanks Martijn. I have convinced myself your tip is the correct approach
>  (although your formula is slightly wrong as it gives twice the area)
> and I have replaced my changes with a new fix using this new approach in
> the 737 trac ticket.
>
> Regards,
> Roy Rankin
>
> Martijn van Oosterhout wrote:
> > On Sun, May 11, 2008 at 9:58 AM, Roy Rankin <rrankin at ihug.com.au> wrote:
> >> I have done a rewrite of the code as follows:
> >>
> >>  Determine the mean latitude of the closed way.
> >>  Then add the deltas of longitude for each segment starting with
> >>  a latitude greater than mean and subtract the deltas of longitude
> >>  if the start is less than the mean latitude.
> >>
> >>  The result should be positive for clockwise ways and negative
> >>  for counter-clockwise ways.
> >
> > You're almost there. You should just use the proper formula for the
> > area of a polygon:
> >
> > for each node
> >   area += x*deltay - y*deltax
> >
> > Dont' need to calculte the mean, nor test anything for direction. And
> > 100% relaible (for non-self-intersecting polygons anyway).
> >
> > Have a nice day,
>

The actual value of the area doesn't matter. It only matters whether the sum
is positive or negative.

Karl



More information about the josm-dev mailing list