Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/otGpxTrack/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, gpx_file_path):

def _load_gpx(self):
"""Load and parse the GPX file."""
with open(self.gpx_file_path, "r") as f:
with open(self.gpx_file_path, "rb") as f:
self.gpx = gpxpy.parse(f)

def _extract_points(self):
Expand Down Expand Up @@ -378,8 +378,8 @@ def simulate_ar1_speeds(self, segment_indices, sigma_tot=2.5, phi=0.9, n_sims=10

# Calculate statistics using OpenTURNS
mean_speed = v_simulees.computeMean()[0]
lower = ot.Sample.computeQuantilePerComponent(v_simulees, 0.025)[0]
upper = ot.Sample.computeQuantilePerComponent(v_simulees, 0.975)[0]
lower = ot.Sample.computeQuantilePerComponent(v_simulees, 0.025)[0][0]
upper = ot.Sample.computeQuantilePerComponent(v_simulees, 0.975)[0][0]

return mean_speed, lower, upper, v_simulees

Expand Down
2 changes: 1 addition & 1 deletion src/otGpxTrack/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, gpx_file_path):

def _load_gpx(self):
"""Load and parse the GPX file."""
with open(self.gpx_file_path, "r") as f:
with open(self.gpx_file_path, "rb") as f:
self.gpx = gpxpy.parse(f)

def _extract_points(self):
Expand Down
20 changes: 12 additions & 8 deletions streamlitApp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,32 @@ def main():
with cols[i]:
if (example_dir / example_file).exists():
if st.button(f"Load {example_file}", use_container_width=True):
# Create a temporary file with the example content
with open(example_dir / example_file, "rb") as f:
uploaded_file = f.read()
uploaded_file = tempfile.NamedTemporaryFile(
delete=False, suffix=".gpx"
)
uploaded_file.write(uploaded_file)
uploaded_file.seek(0)
file_content = f.read()
temp_file = tempfile.NamedTemporaryFile(
delete=False, suffix=".gpx", mode='wb'
)
temp_file.write(file_content)
temp_file.close()
uploaded_file = temp_file

if uploaded_file is not None:
# Process the uploaded file
try:
with st.spinner("Processing GPX file..."):
# Save to temp file
if hasattr(uploaded_file, "name"):
# This is a temp file from example loading
temp_file_path = uploaded_file.name
else:
# This is a Streamlit UploadedFile
temp_file = tempfile.NamedTemporaryFile(
delete=False, suffix=".gpx"
delete=False, suffix=".gpx", mode='wb'
)
temp_file.write(uploaded_file.getvalue())
temp_file_path = temp_file.name
temp_file.close()
temp_file_path = temp_file.name

# Load the track
track = GpxTrack(temp_file_path)
Expand Down