def testGridComplex(self):
    top_left      = self.makePoints((0, 0), (0, 1),
                                    (1, 0), (1, 1),
                                    (2, 0), (2, 1))
    top_middle    = self.makePoints((0, 2), (0, 3),
                                    (1, 2), (1, 3),
                                    (2, 2), (2, 3))
    top_right     = self.makePoints((0, 4), (0, 5),
                                    (1, 4), (1, 5),
                                    (2, 4), (2, 5))
    bottom_left   = self.makePoints((3, 0), (3, 1),
                                    (4, 0), (4, 1),
                                    (5, 0), (5, 1))
    bottom_middle = self.makePoints((3, 2), (3, 3),
                                    (4, 2), (4, 3),
                                    (5, 2), (5, 3))
    bottom_right  = self.makePoints((3, 4), (3, 5),
                                    (4, 4), (4, 5),
                                    (5, 4), (5, 5))

    points = (top_left + top_middle + top_right +
              bottom_left + bottom_middle + bottom_right)
    grid = geo.grid(geo.Rect(6, 6, 0, 0), 2, 3, points)

    self.assertEqual([top_left, top_middle, top_right,
                      bottom_left, bottom_middle, bottom_right], grid)
 def testGridDiscardsPointsOutsideArea(self):
     points = self.makePoints(
         (0, 0),  # The only point inside the area.
         (-10, 0),
         (10, 0),
         (0, -10),
         (0, 10))
     grid = geo.grid(geo.Rect(1, 1, -1, -1), 1, 1, points)
     self.assertEqual([[points[0]]], grid)
    def testGridComplex(self):
        top_left = self.makePoints((0, 0), (0, 1), (1, 0), (1, 1), (2, 0),
                                   (2, 1))
        top_middle = self.makePoints((0, 2), (0, 3), (1, 2), (1, 3), (2, 2),
                                     (2, 3))
        top_right = self.makePoints((0, 4), (0, 5), (1, 4), (1, 5), (2, 4),
                                    (2, 5))
        bottom_left = self.makePoints((3, 0), (3, 1), (4, 0), (4, 1), (5, 0),
                                      (5, 1))
        bottom_middle = self.makePoints((3, 2), (3, 3), (4, 2), (4, 3), (5, 2),
                                        (5, 3))
        bottom_right = self.makePoints((3, 4), (3, 5), (4, 4), (4, 5), (5, 4),
                                       (5, 5))

        points = (top_left + top_middle + top_right + bottom_left +
                  bottom_middle + bottom_right)
        grid = geo.grid(geo.Rect(6, 6, 0, 0), 2, 3, points)

        self.assertEqual([
            top_left, top_middle, top_right, bottom_left, bottom_middle,
            bottom_right
        ], grid)
 def testGridSimple(self):
     points = self.makePoints((0, 0), (0, 1), (1, 0), (1, 1))
     grid = geo.grid(geo.Rect(2, 2, 0, 0), 2, 2, points)
     self.assertEqual([[points[0]], [points[1]], [points[2]], [points[3]]],
                      grid)
 def testGridDiscardsPointsOutsideArea(self):
   points = self.makePoints((0, 0),  # The only point inside the area.
                            (-10, 0), (10, 0), (0, -10), (0, 10))
   grid = geo.grid(geo.Rect(1, 1, -1, -1), 1, 1, points)
   self.assertEqual([[points[0]]], grid)
 def testGridSimple(self):
   points = self.makePoints((0, 0), (0, 1),
                            (1, 0), (1, 1))
   grid = geo.grid(geo.Rect(2, 2, 0, 0), 2, 2, points)
   self.assertEqual([[points[0]], [points[1]], [points[2]], [points[3]]],
                     grid)