antiquesordo commited on
Commit
992d98d
·
verified ·
1 Parent(s): 77b81ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -24
app.py CHANGED
@@ -2,9 +2,6 @@ import folium
2
  from folium.plugins import MeasureControl, FloatImage
3
  from folium.features import DivIcon
4
  import os
5
- from selenium import webdriver
6
- from selenium.webdriver.chrome.service import Service
7
- from webdriver_manager.chrome import ChromeDriverManager
8
  from bs4 import BeautifulSoup
9
  import simplekml
10
  import gradio as gr
@@ -84,38 +81,19 @@ def create_permaculture_map(coordinates, output_dir="output"):
84
  map_path = os.path.join(output_dir, "permaculture_map.html")
85
  map.save(map_path)
86
 
87
- # Export the map as PNG, SVG, and KML
88
  export_map(map_path, coordinates, output_dir)
89
 
90
  return map_path
91
 
92
- # Function to export the map as PNG, SVG, and KML
93
  def export_map(map_path, coordinates, output_dir):
94
- # Export as PNG using Selenium
95
- export_png(map_path, output_dir)
96
-
97
  # Export as SVG using BeautifulSoup
98
  export_svg(map_path, output_dir)
99
 
100
  # Export as KML using SimpleKML
101
  export_kml(coordinates, output_dir)
102
 
103
- # Function to export the map as PNG
104
- def export_png(map_path, output_dir):
105
- options = webdriver.ChromeOptions()
106
- options.add_argument("--headless") # Run in headless mode
107
- options.add_argument("--disable-gpu")
108
- options.add_argument("--window-size=1920x1080")
109
-
110
- driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
111
- driver.get(f"file://{os.path.abspath(map_path)}")
112
- driver.implicitly_wait(10) # Wait for the map to load
113
-
114
- png_path = os.path.join(output_dir, "permaculture_map.png")
115
- driver.save_screenshot(png_path)
116
- driver.quit()
117
- print(f"Map exported as PNG: {png_path}")
118
-
119
  # Function to export the map as SVG
120
  def export_svg(map_path, output_dir):
121
  with open(map_path, "r", encoding="utf-8") as file:
 
2
  from folium.plugins import MeasureControl, FloatImage
3
  from folium.features import DivIcon
4
  import os
 
 
 
5
  from bs4 import BeautifulSoup
6
  import simplekml
7
  import gradio as gr
 
81
  map_path = os.path.join(output_dir, "permaculture_map.html")
82
  map.save(map_path)
83
 
84
+ # Export the map as SVG and KML
85
  export_map(map_path, coordinates, output_dir)
86
 
87
  return map_path
88
 
89
+ # Function to export the map as SVG and KML
90
  def export_map(map_path, coordinates, output_dir):
 
 
 
91
  # Export as SVG using BeautifulSoup
92
  export_svg(map_path, output_dir)
93
 
94
  # Export as KML using SimpleKML
95
  export_kml(coordinates, output_dir)
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  # Function to export the map as SVG
98
  def export_svg(map_path, output_dir):
99
  with open(map_path, "r", encoding="utf-8") as file: