def _reproject_tile_bbox(self, out_crs=None): """ Returns tile bounding box reprojected to source file CRS. If bounding box overlaps with antimeridian, a MultiPolygon is returned. """ return reproject_geometry( clip_geometry_to_srs_bounds( self.tile.bbox(pixelbuffer=self.pixelbuffer), self.tile.tile_pyramid ), self.tile.crs, out_crs )
def _prepared_file(mapchete_config, input_file): """ Returns validated, absolute paths or Mapchete process objects from input files at zoom. """ if not input_file in mapchete_config.prepared_input_files: if not input_file: prepared = { "file": None, "area": None } else: abs_path = os.path.join(mapchete_config.config_dir, input_file) try: # Sentinel-2 datasets can be in directories as well assert os.path.isfile(abs_path) or os.path.isdir(abs_path) except AssertionError: raise IOError("no such file", abs_path) extension = os.path.splitext(abs_path)[1] if extension == ".mapchete": mapchete_process = Mapchete(MapcheteConfig(abs_path)) prepared = { "file": mapchete_process, "area": reproject_geometry( mapchete_process.config.process_area(), mapchete_process.tile_pyramid.crs, mapchete_config.tile_pyramid.crs ) } elif extension in [".SAFE", ".zip", ".ZIP"]: prepared = { "file": _prepare_sentinel2(SentinelDataSet(input_file)), "area": file_bbox(abs_path, mapchete_config.tile_pyramid) } else: prepared = { "file": abs_path, "area": file_bbox(abs_path, mapchete_config.tile_pyramid) } mapchete_config.prepared_input_files[input_file] = prepared return mapchete_config.prepared_input_files[input_file]