def file_osm(directory, coordinates_points): """ This function gets a list with tuples corresponding a geographic points. Each tuple has the coordinates (lat, lon) of the point. Then, it creates a bounding box which contain all coordinates inside. Besides, it checks if exists a Open Street Map '.osm' file in a directory. If it not exists, this function downloads the file. :param file_name: String :param coordinates_points: list the list contains tuples. Each tuple has the latitude and the longitude corresponding to the geographic point. [(lat, lon)] :return: """ coordinates_list = Coordinates.coordinates_list_bbox( coordinates_points, margin_value_coordinate=0.0) file_name = directory + Coordinates.def_file_name( coordinates_list) + '.osm' file = Saves.verify_file_exists(coordinates_list, file_name) if file is not False: print("OSM exists in ", file) return MAPS_DIRECTORY + file coordinates_list = Coordinates.coordinates_list_bbox(coordinates_points) coordinates_osm = Coordinates.coordinates_string(coordinates_list) file_name = directory + Coordinates.def_file_name( coordinates_list) + '.osm' # it just download a new osm file if does not exists a file with # the current coordinates _osm(coordinates_osm, file_name) return file_name
def def_file_name(directory, coordinates_points, extension): coordinates_list = Coordinates.coordinates_list_bbox(coordinates_points) file_name = directory + Coordinates.def_file_name( coordinates_list) + extension return file_name