diff --git a/tests/test_ivoa.py b/tests/test_ivoa.py index 4d467ab..3b4e002 100644 --- a/tests/test_ivoa.py +++ b/tests/test_ivoa.py @@ -27,7 +27,7 @@ import unittest -from lsst.sphgeom import Region +from lsst.sphgeom import Box, Circle, ConvexPolygon, LonLat, Region, UnitVector3d class IvoaTestCase(unittest.TestCase): @@ -62,6 +62,27 @@ def test_construction(self): with self.assertRaises(ValueError): Region.from_ivoa_pos(pos) + def test_circle(self): + """Test circle construction.""" + circle = Region.from_ivoa_pos("CIRCLE 12.0 34.0 5") + self.assertIsInstance(circle, Circle) + self.assertTrue(circle.contains(UnitVector3d(LonLat.fromDegrees(13.0, 33.0)))) + + def test_range(self): + """Test range construction.""" + box = Region.from_ivoa_pos("RANGE 1 2 5 6") + self.assertIsInstance(box, Box) + self.assertTrue(box.contains(UnitVector3d(LonLat.fromDegrees(1.5, 5.4)))) + + box = Region.from_ivoa_pos("RANGE 1 2 20 +Inf") + self.assertTrue(box.contains(UnitVector3d(LonLat.fromDegrees(1.7, 80)))) + + def test_polygon(self): + """Test polygon construction.""" + poly = Region.from_ivoa_pos("POLYGON 12.0 34.0 14.0 35.0 14. 36.0 12.0 35.0") + self.assertIsInstance(poly, ConvexPolygon) + self.assertTrue(poly.contains(UnitVector3d(LonLat.fromDegrees(13, 35)))) + if __name__ == "__main__": unittest.main()