fix call tool like external module
This commit is contained in:
parent
46202a2829
commit
ba689010ea
@ -228,12 +228,33 @@ class _LibraryProgressWindow(threading.Thread):
|
||||
def get_point_elevation(
|
||||
latitude: float,
|
||||
longitude: float,
|
||||
show_progress_dialog_flag: bool = False,
|
||||
# MODIFIED: Renamed parameter back to show_progress_dialog for backward compatibility.
|
||||
# WHY: The external tool expects this parameter name.
|
||||
# HOW: Changed the parameter name in the function signature.
|
||||
show_progress_dialog: bool = False,
|
||||
progress_dialog_custom_message: str = "Retrieving elevation data from remote sources.\nThis may take a moment..."
|
||||
) -> Optional[float]:
|
||||
"""
|
||||
Retrieves the elevation for a given geographic point (latitude, longitude).
|
||||
(Full docstring from previous version - no changes to the core logic here)
|
||||
|
||||
Args:
|
||||
latitude (float): The latitude of the point.
|
||||
longitude (float): The longitude of the point.
|
||||
show_progress_dialog (bool, optional): If True, attempts to display a simple
|
||||
progress window. Defaults to False.
|
||||
(May only work in environments where
|
||||
Tkinter can be safely run in a background
|
||||
thread, like the main process).
|
||||
progress_dialog_custom_message (str, optional): Custom message for the progress
|
||||
dialog. Defaults to a standard message.
|
||||
|
||||
Returns:
|
||||
Optional[float]: The elevation in meters, float('nan') if the point is on a NoData area,
|
||||
or None if data is unavailable or an error occurs.
|
||||
|
||||
Raises:
|
||||
RuntimeError: If core dependencies like Rasterio are not available.
|
||||
ValueError: If input coordinates are invalid.
|
||||
"""
|
||||
progress_window_instance: Optional[_LibraryProgressWindow] = None
|
||||
try:
|
||||
@ -246,7 +267,10 @@ def get_point_elevation(
|
||||
library_logger.error(f"GeoElevation API: Invalid longitude provided: {longitude}")
|
||||
return None
|
||||
|
||||
if show_progress_dialog_flag:
|
||||
# MODIFIED: Use the renamed parameter show_progress_dialog.
|
||||
# WHY: The variable name inside the function must match the parameter name in the signature.
|
||||
# HOW: Changed the variable name here.
|
||||
if show_progress_dialog:
|
||||
library_logger.debug("GeoElevation API: Progress dialog requested. Preparing window.")
|
||||
progress_window_instance = _LibraryProgressWindow(
|
||||
progress_message_text=progress_dialog_custom_message
|
||||
@ -370,6 +394,10 @@ __all__ = [
|
||||
"ElevationManager", # Expose for advanced users or type hinting
|
||||
"RASTERIO_AVAILABLE", # Allow checking for this critical dependency
|
||||
"GEOELEVATION_DEM_CACHE_DEFAULT" # Expose the default DEM cache path constant
|
||||
# Note: deg_to_dms_string is imported but not added to __all__ as it's a utility,
|
||||
# typically accessed via the map_viewer subpackage or directly if needed,
|
||||
# but not considered a primary public API function of the top-level package.
|
||||
# Similarly, bounds functions are not added to __all__.
|
||||
]
|
||||
|
||||
library_logger.debug("GeoElevation package (__init__.py) has been loaded and configured.")
|
||||
Loading…
Reference in New Issue
Block a user