def get_elevation_args()

in analysis/webservice/webmodel/NexusRequestObject.py [0:0]


    def get_elevation_args(self) -> Tuple[Optional[float], Optional[float]]:
        '''
        Extract both single elevation args (depth, height, elevation) or
        min/max elevation args (minDepth/maxDepth, minHeight/maxHeight, minElevation/maxElevation)
        Return a tuple of the form (min, max)
        '''
        min_depth = self.get_float_arg('minDepth', None)
        max_depth = self.get_float_arg('maxDepth', None)
        depth = self.get_float_arg('depth', None)

        min_height = self.get_float_arg('minHeight', None)
        max_height = self.get_float_arg('maxHeight', None)
        height = self.get_float_arg('height', None)

        min_elevation = self.get_float_arg('minElevation', None)
        max_elevation = self.get_float_arg('maxElevation', None)
        elevation = self.get_float_arg('elevation', None)

        # Handle single parameter cases
        if depth is not None:
            return -1 * depth, -1 * depth
        elif height is not None:
            return height, height
        elif elevation is not None:
            return elevation, elevation

        # Handle min/max parameter cases
        ret_min = min_elevation or min_height or (-1 * min_depth if min_depth is not None else None)
        ret_max = max_elevation or max_height or (-1 * max_depth if max_depth is not None else None)

        # Validate max > min unless using depth args
        if ret_max is not None and ret_min is not None and ret_max < ret_min:
            if min_depth is not None or max_depth is not None:
                ret_max, ret_min = ret_min, ret_max
            else:
                raise ValueError(f'Request max elevation less than min elevation: {ret_max} < {ret_min}')
        return ret_min, ret_max