mirror of
https://github.com/josejuanmartinez/libreCatastro.git
synced 2024-07-06 15:22:28 +02:00
Added option to execute the script with a specific json coordinate file.
This commit is contained in:
parent
89b3cb5994
commit
832f0e6239
7
main.py
7
main.py
@ -1,4 +1,9 @@
|
||||
import sys
|
||||
|
||||
from src.librecatastro.catastro_scrapper import CadastroScrapper
|
||||
|
||||
if __name__ == "__main__":
|
||||
CadastroScrapper.scrap_all()
|
||||
filename = ''
|
||||
if len(sys.argv) > 1:
|
||||
filename = sys.argv[1]
|
||||
CadastroScrapper.scrap_all(filename)
|
||||
|
@ -37,18 +37,20 @@ class CadastroScrapper:
|
||||
|
||||
""" Scrapping main calls """
|
||||
@staticmethod
|
||||
def scrap_all():
|
||||
def scrap_all(filename=''):
|
||||
for r, d, files in os.walk(config['coordinates_path']):
|
||||
for file in files:
|
||||
if '.json' in file:
|
||||
f = open(os.path.join(config['coordinates_path'], file), "r")
|
||||
content = f.read()
|
||||
try:
|
||||
bb = KibanaGeoBoundingBox(content)
|
||||
coordinates_tuple = bb.get_coordinates_tuple()
|
||||
CadastroScrapper.scrap_range_of_coordinates(coordinates_tuple[0], coordinates_tuple[1], coordinates_tuple[2], coordinates_tuple[3])
|
||||
except:
|
||||
logger.error("{} is not formatted properly. Please take a look at the examples.".format(file))
|
||||
print(file, filename)
|
||||
if '.json' in file and ((filename != '' and file == filename) or filename == ''):
|
||||
print(file)
|
||||
f = open(os.path.join(config['coordinates_path'], file), "r")
|
||||
content = f.read()
|
||||
try:
|
||||
bb = KibanaGeoBoundingBox(content)
|
||||
coordinates_tuple = bb.get_coordinates_tuple()
|
||||
CadastroScrapper.scrap_range_of_coordinates(coordinates_tuple[0], coordinates_tuple[1], coordinates_tuple[2], coordinates_tuple[3])
|
||||
except:
|
||||
logger.error("{} is not formatted properly. Please take a look at the examples.".format(file))
|
||||
|
||||
@staticmethod
|
||||
def scrap_range_of_coordinates(long_min, long_max, lat_min, lat_max):
|
||||
|
Loading…
Reference in New Issue
Block a user