jieter / Leaflet-semicircle

Extend Leaflet's circle class to display semicircles.
http://jieter.github.io/Leaflet-semicircle/examples/semicircle.html
MIT License
120 stars 52 forks source link

strange behaviour of semicircle, arc on wrong site #22

Open it4workflow opened 7 years ago

it4workflow commented 7 years ago

i use semicircle to display the direction tag of openstreetmap. have a look at viewpoint-direction. there you can see some semicircles, which were incorrectly drawn:

So what have i missed?

it4workflow commented 7 years ago

i've now experimented with the size (direction=270):

jieter commented 7 years ago

@it4workflow I tested with this example page: http://jieter.github.io/Leaflet-semicircle/examples/semicircle.html, which still looks good to me, but I released the latest version in a bit of a hurry, so I might have missed something. You could try to use 0.1.2 (note the different syntax). You could really help by providing an isolated test case, for example in a playground leaflet. Unfortunately, I'v got no time to dig through your app code...

it4workflow commented 7 years ago

Okay, i've played a little bit, what's about this one. The view of this viewpoint is from 270° to 22° (to NNW 337°) , the lines are correct, but the arc is wrong

it4workflow commented 7 years ago

i figured out a little bit, the problem only occurs with usage of start-/stopangle and startAngle>stopAngle. I'ved rewrite my code, manually determine the direction and size and call your setDirection-method. So now everything is fine.

jieter commented 7 years ago

I suspected something like that, but we could try to do better on rendering in those cases... Reopened. If someone has time to make a fix, please open a PR.

osmtools commented 7 years ago

Just yesterday i read the discussion about direction for viewpoint in the OpenStreetMap wiki. And there's an interessting point: the stopAngle always has to be bigger than the startAngle - especially if the calculation is done by modulo 360.

In the playground example above, i've used startAngle=270 and stopAngle=22 (because this are the values stored in database) to get a view from west via north to northnorthwest. But you fix and correct this with the if conditions in start-/stopAngle methods ... and now i think this is right and ok. With this unterstanding i've used startAngle=270 and stopAngle=382 (22+360) in this playground example and this is ok.

So i think, if you mention that circumstance in your documentation it should be fine.