adding GPS converter app
Browse files- app.py +2 -1
- apps/gps_converter.py +76 -0
- requirements.txt +0 -0
app.py
CHANGED
|
@@ -6,7 +6,7 @@ st.set_page_config(
|
|
| 6 |
layout="wide",
|
| 7 |
initial_sidebar_state="expanded",
|
| 8 |
menu_items={
|
| 9 |
-
"About": "**📡 NPO DB Query v0.2.
|
| 10 |
},
|
| 11 |
)
|
| 12 |
|
|
@@ -16,6 +16,7 @@ pages = {
|
|
| 16 |
st.Page("apps/database_page.py", title="Generate Databases"),
|
| 17 |
st.Page("apps/core_dump_page.py", title="Parse dump core"),
|
| 18 |
st.Page("apps/import_physical_db.py", title="Physical Database Management"),
|
|
|
|
| 19 |
],
|
| 20 |
"Documentations": [
|
| 21 |
st.Page("documentations/database_doc.py", title="Databases Documentation"),
|
|
|
|
| 6 |
layout="wide",
|
| 7 |
initial_sidebar_state="expanded",
|
| 8 |
menu_items={
|
| 9 |
+
"About": "**📡 NPO DB Query v0.2.4**",
|
| 10 |
},
|
| 11 |
)
|
| 12 |
|
|
|
|
| 16 |
st.Page("apps/database_page.py", title="Generate Databases"),
|
| 17 |
st.Page("apps/core_dump_page.py", title="Parse dump core"),
|
| 18 |
st.Page("apps/import_physical_db.py", title="Physical Database Management"),
|
| 19 |
+
st.Page("apps/gps_converter.py", title="GPS Converter"),
|
| 20 |
],
|
| 21 |
"Documentations": [
|
| 22 |
st.Page("documentations/database_doc.py", title="Databases Documentation"),
|
apps/gps_converter.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from lat_lon_parser import parse, to_str_deg_min_sec
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class DataFrames:
|
| 7 |
+
Dframe = pd.DataFrame()
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# def gps_converter_page():
|
| 11 |
+
st.title("GPS Coordinate Converter")
|
| 12 |
+
st.write(
|
| 13 |
+
"""This program allows you to convert coordinates from degree-minute-second (13°15'6.20"N) to decimal (13.2517222222222) and vice versa.
|
| 14 |
+
Please choose a file containing the latitude and longitude columns.
|
| 15 |
+
"""
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
uploaded_file = st.file_uploader("Choose a file", type=["xlsx"])
|
| 19 |
+
col1_list = []
|
| 20 |
+
if uploaded_file is not None:
|
| 21 |
+
DataFrames.Dframe = pd.read_excel(uploaded_file, keep_default_na=False)
|
| 22 |
+
col1_list = DataFrames.Dframe.columns.tolist()
|
| 23 |
+
|
| 24 |
+
latitude_dd = st.selectbox("Choose Latitude Column", options=col1_list)
|
| 25 |
+
longitude_dd = st.selectbox("Choose Longitude Column", options=col1_list)
|
| 26 |
+
|
| 27 |
+
conversion_choice = st.selectbox(
|
| 28 |
+
"Choose Conversion Type", options=["Decimal", "DegMinSec"]
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
if st.button("CONVERT", type="primary"):
|
| 32 |
+
|
| 33 |
+
try:
|
| 34 |
+
# if not latitude_dd or not longitude_dd:
|
| 35 |
+
# st.error("Please choose the latitude and longitude columns")
|
| 36 |
+
|
| 37 |
+
# if DataFrames.Dframe.empty:
|
| 38 |
+
# st.error("Please choose a file first")
|
| 39 |
+
|
| 40 |
+
df = DataFrames.Dframe.copy()
|
| 41 |
+
|
| 42 |
+
df["converted_latitude"] = df[latitude_dd]
|
| 43 |
+
df["converted_longitude"] = df[longitude_dd]
|
| 44 |
+
|
| 45 |
+
if conversion_choice == "Decimal":
|
| 46 |
+
df["converted_longitude"] = df["converted_longitude"].str.replace(
|
| 47 |
+
"O", "W"
|
| 48 |
+
)
|
| 49 |
+
df["converted_latitude"] = df["converted_latitude"].apply(parse)
|
| 50 |
+
df["converted_longitude"] = df["converted_longitude"].apply(parse)
|
| 51 |
+
else:
|
| 52 |
+
df["converted_latitude"] = df["converted_latitude"].apply(
|
| 53 |
+
to_str_deg_min_sec
|
| 54 |
+
)
|
| 55 |
+
df["converted_longitude"] = df["converted_longitude"].apply(
|
| 56 |
+
to_str_deg_min_sec
|
| 57 |
+
)
|
| 58 |
+
df["converted_latitude"] = df["converted_latitude"].apply(
|
| 59 |
+
lambda x: x.replace("-", "") + "S" if "-" in x else x + "N"
|
| 60 |
+
)
|
| 61 |
+
df["converted_longitude"] = df["converted_longitude"].apply(
|
| 62 |
+
lambda x: x.replace("-", "") + "W" if "-" in x else x + "E"
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
DataFrames.Dframe = df
|
| 66 |
+
st.success("Coordinates converted Sucessfully")
|
| 67 |
+
st.write(DataFrames.Dframe)
|
| 68 |
+
except Exception as e:
|
| 69 |
+
st.error(
|
| 70 |
+
f"An error occurred. Make sure the file contains the latitude and longitude columns. Error: {e}"
|
| 71 |
+
)
|
| 72 |
+
else:
|
| 73 |
+
st.info("Please choose a file containing the latitude and longitude columns")
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
# gps_converter_page()
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|