Example #1
0
 def test_rect_region_alt__rect_is_a_point(self):
     # this is emergent behavior , not planed one
     tile_width = tile_height_h = 2
     nrows = 7
     ncols = 6
     cells = [['col_%d_row_%d' % (yy, xx) for xx in range(ncols)]
              for yy in range(nrows)]
     m = RectMap(42, tile_width, tile_height_h, cells, origin=(0, 0, 0))
     x1, y1 = 5, 8
     x2, y2 = 5, 8
     overlaps = m.get_in_region(x1, y1, x2, y2)
     print('rect is point:', overlaps)
     assert set(overlaps) == set([])
Example #2
0
 def test_rect_region_alt__rect_is_a_segment_not_in_cells_boundary(self):
     # this is emergent behavior , not planed one
     tile_width = tile_height_h = 2
     nrows = 7
     ncols = 6
     cells = [['col_%d_row_%d' % (yy, xx) for xx in range(ncols)]
              for yy in range(nrows)]
     m = RectMap(42, tile_width, tile_height_h, cells, origin=(0, 0, 0))
     x1, y1 = 5, 8
     x2, y2 = 5, 12
     overlaps = m.get_in_region(x1, y1, x2, y2)
     print('rect is a segment not overlapping cells boundary:', overlaps)
     assert set(overlaps) == set(['col_2_row_4', 'col_2_row_5'])
Example #3
0
    def test_rect_region_alt__rect_with_area_gt_0(self):
        tile_width = tile_height_h = 2
        nrows = 7
        ncols = 6
        cells = [['col_%d_row_%d' % (yy, xx) for xx in range(ncols)]
                 for yy in range(nrows)]
        m = RectMap(42, tile_width, tile_height_h, cells, origin=(0, 0, 0))
        x1, y1 = 5, 8
        x2, y2 = 8, 12
        overlaps = m.get_in_region(x1, y1, x2, y2)
        print(overlaps)
        # expects all cells which overlaps the x1,y1,x2,y2 rect in an area > 0
        assert set(overlaps) == set(
            ['col_2_row_4', 'col_3_row_4', 'col_2_row_5', 'col_3_row_5'])

        # all rect boundaries overlaps cell boundaries
        x1, y1 = 6, 8
        x2, y2 = 8, 12
        overlaps = m.get_in_region(x1, y1, x2, y2)
        print(overlaps)
        # expects all cells which overlaps the x1,y1,x2,y2 rect in an area > 0
        assert set(overlaps) == set(['col_3_row_4', 'col_3_row_5'])
Example #4
0
 def test_rect_region_alt__rect_is_a_point(self):
     # this is emergent behavior , not planed one
     tile_width = tile_height_h = 2
     nrows = 7
     ncols = 6
     cells = [ [ 'col_%d_row_%d'%(yy, xx) for xx in range(ncols)]
                                                   for yy in range(nrows)]        
     m = RectMap(42, tile_width, tile_height_h, cells, origin=(0, 0, 0))
     x1, y1 = 5, 8
     x2, y2 = 5, 8
     overlaps = m.get_in_region(x1, y1, x2, y2)
     print('rect is point:', overlaps)
     assert set(overlaps) == set( [] )
Example #5
0
 def test_rect_region_alt__rect_is_a_segment_not_in_cells_boundary(self):
     # this is emergent behavior , not planed one
     tile_width = tile_height_h = 2
     nrows = 7
     ncols = 6
     cells = [ [ 'col_%d_row_%d'%(yy, xx) for xx in range(ncols)]
                                                   for yy in range(nrows)]        
     m = RectMap(42, tile_width, tile_height_h, cells, origin=(0, 0, 0))
     x1, y1 = 5, 8
     x2, y2 = 5, 12
     overlaps = m.get_in_region(x1, y1, x2, y2)
     print('rect is a segment not overlapping cells boundary:', overlaps)
     assert set(overlaps) == set( ['col_2_row_4', 'col_2_row_5'] )
Example #6
0
    def test_rect_region_alt__rect_with_area_gt_0(self):
        tile_width = tile_height_h = 2
        nrows = 7
        ncols = 6
        cells = [ [ 'col_%d_row_%d'%(yy, xx) for xx in range(ncols)]
                                                      for yy in range(nrows)]        
        m = RectMap(42, tile_width, tile_height_h, cells, origin=(0, 0, 0))
        x1, y1 = 5, 8
        x2, y2 = 8, 12
        overlaps = m.get_in_region(x1, y1, x2, y2)
        print(overlaps)
        # expects all cells which overlaps the x1,y1,x2,y2 rect in an area > 0
        assert set(overlaps) == set( ['col_2_row_4', 'col_3_row_4',
                                     'col_2_row_5', 'col_3_row_5'] )

        # all rect boundaries overlaps cell boundaries
        x1, y1 = 6, 8
        x2, y2 = 8, 12
        overlaps = m.get_in_region(x1, y1, x2, y2)
        print(overlaps)
        # expects all cells which overlaps the x1,y1,x2,y2 rect in an area > 0
        assert set(overlaps) == set( ['col_3_row_4', 'col_3_row_5'] )