# Path: roadmaptools/init.py

# 
# Path: roadmaptools/printer.py
# def print_info(info, file=sys.stdout, end="\n"):
#     print("[{0}]: {1}".format(datetime.now().strftime('%H:%M:%S'), info), file=file, end=end)


import networkx as nx
import roadmaptools.inout
from networkx import DiGraph
from geojson.feature import FeatureCollection
from tqdm import tqdm
from roadmaptools.init import config
from roadmaptools.printer import print_info
			edge_ids.add(id)

	return edge_ids


def filter_geojson_features_by_graph(geojson_data: FeatureCollection, edge_ids: set):

	print_info("Filtering geojson by edge id set")
	new_features = []
	for item in tqdm(geojson_data['features'], desc="processing features"):
		if item['properties']['id'] in edge_ids:
			new_features.append(item)

	geojson_data["features"] = new_features


# def _detect_parallel_edges(graph):
# 	set_of_edges = set()
# 	for n, nbrsdict in list(graph.adjacency()):
# 		for nbr, keydict in nbrsdict.items():
# 			for key, d in keydict.items():
# 				if key != 0:
# 					if (n, nbr) in set_of_edges:
# 						temp_edges.append((graph[n][nbr][key], get_node_reversed(n), get_node_reversed(nbr), True))
# 					else:
# 						set_of_edges.add((nbr, n))  # add the second direction to set!!
# 						temp_edges.append((graph[n][nbr][key], get_node_reversed(n), get_node_reversed(nbr), False))
# 					graph.remove_edge(n, nbr, key)



# Path: roadmaptools/init.py

# 
# Path: roadmaptools/printer.py
# def print_info(info, file=sys.stdout, end="\n"):
#     print("[{0}]: {1}".format(datetime.now().strftime('%H:%M:%S'), info), file=file, end=end)


# Path: roadmaptools/sanitize.py
import networkx as nx
import roadmaptools.inout
from networkx import DiGraph
from geojson.feature import FeatureCollection
from tqdm import tqdm
from roadmaptools.init import config
from roadmaptools.printer import print_info

			edge_ids.add(id)

	return edge_ids


def filter_geojson_features_by_graph(geojson_data: FeatureCollection, edge_ids: set):

	print_info("Filtering geojson by edge id set")
	new_features = []
	for item in tqdm(geojson_data['features'], desc="processing features"):
		if item['properties']['id'] in edge_ids:
			new_features.append(item)

	geojson_data["features"] = new_features


# def _detect_parallel_edges(graph):
# 	set_of_edges = set()
# 	for n, nbrsdict in list(graph.adjacency()):
# 		for nbr, keydict in nbrsdict.items():
# 			for key, d in keydict.items():
# 				if key != 0:
# 					if (n, nbr) in set_of_edges:
# 						temp_edges.append((graph[n][nbr][key], get_node_reversed(n), get_node_reversed(nbr), True))
# 					else:
# 						set_of_edges.add((nbr, n))  # add the second direction to set!!
# 						temp_edges.append((graph[n][nbr][key], get_node_reversed(n), get_node_reversed(nbr), False))
# 					graph.remove_edge(n, nbr, key)



def sanitize(input_filepath: str=config.cleaned_geojson_file, output_filepath: str=config.sanitized_geojson_file):