def test_spatial_extent_from_coordinates(self): extent = SpatialExtent.from_coordinates(RANDOM_GEOM['coordinates']) self.assertEqual(len(extent.bboxes), 1) bbox = extent.bboxes[0] self.assertEqual(len(bbox), 4) for x in bbox: self.assertTrue(type(x) is float)
def test_spatial_extent_from_coordinates(self) -> None: extent = SpatialExtent.from_coordinates(ARBITRARY_GEOM["coordinates"]) self.assertEqual(len(extent.bboxes), 1) bbox = extent.bboxes[0] self.assertEqual(len(bbox), 4) for x in bbox: self.assertTrue(type(x) is float)
} RANDOM_GEOM = { "type": "Polygon", "coordinates": [[[-2.5048828125, 3.8916575492899987], [-1.9610595703125, 3.8916575492899987], [-1.9610595703125, 4.275202171119132], [-2.5048828125, 4.275202171119132], [-2.5048828125, 3.8916575492899987]]] } RANDOM_BBOX = [ RANDOM_GEOM['coordinates'][0][0][0], RANDOM_GEOM['coordinates'][0][0][1], RANDOM_GEOM['coordinates'][0][1][0], RANDOM_GEOM['coordinates'][0][1][1] ] RANDOM_EXTENT = Extent(spatial=SpatialExtent.from_coordinates(RANDOM_GEOM['coordinates']), temporal=TemporalExtent.from_now()) # noqa: E126 class TestCases: @staticmethod def get_path(rel_path): return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', rel_path)) @staticmethod def get_examples_info(): examples = [] info_path = TestCases.get_path('data-files/examples/example-info.csv') with open(TestCases.get_path('data-files/examples/example-info.csv')) as f: for row in csv.reader(f):
[-1.9610595703125, 3.8916575492899987], [-1.9610595703125, 4.275202171119132], [-2.5048828125, 4.275202171119132], [-2.5048828125, 3.8916575492899987], ]], } ARBITRARY_BBOX: List[float] = [ ARBITRARY_GEOM["coordinates"][0][0][0], ARBITRARY_GEOM["coordinates"][0][0][1], ARBITRARY_GEOM["coordinates"][0][1][0], ARBITRARY_GEOM["coordinates"][0][1][1], ] ARBITRARY_EXTENT = Extent( spatial=SpatialExtent.from_coordinates(ARBITRARY_GEOM["coordinates"]), temporal=TemporalExtent.from_now(), ) class ExampleInfo: def __init__( self, path: str, object_type: pystac.STACObjectType, stac_version: str, extensions: List[str], valid: bool, ) -> None: self.path = path self.object_type = object_type