def import_parish_geojson(import_key: str, force: int): geojson_output_file = settings.output_parish if import_key != settings.import_key: return {"Result": 0, "Reason": "Incorrect key."} force = force == 1 execute = overpass_to_geojson( output_file=geojson_output_file, area_id=3600049715, force_download=force, response_type="xml", out="geom", boundary="religious_administration", admin_level="10", ) if execute: # 1. Format .geojson file geojson_output_file = simplify_geojson(geojson_output_file) # 2. Geojson file to MongoDB export geojson_to_mongodb(geojson_output_file, settings.database, settings.PARISH_COLLECTION) return {"Result": 1} return {"Result": 0, "Reason": "No changes"}
def import_monastery_geojson(import_key: str, force: int): if import_key != settings.import_key: return {"Result": 0, "Reason": "Incorrect key."} geojson_output_file = settings.output_monastery force = force == 1 execute = overpass_to_geojson( output_file=geojson_output_file, area_id=3600049715, force_download=force, amenity="monastery", ) if execute: geojson_output_file = simplify_geojson_geometry(geojson_output_file) # 2. Geojson file to MongoDB export geojson_to_mongodb(geojson_output_file, settings.database, settings.MONASTERY_COLLECTION) return {"Result": 1} return {"Result": 0, "Reason": "No changes"}
def import_office_geojson(import_key: str, force: int): geojson_output_file = settings.output_office if import_key != settings.import_key: return {"Result": 0, "Reason": "Incorrect key."} force = force == 1 execute = overpass_to_geojson( output_file=geojson_output_file, area_id=3600049715, force_download=force, office="religion", ) if execute: # 1. Format .geojson file geojson_output_file = filter_osm_geojson( geojson_output_file, tags=False, coords=True ) # 2. Geojson file to MongoDB export geojson_to_mongodb( geojson_output_file, settings.database, settings.OFFICE_COLLECTION ) return {"Result": 1} return {"Result": 0, "Reason": "No changes"}
def import_pow_geojson(import_key: str, force: int): geojson_output_file = settings.output_place_of_worship if import_key != settings.import_key: return {"Result": 0, "Reason": "Incorrect key."} force = force == 1 # 1 execute = overpass_to_geojson( output_file=geojson_output_file, area_id=3600049715, force_download=force, amenity="place_of_worship", ) if execute: # 1. Filter Geojson: geojson_file_processed = filter_osm_geojson(geojson_output_file) # 2. Compare with Wikidata geojson_file_processed = compare_osm_wikidata(geojson_file_processed) # 2. Simplify geometry geojson_file_processed = simplify_geojson_geometry(geojson_output_file) # 2. Geojson file to MongoDB export if geojson_file_processed: geojson_to_mongodb(geojson_file_processed, settings.database, settings.POW_COLLECTION) # 3. Generate statistics of usage of some tags statistics_to_html_file( "religion", osm_tag_statistics("religion", settings.database, settings.POW_COLLECTION), "templates/religion_stats.html", ) statistics_to_html_file( "denomination", osm_tag_statistics("denomination", settings.database, settings.POW_COLLECTION), "templates/denomination_stats.html", ) statistics_to_html_file( "church:type", osm_tag_statistics("church:type", settings.database, settings.POW_COLLECTION), "templates/churchtype_stats.html", ) statistics_to_html_file( "building", osm_tag_statistics("building", settings.database, settings.POW_COLLECTION), "templates/building_stats.html", ) import_date = datetime.datetime.now().replace(second=0, microsecond=0) export_date_to_html_file(import_date, "templates/export.html") return {"Result": 1} else: return {"Result": 0, "Reason": "Error, incorrect processed file"} return {"Result": 0, "Reason": "No changes"}