howardjones / network-weathermap

Network Weathermap draws diagrams from data
http://www.network-weathermap.com/
MIT License
423 stars 95 forks source link

Incorrect calculation of points in angled "via" option #256

Open amshikov opened 3 years ago

amshikov commented 3 years ago

Hello!

Simple configuration of two nodes and link angled via one point produces broken link between nodes:

NODE sw2-vg
        LABEL sw2-vg.ki
        ICON images/core-switch-blue.png
        POSITION 1800 190

NODE swc1-mrp
        LABEL swc1-mrp.dn
        ICON 100 100 images/core-switch-blue.png
        POSITION 4300 2448

# regular LINKs:
LINK sw2-vg-swc1-mrp
        NODES sw2-vg:170:170 swc1-mrp
        VIA 4300 360
        VIASTYLE angled

The lengths of parts of such link are wrongly calculated. Example screenshot: https://puu.sh/H7dPD/f7296b0d00.pngn Could you please take a look? Thank you.

howardjones commented 3 years ago

This sounds like #205 (especially with a large map like you have)

You didn't say what version you have, but give this a try assuming it's 0.98/0.98a:

in lib/WeatherMap.functions.php, around line 1330 is the simplify_spline function. Decrease the epsilon value there from 1e-8 to 1e-11. This is the largest area of a triangle that weathermap considers to be a straight line - when you have such a long line, a small deviation (from rounding errors) makes it not as sensitive as it should be, and that causes other problems with link drawing, which assumes that points next to each other are not in a line. Geometry for VIAs is complicated! :-)

amshikov commented 3 years ago

I apologise for not mentioning a version. I indeed have 0.98a. I've found this function, decreased a value, but it didn't help. It seems that changing that value has not effect et-all, at least in editor. Does editor use the same library?

howardjones commented 3 years ago

Yes, it should. I'll try to reproduce this over the weekend from your config above and let you know what I find.

howardjones commented 3 years ago

Just notes for myself... The original spine for the link shows the expected path. The path is simplified during draw_straight() and loses the corner. Also there are no points between the splitpos and the VIA. Changing SPLITPOS to 47 is enough to get a proper corner again. We need to detect when the corner doesn't have any intermediate points, and add one.

image

amshikov commented 3 years ago

Dear Howard, thank you for workaround provided!

howardjones commented 3 years ago

No problem! I'm still working on the right way to fix it - there's a lot going on to draw one of these angled links :-)