Пример #1
0
 def __rayIntersect(p0, p1, polyline):
     ray_dir = GeometryTools.lineToRay(p0, p1)
     intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, polyline)
     if intersections:
         if len(intersections) > 1:
             d_list = [ GeometryTools.distance(p1, p[1]) for p in intersections ]
             index = d_list.index(min(d_list))
         else:
             index = 0
         p2 = intersections[index][1]
         return [p1, p2]
     else:
         return None
Пример #2
0
    def extendToBBox(self, bbox, k, start=True):
        fault_polyline = self.getPolyline(k)
        if start:
            p0 = fault_polyline[1]
            p1 = fault_polyline[0]
        else:
            p0 = fault_polyline[-2]
            p1 = fault_polyline[-1]

        ray_dir = GeometryTools.lineToRay(p0,p1)
        intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, bbox)
        if intersections:
            p2 = intersections[0][1]
            if self.getName():
                name = "Extend:%s" % self.getName()
            else:
                name = None

            return CPolyline(name=name, init_points=[(p1[0], p1[1]), p2])
        else:
            raise Exception("Logical error - must intersect with bounding box")