[josm-dev] Validator plugin WronglyOrderedWays false error
Roy Rankin
rrankin at ihug.com.au
Sun May 11 12:50:51 BST 2008
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,
More information about the josm-dev
mailing list