map-tiles / app.py
Omnibus's picture
Update app.py
40da3e8 verified
import os
import gradio as gr
from huggingface_hub import HfApi
from pydriosm.reader import GeofabrikReader
reponame="Omnibus/osm"
save_data=f'https://huggingface.co/datasets/{reponame}/raw/main/'
token_self = os.environ['HF_TOKEN']
api=HfApi(token=token_self)
def save_file_data(inp, key):
if inp == os.environ.get("PASS"):
try:
file_obj=inp
api.upload_file(
path_or_fileobj=inp,
path_in_repo=inp,
repo_id=reponame,
#repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
token=token_self,
repo_type="dataset",
)
print("Done")
except Exception as e:
print(e)
def get_map(inp):
if inp == os.environ.get("PASS"):
print("downloading")
#os.system("wget https://download.geofabrik.de/north-america/canada/quebec-latest.osm.pbf")
os.system("wget https://download.geofabrik.de/north-america-latest.osm.pbf")
print("done")
#out = os.path.abspath("quebec-latest.osm.pbf")
#print (out)
save_file_data("north-america-latest.osm.pbf", inp)
print("saved")
def process_data():
gfr = GeofabrikReader()
subrgn_name=""
parsed_1 = gfr.read_osm_pbf(
subregion_name=subrgn_name, data_dir=dat_dir, expand=True, verbose=True)
with gr.Blocks() as app:
with gr.Tab("Process"):
proc_btn=gr.Button("Process")
with gr.Tab("Load"):
with gr.Row():
inp_pass=gr.Textbox()
btn=gr.Button()
btn.click(get_map,inp_pass,None)
app.launch()