Spaces:
Sleeping
Sleeping
Commit
·
0527b5a
0
Parent(s):
Duplicate from DavMelchi/solara-gps-converter
Browse files- .github/workflows/sync-hf.yml +20 -0
- .gitignore +160 -0
- .history/README_20230619150004.md +25 -0
- .history/README_20230619151116.md +30 -0
- .history/pages/00_home_20230619150004.py +25 -0
- .history/pages/00_home_20230619150424.py +101 -0
- .history/requirements_20230619150004.txt +5 -0
- .history/requirements_20230619150422.txt +3 -0
- Dockerfile +21 -0
- LICENSE +21 -0
- README.md +30 -0
- pages/00_home.py +101 -0
- requirements.txt +3 -0
.github/workflows/sync-hf.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face hub
|
| 2 |
+
on:
|
| 3 |
+
push:
|
| 4 |
+
branches: [main]
|
| 5 |
+
|
| 6 |
+
# to run this workflow manually from the Actions tab
|
| 7 |
+
workflow_dispatch:
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
sync-to-hub:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/checkout@v3
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 0
|
| 16 |
+
lfs: true
|
| 17 |
+
- name: Push to hub
|
| 18 |
+
env:
|
| 19 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
+
run: git push --force https://giswqs:$HF_TOKEN@huggingface.co/spaces/giswqs/solara-geospatial main
|
.gitignore
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
.Python
|
| 11 |
+
build/
|
| 12 |
+
develop-eggs/
|
| 13 |
+
dist/
|
| 14 |
+
downloads/
|
| 15 |
+
eggs/
|
| 16 |
+
.eggs/
|
| 17 |
+
lib/
|
| 18 |
+
lib64/
|
| 19 |
+
parts/
|
| 20 |
+
sdist/
|
| 21 |
+
var/
|
| 22 |
+
wheels/
|
| 23 |
+
share/python-wheels/
|
| 24 |
+
*.egg-info/
|
| 25 |
+
.installed.cfg
|
| 26 |
+
*.egg
|
| 27 |
+
MANIFEST
|
| 28 |
+
|
| 29 |
+
# PyInstaller
|
| 30 |
+
# Usually these files are written by a python script from a template
|
| 31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 32 |
+
*.manifest
|
| 33 |
+
*.spec
|
| 34 |
+
|
| 35 |
+
# Installer logs
|
| 36 |
+
pip-log.txt
|
| 37 |
+
pip-delete-this-directory.txt
|
| 38 |
+
|
| 39 |
+
# Unit test / coverage reports
|
| 40 |
+
htmlcov/
|
| 41 |
+
.tox/
|
| 42 |
+
.nox/
|
| 43 |
+
.coverage
|
| 44 |
+
.coverage.*
|
| 45 |
+
.cache
|
| 46 |
+
nosetests.xml
|
| 47 |
+
coverage.xml
|
| 48 |
+
*.cover
|
| 49 |
+
*.py,cover
|
| 50 |
+
.hypothesis/
|
| 51 |
+
.pytest_cache/
|
| 52 |
+
cover/
|
| 53 |
+
|
| 54 |
+
# Translations
|
| 55 |
+
*.mo
|
| 56 |
+
*.pot
|
| 57 |
+
|
| 58 |
+
# Django stuff:
|
| 59 |
+
*.log
|
| 60 |
+
local_settings.py
|
| 61 |
+
db.sqlite3
|
| 62 |
+
db.sqlite3-journal
|
| 63 |
+
|
| 64 |
+
# Flask stuff:
|
| 65 |
+
instance/
|
| 66 |
+
.webassets-cache
|
| 67 |
+
|
| 68 |
+
# Scrapy stuff:
|
| 69 |
+
.scrapy
|
| 70 |
+
|
| 71 |
+
# Sphinx documentation
|
| 72 |
+
docs/_build/
|
| 73 |
+
|
| 74 |
+
# PyBuilder
|
| 75 |
+
.pybuilder/
|
| 76 |
+
target/
|
| 77 |
+
|
| 78 |
+
# Jupyter Notebook
|
| 79 |
+
.ipynb_checkpoints
|
| 80 |
+
|
| 81 |
+
# IPython
|
| 82 |
+
profile_default/
|
| 83 |
+
ipython_config.py
|
| 84 |
+
|
| 85 |
+
# pyenv
|
| 86 |
+
# For a library or package, you might want to ignore these files since the code is
|
| 87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
| 88 |
+
# .python-version
|
| 89 |
+
|
| 90 |
+
# pipenv
|
| 91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 94 |
+
# install all needed dependencies.
|
| 95 |
+
#Pipfile.lock
|
| 96 |
+
|
| 97 |
+
# poetry
|
| 98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 100 |
+
# commonly ignored for libraries.
|
| 101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 102 |
+
#poetry.lock
|
| 103 |
+
|
| 104 |
+
# pdm
|
| 105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 106 |
+
#pdm.lock
|
| 107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 108 |
+
# in version control.
|
| 109 |
+
# https://pdm.fming.dev/#use-with-ide
|
| 110 |
+
.pdm.toml
|
| 111 |
+
|
| 112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 113 |
+
__pypackages__/
|
| 114 |
+
|
| 115 |
+
# Celery stuff
|
| 116 |
+
celerybeat-schedule
|
| 117 |
+
celerybeat.pid
|
| 118 |
+
|
| 119 |
+
# SageMath parsed files
|
| 120 |
+
*.sage.py
|
| 121 |
+
|
| 122 |
+
# Environments
|
| 123 |
+
.env
|
| 124 |
+
.venv
|
| 125 |
+
env/
|
| 126 |
+
venv/
|
| 127 |
+
ENV/
|
| 128 |
+
env.bak/
|
| 129 |
+
venv.bak/
|
| 130 |
+
|
| 131 |
+
# Spyder project settings
|
| 132 |
+
.spyderproject
|
| 133 |
+
.spyproject
|
| 134 |
+
|
| 135 |
+
# Rope project settings
|
| 136 |
+
.ropeproject
|
| 137 |
+
|
| 138 |
+
# mkdocs documentation
|
| 139 |
+
/site
|
| 140 |
+
|
| 141 |
+
# mypy
|
| 142 |
+
.mypy_cache/
|
| 143 |
+
.dmypy.json
|
| 144 |
+
dmypy.json
|
| 145 |
+
|
| 146 |
+
# Pyre type checker
|
| 147 |
+
.pyre/
|
| 148 |
+
|
| 149 |
+
# pytype static type analyzer
|
| 150 |
+
.pytype/
|
| 151 |
+
|
| 152 |
+
# Cython debug symbols
|
| 153 |
+
cython_debug/
|
| 154 |
+
|
| 155 |
+
# PyCharm
|
| 156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 160 |
+
#.idea/
|
.history/README_20230619150004.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Solara Geospatial
|
| 3 |
+
emoji: 🌍
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
app_port: 8765
|
| 10 |
+
duplicated_from: giswqs/solara-geospatial
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## Introduction
|
| 14 |
+
|
| 15 |
+
A collection of [Solara](https://github.com/widgetti/solara) web apps for geospatial applications
|
| 16 |
+
|
| 17 |
+
Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future.
|
| 18 |
+
|
| 19 |
+
- Web App: <https://giswqs-solara-geospatial.hf.space>
|
| 20 |
+
- GitHub: <https://github.com/opengeos/solara-geospatial>
|
| 21 |
+
- Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geospatial>
|
| 22 |
+
|
| 23 |
+
## Demos
|
| 24 |
+
|
| 25 |
+

|
.history/README_20230619151116.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Solara Gps_Converter
|
| 3 |
+
emoji: 🌍
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
app_port: 8765
|
| 10 |
+
duplicated_from: giswqs/solara-geospatial
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## Introduction
|
| 14 |
+
|
| 15 |
+
GPS Coordinate Converter provides a convenient way to convert GPS coordinates between different formats. It simplifies the process of converting latitude and longitude coordinates to various representations such as Decimal and degrees-minutes-seconds (DMS) coordinates.
|
| 16 |
+
|
| 17 |
+
## Features
|
| 18 |
+
|
| 19 |
+
- Convert GPS coordinates between Decimal and degrees-minutes-seconds (DMS)
|
| 20 |
+
- Accurate and reliable conversion algorithms
|
| 21 |
+
- Supports both forward and reverse coordinate conversions
|
| 22 |
+
- Simple and intuitive API
|
| 23 |
+
|
| 24 |
+
## Contributing
|
| 25 |
+
|
| 26 |
+
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
|
| 27 |
+
|
| 28 |
+
## Acknowledgements
|
| 29 |
+
|
| 30 |
+
Coordinate Converter is built upon the excellent Solara.<https://github.com/widgetti/solara>
|
.history/pages/00_home_20230619150004.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import solara
|
| 2 |
+
|
| 3 |
+
@solara.component
|
| 4 |
+
def Page():
|
| 5 |
+
|
| 6 |
+
markdown = """
|
| 7 |
+
## Solara for Geospatial Applications
|
| 8 |
+
|
| 9 |
+
### Introduction
|
| 10 |
+
|
| 11 |
+
**A collection of [Solara](https://github.com/widgetti/solara) web apps for geospatial applications.**
|
| 12 |
+
|
| 13 |
+
Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future. Click on the menu above to see the other pages.
|
| 14 |
+
|
| 15 |
+
- Web App: <https://giswqs-solara-geospatial.hf.space>
|
| 16 |
+
- GitHub: <https://github.com/opengeos/solara-geospatial>
|
| 17 |
+
- Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geospatial>
|
| 18 |
+
|
| 19 |
+
### Demos
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
solara.Markdown(markdown)
|
.history/pages/00_home_20230619150424.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, cast
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import os
|
| 4 |
+
import solara
|
| 5 |
+
from solara.components.file_drop import FileDrop
|
| 6 |
+
from lat_lon_parser import parse,to_str_deg_min_sec
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class State:
|
| 10 |
+
options = ["Decimal", "Deg_Min_Sec"]
|
| 11 |
+
option = solara.reactive("")
|
| 12 |
+
df = solara.reactive(cast(Optional[pd.DataFrame], None))
|
| 13 |
+
dff = solara.reactive(cast(Optional[pd.DataFrame], None))
|
| 14 |
+
latitude = solara.reactive(cast(Optional[str],""))
|
| 15 |
+
longitude = solara.reactive(cast(Optional[str],""))
|
| 16 |
+
extension_check = solara.reactive(True)
|
| 17 |
+
error_message = solara.reactive("")
|
| 18 |
+
|
| 19 |
+
@staticmethod
|
| 20 |
+
def load_from_file(file):
|
| 21 |
+
file_name, file_extension = os.path.splitext(file["name"])
|
| 22 |
+
if file_extension == ".csv":
|
| 23 |
+
df = pd.read_csv(file["file_obj"], encoding='latin-1')
|
| 24 |
+
State.df.value = df
|
| 25 |
+
State.extension_check.value = True
|
| 26 |
+
State.reset_vars()
|
| 27 |
+
else:
|
| 28 |
+
State.extension_check.value = False
|
| 29 |
+
State.df.value = None
|
| 30 |
+
State.reset_vars()
|
| 31 |
+
|
| 32 |
+
def reset_vars():
|
| 33 |
+
State.latitude.value = str("")
|
| 34 |
+
State.longitude.value = str("")
|
| 35 |
+
State.option.value = str("")
|
| 36 |
+
State.error_message.value =str("")
|
| 37 |
+
|
| 38 |
+
@staticmethod
|
| 39 |
+
def convert ():
|
| 40 |
+
State.error_message.value =""
|
| 41 |
+
try :
|
| 42 |
+
df = State.df.value
|
| 43 |
+
df['converted_latitude'] = df.loc[:, str(State.latitude.value)]
|
| 44 |
+
df['converted_longitude'] = df.loc[:, str(State.longitude.value)]
|
| 45 |
+
if State.option.value =="Decimal":
|
| 46 |
+
df['converted_longitude'] =df['converted_longitude'].str.replace('O','W')
|
| 47 |
+
df["converted_latitude"] =df["converted_latitude"].apply(parse)
|
| 48 |
+
df["converted_longitude"] =df["converted_longitude"].apply(parse)
|
| 49 |
+
elif State.option.value =="Deg_Min_Sec":
|
| 50 |
+
df["converted_latitude"] =df["converted_latitude"].apply(to_str_deg_min_sec)
|
| 51 |
+
df["converted_longitude"] =df["converted_longitude"].apply(to_str_deg_min_sec)
|
| 52 |
+
df["converted_latitude"] =df["converted_latitude"].apply(lambda x: x.replace("-", "") + "S" if "-" in x else x + "N")
|
| 53 |
+
df["converted_longitude"] =df["converted_longitude"].apply(lambda x: x.replace("-", "") + "W" if "-" in x else x + "E")
|
| 54 |
+
except Exception as es:
|
| 55 |
+
State.error_message.value = f"An error occurred. Please check your latitude and longitude format and ensure the correct conversion format ({es})"
|
| 56 |
+
else :
|
| 57 |
+
State.df.value = None
|
| 58 |
+
State.df.value = df
|
| 59 |
+
State.dff.value = State.df.value
|
| 60 |
+
|
| 61 |
+
@solara.component
|
| 62 |
+
def Page():
|
| 63 |
+
df = State.df.value
|
| 64 |
+
|
| 65 |
+
solara.Title("GPS Coordinates Converter")
|
| 66 |
+
|
| 67 |
+
with solara.Sidebar():
|
| 68 |
+
with solara.Column():
|
| 69 |
+
FileDrop(on_file=State.load_from_file, on_total_progress=lambda *args: None, label="Drag your file CSV here")
|
| 70 |
+
|
| 71 |
+
if State.extension_check.value is not True :
|
| 72 |
+
solara.Warning("Only CSV file are allowed")
|
| 73 |
+
else :
|
| 74 |
+
if df is not None:
|
| 75 |
+
columns = list(map(str, df.columns))
|
| 76 |
+
solara.Select("Latitude", values=columns, value=State.latitude)
|
| 77 |
+
solara.Select("Longitude", values=columns, value=State.longitude)
|
| 78 |
+
solara.Select("Convert To", values=State.options, value=State.option)
|
| 79 |
+
|
| 80 |
+
if State.longitude.value =="" or State.latitude.value == "" or State.option.value == "":
|
| 81 |
+
solara.Info("Select Coordinates Columns and Ouput Format")
|
| 82 |
+
else :
|
| 83 |
+
solara.Button("Convert", color="primary", text=True, outlined=True, on_click=State.convert)
|
| 84 |
+
if State.dff.value is not None:
|
| 85 |
+
def get_data():
|
| 86 |
+
return State.dff.value.to_csv(index=False)
|
| 87 |
+
solara.FileDownload(get_data, label=f"Download {len(State.dff.value):,} converted coordinates", filename="converted.csv",)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
if State.df.value is not None:
|
| 91 |
+
with solara.Column():
|
| 92 |
+
solara.DataFrame(State.df.value)
|
| 93 |
+
if State.error_message.value != "":
|
| 94 |
+
solara.Warning(State.error_message.value)
|
| 95 |
+
else:
|
| 96 |
+
solara.Info("Waiting for Data, Please upload a file.")
|
| 97 |
+
|
| 98 |
+
@solara.component
|
| 99 |
+
def Layout(children):
|
| 100 |
+
route, routes = solara.use_route()
|
| 101 |
+
return solara.AppLayout(children=children)
|
.history/requirements_20230619150004.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
geemap>=0.21.0
|
| 2 |
+
leafmap
|
| 3 |
+
mapwidget
|
| 4 |
+
solara
|
| 5 |
+
geopandas
|
.history/requirements_20230619150422.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
solara
|
| 2 |
+
pandas
|
| 3 |
+
lat_lon_parser
|
Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM jupyter/base-notebook:latest
|
| 2 |
+
|
| 3 |
+
RUN mamba install -c conda-forge leafmap geopandas localtileserver -y && \
|
| 4 |
+
fix-permissions "${CONDA_DIR}" && \
|
| 5 |
+
fix-permissions "/home/${NB_USER}"
|
| 6 |
+
|
| 7 |
+
COPY requirements.txt .
|
| 8 |
+
RUN pip install -r requirements.txt
|
| 9 |
+
|
| 10 |
+
RUN mkdir ./pages
|
| 11 |
+
COPY /pages ./pages
|
| 12 |
+
|
| 13 |
+
ENV PROJ_LIB='/opt/conda/share/proj'
|
| 14 |
+
|
| 15 |
+
USER root
|
| 16 |
+
RUN chown -R ${NB_UID} ${HOME}
|
| 17 |
+
USER ${NB_USER}
|
| 18 |
+
|
| 19 |
+
EXPOSE 8765
|
| 20 |
+
|
| 21 |
+
CMD ["solara", "run", "./pages", "--host=0.0.0.0"]
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023 Open Geospatial Solutions
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Solara Gps_Converter
|
| 3 |
+
emoji: 🌍
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
app_port: 8765
|
| 10 |
+
duplicated_from: DavMelchi/solara-gps-converter
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## Introduction
|
| 14 |
+
|
| 15 |
+
GPS Coordinate Converter provides a convenient way to convert GPS coordinates between different formats. It simplifies the process of converting latitude and longitude coordinates to various representations such as Decimal and degrees-minutes-seconds (DMS) coordinates.
|
| 16 |
+
|
| 17 |
+
## Features
|
| 18 |
+
|
| 19 |
+
- Convert GPS coordinates between Decimal and degrees-minutes-seconds (DMS)
|
| 20 |
+
- Accurate and reliable conversion algorithms
|
| 21 |
+
- Supports both forward and reverse coordinate conversions
|
| 22 |
+
- Simple and intuitive API
|
| 23 |
+
|
| 24 |
+
## Contributing
|
| 25 |
+
|
| 26 |
+
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
|
| 27 |
+
|
| 28 |
+
## Acknowledgements
|
| 29 |
+
|
| 30 |
+
Coordinate Converter is built upon the excellent Solara.<https://github.com/widgetti/solara>
|
pages/00_home.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, cast
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import os
|
| 4 |
+
import solara
|
| 5 |
+
from solara.components.file_drop import FileDrop
|
| 6 |
+
from lat_lon_parser import parse,to_str_deg_min_sec
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class State:
|
| 10 |
+
options = ["Decimal", "Deg_Min_Sec"]
|
| 11 |
+
option = solara.reactive("")
|
| 12 |
+
df = solara.reactive(cast(Optional[pd.DataFrame], None))
|
| 13 |
+
dff = solara.reactive(cast(Optional[pd.DataFrame], None))
|
| 14 |
+
latitude = solara.reactive(cast(Optional[str],""))
|
| 15 |
+
longitude = solara.reactive(cast(Optional[str],""))
|
| 16 |
+
extension_check = solara.reactive(True)
|
| 17 |
+
error_message = solara.reactive("")
|
| 18 |
+
|
| 19 |
+
@staticmethod
|
| 20 |
+
def load_from_file(file):
|
| 21 |
+
file_name, file_extension = os.path.splitext(file["name"])
|
| 22 |
+
if file_extension == ".csv":
|
| 23 |
+
df = pd.read_csv(file["file_obj"], encoding='latin-1')
|
| 24 |
+
State.df.value = df
|
| 25 |
+
State.extension_check.value = True
|
| 26 |
+
State.reset_vars()
|
| 27 |
+
else:
|
| 28 |
+
State.extension_check.value = False
|
| 29 |
+
State.df.value = None
|
| 30 |
+
State.reset_vars()
|
| 31 |
+
|
| 32 |
+
def reset_vars():
|
| 33 |
+
State.latitude.value = str("")
|
| 34 |
+
State.longitude.value = str("")
|
| 35 |
+
State.option.value = str("")
|
| 36 |
+
State.error_message.value =str("")
|
| 37 |
+
|
| 38 |
+
@staticmethod
|
| 39 |
+
def convert ():
|
| 40 |
+
State.error_message.value =""
|
| 41 |
+
try :
|
| 42 |
+
df = State.df.value
|
| 43 |
+
df['converted_latitude'] = df.loc[:, str(State.latitude.value)]
|
| 44 |
+
df['converted_longitude'] = df.loc[:, str(State.longitude.value)]
|
| 45 |
+
if State.option.value =="Decimal":
|
| 46 |
+
df['converted_longitude'] =df['converted_longitude'].str.replace('O','W')
|
| 47 |
+
df["converted_latitude"] =df["converted_latitude"].apply(parse)
|
| 48 |
+
df["converted_longitude"] =df["converted_longitude"].apply(parse)
|
| 49 |
+
elif State.option.value =="Deg_Min_Sec":
|
| 50 |
+
df["converted_latitude"] =df["converted_latitude"].apply(to_str_deg_min_sec)
|
| 51 |
+
df["converted_longitude"] =df["converted_longitude"].apply(to_str_deg_min_sec)
|
| 52 |
+
df["converted_latitude"] =df["converted_latitude"].apply(lambda x: x.replace("-", "") + "S" if "-" in x else x + "N")
|
| 53 |
+
df["converted_longitude"] =df["converted_longitude"].apply(lambda x: x.replace("-", "") + "W" if "-" in x else x + "E")
|
| 54 |
+
except Exception as es:
|
| 55 |
+
State.error_message.value = f"An error occurred. Please check your latitude and longitude format and ensure the correct conversion format ({es})"
|
| 56 |
+
else :
|
| 57 |
+
State.df.value = None
|
| 58 |
+
State.df.value = df
|
| 59 |
+
State.dff.value = State.df.value
|
| 60 |
+
|
| 61 |
+
@solara.component
|
| 62 |
+
def Page():
|
| 63 |
+
df = State.df.value
|
| 64 |
+
|
| 65 |
+
solara.Title("GPS Coordinates Converter")
|
| 66 |
+
|
| 67 |
+
with solara.Sidebar():
|
| 68 |
+
with solara.Column():
|
| 69 |
+
FileDrop(on_file=State.load_from_file, on_total_progress=lambda *args: None, label="Drag your file CSV here")
|
| 70 |
+
|
| 71 |
+
if State.extension_check.value is not True :
|
| 72 |
+
solara.Warning("Only CSV file are allowed")
|
| 73 |
+
else :
|
| 74 |
+
if df is not None:
|
| 75 |
+
columns = list(map(str, df.columns))
|
| 76 |
+
solara.Select("Latitude", values=columns, value=State.latitude)
|
| 77 |
+
solara.Select("Longitude", values=columns, value=State.longitude)
|
| 78 |
+
solara.Select("Convert To", values=State.options, value=State.option)
|
| 79 |
+
|
| 80 |
+
if State.longitude.value =="" or State.latitude.value == "" or State.option.value == "":
|
| 81 |
+
solara.Info("Select Coordinates Columns and Ouput Format")
|
| 82 |
+
else :
|
| 83 |
+
solara.Button("Convert", color="primary", text=True, outlined=True, on_click=State.convert)
|
| 84 |
+
if State.dff.value is not None:
|
| 85 |
+
def get_data():
|
| 86 |
+
return State.dff.value.to_csv(index=False)
|
| 87 |
+
solara.FileDownload(get_data, label=f"Download {len(State.dff.value):,} converted coordinates", filename="converted.csv",)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
if State.df.value is not None:
|
| 91 |
+
with solara.Column():
|
| 92 |
+
solara.DataFrame(State.df.value)
|
| 93 |
+
if State.error_message.value != "":
|
| 94 |
+
solara.Warning(State.error_message.value)
|
| 95 |
+
else:
|
| 96 |
+
solara.Info("Waiting for Data, Please upload a file.")
|
| 97 |
+
|
| 98 |
+
@solara.component
|
| 99 |
+
def Layout(children):
|
| 100 |
+
route, routes = solara.use_route()
|
| 101 |
+
return solara.AppLayout(children=children)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
solara
|
| 2 |
+
pandas
|
| 3 |
+
lat_lon_parser
|