Re: [OSM-dev] Algorithm help

2008-05-30 Thread Dirk-Lüder Kreie
Tom Evans schrieb: Our data-model does not support earth as a sphere. Uh? The data model supports it fine as far as I can see. Yes, virtually all the tools don't, because it isn't a problem so far (and is harder...). But they could be improved in the future and the data model would be

Re: [OSM-dev] Algorithm help

2008-05-30 Thread Tom Evans
Consider a way from 0°, -189.999° to 0°, 180°. that is, in our current datamodel, a way that's roughly 40,000 km long. No. In the datamodel, it's just a way between two nodes. The nodes are defined in lat, lon, effectively in spherical co-ordinates, hence them being angles. (ignoring

Re: [OSM-dev] Algorithm help

2008-05-29 Thread SteveC
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 http://en.wikipedia.org/wiki/Cross_Product if its positive in the z axis its one way, if its negative its the

Re: [OSM-dev] Algorithm help

2008-05-29 Thread SteveC
On 28 May 2008, at 21:35, Richard Duivenvoorde wrote: Richard Fairhurst wrote: Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise? cheers Richard ___ dev

Re: [OSM-dev] Algorithm help

2008-05-29 Thread Richard Duivenvoorde
SteveC wrote: On 28 May 2008, at 21:35, Richard Duivenvoorde wrote: Richard Fairhurst wrote: Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise? cheers Richard

Re: [OSM-dev] Algorithm help

2008-05-29 Thread SteveC
On 29 May 2008, at 09:47, Richard Duivenvoorde wrote: SteveC wrote: On 28 May 2008, at 21:35, Richard Duivenvoorde wrote: Richard Fairhurst wrote: Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise?

Re: [OSM-dev] Algorithm help

2008-05-29 Thread Ludwig
The Geos Library has a method isCCW (counterclockwise) - ( http://geos.refractions.net/ro/doxygen_docs/html/classgeos_1_1algorithm_1_1CGAlgorithms.html ). Unfortunately this algorithm is not exposed in the Geos C API (only the C++ API), and thus not available in the Python etc bindings - but the

Re: [OSM-dev] Algorithm help

2008-05-29 Thread Francisco R. Santos
On Wed, May 28, 2008 at 10:26 PM, Richard Fairhurst [EMAIL PROTECTED] wrote: Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise? Take a look at this:

Re: [OSM-dev] Algorithm help

2008-05-29 Thread Richard Fairhurst
SteveC wrote: On 29 May 2008, at 11:08, Richard Fairhurst wrote: For anyone interested, this is the code I committed at silly o'clock last night: [...] its amazing any of that works How so? cheers Richard ___ dev mailing list

Re: [OSM-dev] Algorithm help

2008-05-29 Thread Richard Fairhurst
SteveC wrote: it's like reading undocumented assembler! I could do that if it helps? ld hl,table: call BD58 ld hl,BD2B: ld de,mc_pc: ld bc,mc_pco: call patch ld hl,BD31: ld de,mc_sp: ld bc,mc_spo: call patch ld hl,BDF1: ld de,mc_wp: ld bc,mc_wpo: jp patch

Re: [OSM-dev] Algorithm help

2008-05-29 Thread Tom Evans
Our data-model does not support earth as a sphere. Uh? The data model supports it fine as far as I can see. Yes, virtually all the tools don't, because it isn't a problem so far (and is harder...). But they could be improved in the future and the data model would be fine. Or am I missing

Re: [OSM-dev] Algorithm help

2008-05-29 Thread SteveC
On 29 May 2008, at 13:17, Dave Stubbs wrote: On Thu, May 29, 2008 at 9:07 AM, SteveC [EMAIL PROTECTED] 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

[OSM-dev] Algorithm help

2008-05-28 Thread Richard Fairhurst
Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise? cheers Richard ___ dev mailing list dev@openstreetmap.org

Re: [OSM-dev] Algorithm help

2008-05-28 Thread Richard Duivenvoorde
Richard Fairhurst wrote: Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise? cheers Richard ___ dev mailing list dev@openstreetmap.org

Re: [OSM-dev] Algorithm help

2008-05-28 Thread Nathan Vander Wilt
On May 28, 2008, at 1:35 PM, Richard Duivenvoorde wrote: Richard Fairhurst wrote: Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise? Richard, there is a good set of (explanations of) algorithms here:

Re: [OSM-dev] Algorithm help

2008-05-28 Thread Dirk-Lüder Kreie
Nathan Vander Wilt schrieb: On May 28, 2008, at 1:35 PM, Richard Duivenvoorde wrote: Richard Fairhurst wrote: Can anybody point me in the direction of an algorithm that will determine whether a closed way (polyline) is clockwise or anti- clockwise? Richard, there is a good set of

Re: [OSM-dev] Algorithm help

2008-05-28 Thread Richard Fairhurst
Thanks Richard and Nathan for the pointers - really appreciated. I think I've got it now. Nathan Vander Wilt wrote: [...] That said, I'm guessing there are other assumptions being made within OSM that break down under spherical geometry. If your polygon doesn't contain pole(s) or cross