def test_group_by_extent(self): geom_coords_1 = [[[89, 2], [90, 2], [90, 3], [89, 3], [89, 2]]] geom_coords_2 = [[[90, 3], [91, 3], [91, 4], [90, 4], [90, 3]]] geom_coords_3 = [[[92, 4], [92, 4], [92, 5], [91, 5], [91, 4]]] eo_geom1 = EOProduct.from_geojson( self._minimal_eoproduct_geojson_repr("1", geom_coords_1) ) eo_geom2 = EOProduct.from_geojson( self._minimal_eoproduct_geojson_repr("2", geom_coords_2) ) eo_geom3 = EOProduct.from_geojson( self._minimal_eoproduct_geojson_repr("3", geom_coords_3) ) first_search = SearchResult([eo_geom1]) second_search = SearchResult([eo_geom1, eo_geom2]) third_search = SearchResult([eo_geom1, eo_geom2, eo_geom3]) grouped_searches = EODataAccessGateway.group_by_extent( [first_search, second_search, third_search] ) # The returned value is a List[SearchResult] self.assertIsInstance(grouped_searches, list) self.assertTrue(all(isinstance(sr, SearchResult) for sr in grouped_searches)) # We expect three groups because we have given products that have # three different geometry bounds. self.assertEqual(len(grouped_searches), 3) # Given how the search results were constructed the resulting groups # must have these 3 different lengths. ss_len = [len(sr) for sr in grouped_searches] self.assertIn(1, ss_len) self.assertIn(2, ss_len) self.assertIn(3, ss_len)
def test_eoproduct_from_geointerface(self): """EOProduct must be build-able from its geo-interface""" product = EOProduct(self.provider, self.eoproduct_props, productType=self.product_type) same_product = EOProduct.from_geojson( geojson.loads(geojson.dumps(product))) self.assertSequenceEqual( [ product.provider, product.location, product.properties["title"], product.properties["instrument"], self._tuples_to_lists(geometry.mapping(product.geometry)), self._tuples_to_lists( geometry.mapping(product.search_intersection)), product.product_type, product.properties["productType"], product.properties["platformSerialIdentifier"], ], [ same_product.provider, same_product.location, same_product.properties["title"], same_product.properties["instrument"], self._tuples_to_lists(geometry.mapping(same_product.geometry)), self._tuples_to_lists( geometry.mapping(same_product.search_intersection)), same_product.product_type, same_product.properties["productType"], same_product.properties["platformSerialIdentifier"], ], )