clipGeometry = {
const {centerPoint, width, height} = dimensions;
const {portionVisible, aToB } = positionedMap
const divider = aToB.perp().unit().mult(-1);
const centerToVerticalEdge = divider.mult((width / 2) / Math.abs(divider.x));
const centerToHorizontalEdge = divider.mult((height / 2) / Math.abs(divider.y));
const tl = new mapboxgl.Point(0, 0);
const tr = new mapboxgl.Point(width, 0);
const bl = new mapboxgl.Point(0, height);
const br = new mapboxgl.Point(width, height);
if (portionVisible === 1) {
return [tl];
} else if (centerToVerticalEdge.mag() < centerToHorizontalEdge.mag()) {
const intersection0 = centerPoint.sub(centerToVerticalEdge);
const intersection1 = centerPoint.add(centerToVerticalEdge);
if (centerToVerticalEdge.x < 0) {
return [intersection0, intersection1, tl, tr];
} else {
return [intersection0, intersection1, br, bl];
}
} else {
const intersection0 = centerPoint.sub(centerToHorizontalEdge);
const intersection1 = centerPoint.add(centerToHorizontalEdge);
if (centerToHorizontalEdge.y < 0) {
return [intersection0, intersection1, tr, br];
} else {
return [intersection0, intersection1, bl, tl];
}
}
}