Example #1
0
    def uniform_random_sampling_with_distance_constraint(
            self, sample_count, min_distance):
        u"""
        Perform sampling by substituting the source polygon with uniformly
        distributed and randomized points that are separated from each other by the
        given minimum distance.
        
        """
        self.samples = list()
        self.triangulate()
        self.constrain_triangulation()

        buffered_zone = Polygon()

        while len(self.samples) < sample_count:
            wr = weighted_random_sub(map(attrgetter('area'), self.triangles))
            triangle = self.triangles[wr]
            sp = self.create_point_in_triangle(triangle)
            if buffered_zone.contains(sp):
                continue
            sp_buffer = sp.buffer(min_distance)
            buffered_zone = buffered_zone.union(sp_buffer)
            self.samples.append(sp)
        else:
            open(r"d:\tmp\buf.txt", 'wb').write(buffered_zone.__str__())
 def uniform_random_sampling_with_distance_constraint(self, sample_count, min_distance):
     u"""
     Perform sampling by substituting the source polygon with uniformly
     distributed and randomized points that are separated from each other by the
     given minimum distance.
     
     """
     self.samples = list()
     self.triangulate()
     self.constrain_triangulation()
     
     buffered_zone = Polygon()
     
     while len(self.samples) < sample_count:
         wr = weighted_random_sub(map(attrgetter('area'), self.triangles))
         triangle = self.triangles[wr]
         sp = self.create_point_in_triangle(triangle)
         if buffered_zone.contains(sp):
             continue
         sp_buffer = sp.buffer(min_distance)
         buffered_zone = buffered_zone.union(sp_buffer)
         self.samples.append(sp)
     else:
         open(r"d:\tmp\buf.txt", 'wb').write(buffered_zone.__str__())
Example #3
0
 def __str__(self):
     return '{}: {}'.format(self._name, Polygon.__str__(self))