adding sector kml generator app
Browse files- app.py +4 -0
- apps/sector_kml_generator.py +95 -0
- samples/Sector_kml.xlsx +0 -0
app.py
CHANGED
|
@@ -21,6 +21,10 @@ pages = {
|
|
| 21 |
"apps/multi_points_distance_calculator.py",
|
| 22 |
title="Multi Points Distance Calculator",
|
| 23 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
st.Page("apps/import_physical_db.py", title="Physical Database Verification"),
|
| 25 |
],
|
| 26 |
"Documentations": [
|
|
|
|
| 21 |
"apps/multi_points_distance_calculator.py",
|
| 22 |
title="Multi Points Distance Calculator",
|
| 23 |
),
|
| 24 |
+
st.Page(
|
| 25 |
+
"apps/sector_kml_generator.py",
|
| 26 |
+
title="π‘ Sector KML Generator",
|
| 27 |
+
),
|
| 28 |
st.Page("apps/import_physical_db.py", title="Physical Database Verification"),
|
| 29 |
],
|
| 30 |
"Documentations": [
|
apps/sector_kml_generator.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
+
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import streamlit as st
|
| 5 |
+
|
| 6 |
+
from utils.kml_creator import generate_kml_from_df
|
| 7 |
+
|
| 8 |
+
st.title("π‘ Telecom Sector KML Generator")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# display mandatory columns
|
| 12 |
+
|
| 13 |
+
col1, col2 = st.columns(2)
|
| 14 |
+
|
| 15 |
+
with col1:
|
| 16 |
+
st.write("Mandatory columns:")
|
| 17 |
+
st.markdown(
|
| 18 |
+
"""
|
| 19 |
+
| Column Name | Description |
|
| 20 |
+
| --- | --- |
|
| 21 |
+
| code| code of the site |
|
| 22 |
+
| name | Name of the sector |
|
| 23 |
+
| Azimut | Azimuth of the sector |
|
| 24 |
+
| Longitude | Longitude of the sector |
|
| 25 |
+
| Latitude | Latitude of the sector |
|
| 26 |
+
| Size | Size of the sector ex:100 |
|
| 27 |
+
| colors | Color of the sector |
|
| 28 |
+
"""
|
| 29 |
+
)
|
| 30 |
+
st.write(
|
| 31 |
+
"All other columns added in the file will be displayed in the KML description for each sector."
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
with col2:
|
| 35 |
+
st.markdown(
|
| 36 |
+
"""
|
| 37 |
+
| Color Name | KML Color Code (AABBGGRR) |
|
| 38 |
+
| --- | --- |
|
| 39 |
+
| Red | 7f0000ff |
|
| 40 |
+
| Green | 7f00ff00 |
|
| 41 |
+
| Blue | 7fff0000 |
|
| 42 |
+
| Yellow | 7f00ffff |
|
| 43 |
+
| Cyan | 7fffff00 |
|
| 44 |
+
| Magenta | 7fff00ff |
|
| 45 |
+
| Orange | 7f007fff |
|
| 46 |
+
| Purple | 7f7f00ff |
|
| 47 |
+
| Pink | 7fcc99ff |
|
| 48 |
+
| Brown | 7f2a2aa5 |
|
| 49 |
+
"""
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
sector_kml_sample_file = "samples/Sector_kml.xlsx"
|
| 53 |
+
|
| 54 |
+
# Create a download button
|
| 55 |
+
st.download_button(
|
| 56 |
+
label="Download Sector KML sample File",
|
| 57 |
+
data=open(sector_kml_sample_file, "rb").read(),
|
| 58 |
+
file_name="Sector_kml.xlsx",
|
| 59 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
st.write("Upload an excel file containing sectors data to generate a KML file.")
|
| 64 |
+
# Upload CSV file
|
| 65 |
+
uploaded_file = st.file_uploader("Upload XLSX file", type=["xlsx"])
|
| 66 |
+
|
| 67 |
+
if uploaded_file is not None:
|
| 68 |
+
# Read CSV
|
| 69 |
+
df = pd.read_excel(uploaded_file, keep_default_na=False)
|
| 70 |
+
|
| 71 |
+
# Check if required columns exist
|
| 72 |
+
required_columns = {
|
| 73 |
+
"code",
|
| 74 |
+
"name",
|
| 75 |
+
"Azimut",
|
| 76 |
+
"Longitude",
|
| 77 |
+
"Latitude",
|
| 78 |
+
"size",
|
| 79 |
+
"color",
|
| 80 |
+
}
|
| 81 |
+
if not required_columns.issubset(df.columns):
|
| 82 |
+
st.error(f"Uploaded file must contain columns: {', '.join(required_columns)}")
|
| 83 |
+
else:
|
| 84 |
+
# Generate KML
|
| 85 |
+
kml_data = generate_kml_from_df(df)
|
| 86 |
+
|
| 87 |
+
# Download button
|
| 88 |
+
st.download_button(
|
| 89 |
+
label="π₯ Download KML",
|
| 90 |
+
data=kml_data,
|
| 91 |
+
file_name=f"Sectors_kml_{datetime.now()}.kml",
|
| 92 |
+
mime="application/vnd.google-earth.kml+xml",
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
st.success("KML file generated successfully! π")
|
samples/Sector_kml.xlsx
ADDED
|
Binary file (12.1 kB). View file
|
|
|