Exemple #1
0
def test_generate_random_point_in_polygon():
    polygon = Polygon((0,0), (0,4), (4,4), (4,0), (0,0))
    point = polygon.random_point()
    print("POINT: %s" % point)
    assert polygon.contains(point)
    
    polygon = Polygon(  geo.LatLon(42.39321,-82.92114),
                        geo.LatLon(42.39194,-82.91669),
                        geo.LatLon(42.39147,-82.91796),
                        geo.LatLon(42.39090,-82.91974),
                        geo.LatLon(42.39321,-82.92114))
                        
    point = polygon.random_point()
    print("POINT: %s" % point)
    assert polygon.contains(point)
Exemple #2
0
 def generate(self):
     polygon = Polygon(*self.location_bounds)
     latlng_list = [
         convert_point_to_latlng(polygon.random_point())
         for _ in range(self.max_num_nodes)
     ]
     return convert_latlng_to_stop_nodes(latlng_list)
def rand_p(area="1"):
    mypoly = [(30.06657871622343, 31.30840301513672),
              (30.073115284501085, 31.359214782714844),
              (30.039239299161178, 31.36333465576172),
              (30.03686160188358, 31.304969787597656),
              (30.06657871622343, 31.30840301513672)]
    poly = Polygon(*mypoly)
    p = poly.random_point()
    return [p.x, p.y, area]