Skip to content

Commit

Permalink
Add support for pathlib Path
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Nov 27, 2024
1 parent a5ef68b commit 1027583
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions leafmap/maplibregl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3613,6 +3613,8 @@ def add_gps_trace(
None
"""

from pathlib import Path

if add_draw_control:
if draw_control_args is None:
draw_control_args = {
Expand All @@ -3621,6 +3623,12 @@ def add_gps_trace(
}
self.add_draw_control(**draw_control_args)

if isinstance(data, Path):
if data.exists():
data = str(data)
else:
raise FileNotFoundError(f"File not found: {data}")

if isinstance(data, str):
gdf = common.points_from_xy(data, x=x, y=y)
elif isinstance(data, gpd.GeoDataFrame):
Expand Down Expand Up @@ -3999,6 +4007,7 @@ def edit_gps_trace(
Any: The main widget containing the map and the editing interface.
"""

from pathlib import Path
from datetime import datetime
from bqplot import LinearScale, Figure, PanZoom
import bqplot as bq
Expand All @@ -4015,6 +4024,12 @@ def edit_gps_trace(
else:
from bqplot import Scatter

if isinstance(filename, Path):
if filename.exists():
filename = str(filename)
else:
raise FileNotFoundError(f"File not found: {filename}")

output = widgets.Output()
download_widget = widgets.Output()

Expand Down

0 comments on commit 1027583

Please sign in to comment.