Commit d73f4660 authored by Cresson Remi's avatar Cresson Remi
Browse files

Merge branch '23-typo-in-reproject-function' into 'develop'

Resolve "Typo in reproject function"

Closes #23

See merge request !45
1 merge request!45Resolve "Typo in reproject function"
Pipeline #37837 failed with stages
in 5 minutes and 9 seconds
Showing with 12 additions and 7 deletions
+12 -7
......@@ -49,12 +49,14 @@ class Source(pyotb.Output):
"""
def __init__(self, root_scene: Scene, out: str | pyotb.core.otbObject, parent: Source = None):
def __init__(self, root_scene: Scene, out: str | pyotb.core.otbObject, parent: Source = None,
output_parameter_key: str = 'out'):
"""
Args:
root_scene: root Scene instance
out: image to deliver (can be an image filename (str), a pyotb.App, etc.)
parent: parent Source instance
output_parameter_key: output parameter key of the app of `out`
"""
assert isinstance(root_scene, Scene), f"root_scene type is {type(root_scene)}"
......@@ -63,17 +65,19 @@ class Source(pyotb.Output):
# Since it can only be called with pyotb apps, we do the following:
# - if the output is a str, (e.g. the original dimap filename), we instantiate a pyotb.Input(),
# - else we use the original output (should be pyotb application)
super().__init__(app=pyotb.Input(out).pyotb_app if isinstance(out, str) else out, output_parameter_key="out")
super().__init__(app=pyotb.Input(out).pyotb_app if isinstance(out, str) else out,
output_parameter_key=output_parameter_key)
assert parent is not self, "You cannot assign a new source to its parent instance"
self.parent = parent # parent source (is another Source instance)
self._app_stack = [] # list of otb applications or output to keep trace
def new_source(self, *args) -> Source:
def new_source(self, *args, **kwargs) -> Source:
"""
Return a new Source instance with new apps added at the end of the pipeline.
Args:
*args: list of pyotb.app instances to append to the existing pipeline
**kwargs: some keyword arguments for Source instantiation
Returns:
new source
......@@ -81,7 +85,7 @@ class Source(pyotb.Output):
"""
for new_app in args:
self._app_stack.append(new_app)
return self.__class__(root_scene=self.root_scene, out=self._app_stack[-1], parent=self)
return self.__class__(root_scene=self.root_scene, out=self._app_stack[-1], parent=self, **kwargs)
def drilled(self, msk_vec_file: str, inside: bool = True, nodata: float | int = 0) -> Source:
"""
......@@ -193,10 +197,11 @@ class Source(pyotb.Output):
"""
if self.root_scene.epsg != epsg:
return self.new_source(pyotb.Orthorectification({"io.in": self,
return self.new_source(pyotb.OrthoRectification({"io.in": self,
"map": "epsg",
"map.epsg": epsg,
"interpolator": interpolator}))
"map.epsg.code": epsg,
"interpolator": interpolator}),
output_parameter_key='io.out')
return self # Nothing but a soft copy of the source
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment