Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some SPLITPOS values for angled vias can crash weathermap (parallel vectors) #205

Closed
howardjones opened this issue Jan 6, 2019 · 3 comments

Comments

@howardjones
Copy link
Owner

This config crashes weathermap with an exception while trying to find the crossing point of two parallel lines. The same thing does not happen if you move both points 4000 pixels left (X is 370 and 30) instead. It is also fine if SPLITPOS is 50.

WIDTH 4640
HEIGHT 3100

# regular NODEs:
NODE node111111111111111111111111111
	LABEL node111111111111111111111111111
	POSITION 4370 100

NODE node2
	LABEL node2
	POSITION 4030 2400

LINK node111111111111111111111111111-node2
	WIDTH 2
	BWLABEL bits
	VIASTYLE angled
	SPLITPOS 19
	NODES node111111111111111111111111111:W10 node2:E
	VIA node2 320 0

@howardjones
Copy link
Owner Author

howardjones commented Jan 6, 2019

Failure is
PHP Fatal error: Uncaught Weathermap\Core\WeathermapInternalFail: ParallelLinesNeverCross in /home/howie/Work/network-weathermap/lib/Weathermap/Core/Line.php:56

While finding $crossingPoint1, which is where $line1 and $line2 cross - the outside corner of the link as it goes around a VIA corner. This should never be parallel, as the spine is simplified to remove colinear points after it is split into two spines (one for each direction, split at SPLITPOS).

image

@howardjones
Copy link
Owner Author

If SPLITPOS is close to one end, you can end up with a spine of only two points after the split is done. Spine::splitAtDistance() needs to interpolate a middle point if there are only two. (Good news is that if there are only two, it'll always be a simple linear interpolation)

@howardjones
Copy link
Owner Author

Also, when coordinates are large, getTriangleArea() and simplify() start to get too fussy, and not simplify points that they should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant