예제 #1
0
 def __init__(self, user, project_id, stack_ids, x_min, x_max, y_min, y_max,
              z_min, z_max, rotation_cw, zoom_level, single_channel=False,
              output_path=None):
     self.user = user
     self.project_id = int(project_id)
     self.project = get_object_or_404(Project, pk=project_id)
     # Allow a single ID and a list
     if isinstance(stack_ids, int):
         self.stack_ids = [stack_ids]
     else:
         self.stack_ids = stack_ids
     self.stacks = []
     for sid in self.stack_ids:
         self.stacks.append( get_object_or_404(Stack, pk=sid) )
     # The reference stack is used to obtain e.g. resolution information
     self.ref_stack = self.stacks[0]
     self.x_min = float(x_min)
     self.x_max = float(x_max)
     self.y_min = float(y_min)
     self.y_max = float(y_max)
     self.z_min = float(z_min)
     self.z_max = float(z_max)
     self.zoom_level = int(zoom_level)
     # Save a normalized version of the rotation angle
     self.rotation_cw = rotation_cw % 360
     # Create an output path if not already present
     if output_path is None:
         file_name = file_prefix + id_generator() + "." + file_extension
         output_path = os.path.join(crop_output_path, file_name)
     self.single_channel = single_channel
     self.output_path = output_path
     # State that extra initialization is needed
     self.needs_initialization = True
예제 #2
0
 def __init__(self, user, project_id, stack_mirror_ids, x_min,
         x_max, y_min, y_max, z_min, z_max, rotation_cw, zoom_level,
         single_channel=False, output_path=None):
     self.user = user
     self.project_id = int(project_id)
     self.project = get_object_or_404(Project, pk=project_id)
     # Allow a single ID and a list
     if isinstance(stack_mirror_ids, int):
         self.stack_mirror_ids= [stack_mirror_ids]
     else:
         self.stack_mirror_ids = stack_mirror_ids
     self.stack_mirrors:List = []
     self.stack_tile_sources:Dict = {}
     for sid in self.stack_mirror_ids:
         stack_mirror = get_object_or_404(StackMirror, pk=sid)
         self.stack_mirrors.append(stack_mirror)
         tile_source = get_tile_source(stack_mirror.tile_source_type)
         self.stack_tile_sources[stack_mirror.stack.id] = tile_source
     # The reference stack is used to obtain e.g. resolution information
     self.ref_stack = self.stack_mirrors[0].stack
     self.x_min = float(x_min)
     self.x_max = float(x_max)
     self.y_min = float(y_min)
     self.y_max = float(y_max)
     self.z_min = float(z_min)
     self.z_max = float(z_max)
     self.zoom_level = int(zoom_level)
     # Save a normalized version of the rotation angle
     self.rotation_cw = rotation_cw % 360
     # Create an output path if not already present
     if output_path is None:
         file_name = file_prefix + id_generator() + "." + file_extension
         output_path = os.path.join(crop_output_path, file_name)
     self.single_channel = single_channel
     self.output_path = output_path
예제 #3
0
 def create_basic_output_path(self):
     """ Will create a random output folder name prefixed with the entity
     name as well as the actual directory.
     """
     # Find non-existing random folder name
     while True:
         folder_name = self.entity_name + '_archive_' + id_generator()
         output_path = os.path.join(treenode_output_path, folder_name)
         if not os.path.exists(output_path):
             break
     # Create folder and store path as field
     os.makedirs(output_path)
     self.output_path = output_path
예제 #4
0
 def create_basic_output_path(self):
     """ Will create a random output folder name prefixed with the entity
     name as well as the actual directory.
     """
     # Find non-existing random folder name
     while True:
         folder_name = self.entity_name + '_archive_' + id_generator()
         output_path = os.path.join(treenode_output_path, folder_name)
         if not os.path.exists(output_path):
             break
     # Create folder and store path as field
     os.makedirs(output_path)
     self.output_path = output_path
예제 #5
0
 def __init__(self,
              user,
              project_id,
              stack_ids,
              x_min,
              x_max,
              y_min,
              y_max,
              z_min,
              z_max,
              rotation_cw,
              zoom_level,
              single_channel=False,
              output_path=None):
     self.user = user
     self.project_id = int(project_id)
     self.project = get_object_or_404(Project, pk=project_id)
     # Allow a single ID and a list
     if isinstance(stack_ids, int):
         self.stack_ids = [stack_ids]
     else:
         self.stack_ids = stack_ids
     self.stacks = []
     for sid in self.stack_ids:
         self.stacks.append(get_object_or_404(Stack, pk=sid))
     # The reference stack is used to obtain e.g. resolution information
     self.ref_stack = self.stacks[0]
     self.x_min = float(x_min)
     self.x_max = float(x_max)
     self.y_min = float(y_min)
     self.y_max = float(y_max)
     self.z_min = float(z_min)
     self.z_max = float(z_max)
     self.zoom_level = int(zoom_level)
     # Save a normalized version of the rotation angle
     self.rotation_cw = rotation_cw % 360
     # Create an output path if not already present
     if output_path is None:
         file_name = file_prefix + id_generator() + "." + file_extension
         output_path = os.path.join(crop_output_path, file_name)
     self.single_channel = single_channel
     self.output_path = output_path
     # State that extra initialization is needed
     self.needs_initialization = True