Ejemplo n.º 1
0
    def test_init(self):
        rect = GeoExtent()
        self.assertEqual(rect.west, -180.)
        self.assertEqual(rect.south, -90.)
        self.assertEqual(rect.east, 180.)
        self.assertEqual(rect.north, 90.)
        self.assertEqual(rect.inv_y, False)
        self.assertEqual(rect.eps, 1e-04)
        self.assertEqual(str(rect), '-180.0, -90.0, 180.0, 90.0')
        self.assertEqual(repr(rect), 'GeoExtend()')
        self.assertEqual(rect.crosses_antimeridian, False)

        with self.assertRaises(ValueError):
            GeoExtent(west=-180.1)
        with self.assertRaises(ValueError):
            GeoExtent(south=-90.1)
        with self.assertRaises(ValueError):
            GeoExtent(east=180.1)
        with self.assertRaises(ValueError):
            GeoExtent(north=90.1)
        with self.assertRaises(ValueError):
            GeoExtent(west=20, east=20 + 0.9e-6)
        with self.assertRaises(ValueError):
            GeoExtent(south=20, north=20 + 0.9e-6)
        with self.assertRaises(ValueError):
            GeoExtent(south=21, north=20)
Ejemplo n.º 2
0
 def test_repr(self):
     self.assertEqual(repr(GeoExtent()), 'GeoExtend()')
     self.assertEqual(repr(GeoExtent(west=43.2)), 'GeoExtend(west=43.2)')
     self.assertEqual(repr(GeoExtent(south=43.2)), 'GeoExtend(south=43.2)')
     self.assertEqual(repr(GeoExtent(east=43.2)), 'GeoExtend(east=43.2)')
     self.assertEqual(repr(GeoExtent(north=43.2)), 'GeoExtend(north=43.2)')
     self.assertEqual(repr(GeoExtent(inv_y=True)), 'GeoExtend(inv_y=True)')
     self.assertEqual(repr(GeoExtent(inv_y=False, eps=0.001)),
                      'GeoExtend(eps=0.001)')
     self.assertEqual(
         repr(GeoExtent(12.5, 43.2, 180.0, 64.1, inv_y=True)),
         'GeoExtend(west=12.5, south=43.2, north=64.1, inv_y=True)')
Ejemplo n.º 3
0
 def test_crosses_antimeridian(self):
     self.assertEqual(
         GeoExtent(west=170., east=-160.).crosses_antimeridian, True)
     self.assertEqual(
         GeoExtent(west=-170., east=160.).crosses_antimeridian, False)