cross links plugin

- fixed indentation
- fixed off-by-one error on polygons
- made lines dashed, and less opaque - so it's easier to see the colour of the link they're drawn on
This commit is contained in:
Jon Atkins 2014-06-21 03:05:08 +01:00
parent 77f0f6f167
commit 2e87c4f4ac

View File

@ -34,6 +34,10 @@ var near_0 = 1e-6;
function greatCircleArcIntersect(a0,a1,b0,b1) {
function length(x, y, z) {
return Math.sqrt(x * x + y * y + z * z);
}
// Order points
if (a1.lat < a0.lat) { var t=a1;a1=a0;a0=t;}
if (b1.lat < b0.lat) { var t=b1;b1=b0;b0=t;}
@ -128,17 +132,7 @@ function greatCircleArcIntersect(a0,a1,b0,b1) {
}
}
function length(x, y, z) {
return Math.sqrt(x * x + y * y + z * z);
}
/*
smallCircleIntersect
idea:
- build the plane of the small circle: normalvector (center) and p=center+radian // E:n1*x+n2*y+n3*z=n1*p1+n2*p2+n3*p3
- calc distance to both points // d=(n1*x+n2*y+n3*z- (n1*p1+n2*p2+n3*p3)) / length(n)
- both >0 = inside ; one >0 = collision
*/
window.plugin.crossLinks.testPolyLine = function (polyline, link,closed) {
@ -150,7 +144,7 @@ window.plugin.crossLinks.testPolyLine = function (polyline, link,closed) {
}
if (closed) {
if (greatCircleArcIntersect(a[0],a[1],b[b.length],b[0])) return true;
if (greatCircleArcIntersect(a[0],a[1],b[b.length-1],b[0])) return true;
}
return false;
@ -198,9 +192,10 @@ window.plugin.crossLinks.showLink = function(link) {
var poly = L.geodesicPolyline(link.getLatLngs(), {
color: '#f11',
opacity: 0.7,
weight: 4,
opacity: 0.5,
weight: 5,
clickable: false,
dashArray: [8,8],
guid: link.options.guid
});