private void AddIntersections(List <SuperWayIntersection> list, List <Way> superWay, bool inner) { bool prevIsInside = false; if (sector.ContainsCoord(nodes[superWay.First().refs.First()])) { throw new NotImplementedException(); } if (sector.ContainsCoord(nodes[superWay.Last().refs.Last()])) { throw new NotImplementedException(); } for (int i = 0; i < superWay.Count; i++) { for (int j = 1; j < superWay[i].refs.Count; j++) { long prev = superWay[i].refs[j - 1]; long next = superWay[i].refs[j]; if (sector.BorderContainsCoord(nodes[next])) { if (prevIsInside) // close-out a line { list.Add(new SuperWayIntersection() { intersection = nodes[next], leaving = true, superWay = superWay, inner = inner }); } else // start up a new line { list.Add(new SuperWayIntersection() { intersection = nodes[next], leaving = false, superWay = superWay, inner = inner }); } prevIsInside = !prevIsInside; } } } }