# 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/init.py



import geojson
import codecs
import copy
import argparse
import sys
import time
import pandas as pd
import roadmaptools.inout
import roadmaptools.road_structures
from typing import Dict, Set, List, Tuple
from tqdm import tqdm, trange
from geojson import FeatureCollection, Feature
from pandas import DataFrame
from roadmaptools.printer import print_info
from roadmaptools.init import config
    start_time = time.time()
    feature_collection = roadmaptools.inout.load_geojson(input_file_path)
    prune_geojson_file(feature_collection, keep_attributes, remove_attributes)

    print_info('Cleaning complete. (%.2f secs)' % (time.time() - start_time))

    roadmaptools.inout.save_geojson(feature_collection, output_file_path)


def clean_geojson(input_stream, output_stream):
    json_dict = _load_geojson(input_stream)
    json_deleted = get_geojson_with_deleted_features(json_dict)
    # save_geojson(output_stream, json_deleted)
    prune_geojson_file(json_dict)
    save_geojson(json_dict, output_stream)


# def get_cleaned_geojson(json_dict):
# 	print_info("Cleaning geojson")
# 	prune_geojson_file(json_dict)
# 	print_info("Removing empty features")
# 	json_dict['features'] = [i for i in json_dict["features"] if i]  # remove empty dicts
# 	return json_dict


def remove_properties(item, keep_attributes: Set[str], remove_attributes: Set[str]) -> Feature:
    if remove_attributes:
        item['properties'] = {k: v for k, v in item['properties'].items() if k not in remove_attributes}
    else:
        item['properties'] = {k: v for k, v in item['properties'].items() if k in keep_attributes}

# 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/init.py



# Path: roadmaptools/clean_geojson.py
import geojson
import codecs
import copy
import argparse
import sys
import time
import pandas as pd
import roadmaptools.inout
import roadmaptools.road_structures
from typing import Dict, Set, List, Tuple
from tqdm import tqdm, trange
from geojson import FeatureCollection, Feature
from pandas import DataFrame
from roadmaptools.printer import print_info
from roadmaptools.init import config

    start_time = time.time()
    feature_collection = roadmaptools.inout.load_geojson(input_file_path)
    prune_geojson_file(feature_collection, keep_attributes, remove_attributes)

    print_info('Cleaning complete. (%.2f secs)' % (time.time() - start_time))

    roadmaptools.inout.save_geojson(feature_collection, output_file_path)


def clean_geojson(input_stream, output_stream):
    json_dict = _load_geojson(input_stream)
    json_deleted = get_geojson_with_deleted_features(json_dict)
    # save_geojson(output_stream, json_deleted)
    prune_geojson_file(json_dict)
    save_geojson(json_dict, output_stream)


# def get_cleaned_geojson(json_dict):
# 	print_info("Cleaning geojson")
# 	prune_geojson_file(json_dict)
# 	print_info("Removing empty features")
# 	json_dict['features'] = [i for i in json_dict["features"] if i]  # remove empty dicts
# 	return json_dict


def remove_properties(item, keep_attributes: Set[str], remove_attributes: Set[str]) -> Feature:
    if remove_attributes:
        item['properties'] = {k: v for k, v in item['properties'].items() if k not in remove_attributes}
    else:
        item['properties'] = {k: v for k, v in item['properties'].items() if k in keep_attributes}

    return item