# 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 math
import geojson
import codecs
import sys
import argparse
import time
from roadmaptools.printer import print_info
from roadmaptools.init import config


def compute_edge_curvatures(input_filename: str, output_filename: str):

    print_info('Computing average edge curvatures.')
    start_time = time.time()

    input_stream = open(input_filename, encoding='utf8')
    output_stream = open(output_filename, 'w')

    print_info("Loading geojson from: {}".format(input_filename))
    geojson_file = load_geojson(input_stream)

    print_info("Calculating curvature")
    geojson_out = get_geojson_with_curvature(geojson_file)

    print_info("Saving geojson to: {}".format(output_filename))
    save_geojson(geojson_out, output_stream)
    input_stream.close()
    output_stream.close()

    print_info('Curvature computation process finished. (%.2f secs)' % (time.time() - start_time))


def calculate_curvature(input_stream, output_stream):
    json_dict = load_geojson(input_stream)
    analyse_roads(json_dict)
    save_geojson(json_dict, output_stream)



# 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/calculate_curvature.py
import math
import geojson
import codecs
import sys
import argparse
import time
from roadmaptools.printer import print_info
from roadmaptools.init import config



def compute_edge_curvatures(input_filename: str, output_filename: str):

    print_info('Computing average edge curvatures.')
    start_time = time.time()

    input_stream = open(input_filename, encoding='utf8')
    output_stream = open(output_filename, 'w')

    print_info("Loading geojson from: {}".format(input_filename))
    geojson_file = load_geojson(input_stream)

    print_info("Calculating curvature")
    geojson_out = get_geojson_with_curvature(geojson_file)

    print_info("Saving geojson to: {}".format(output_filename))
    save_geojson(geojson_out, output_stream)
    input_stream.close()
    output_stream.close()

    print_info('Curvature computation process finished. (%.2f secs)' % (time.time() - start_time))


def calculate_curvature(input_stream, output_stream):
    json_dict = load_geojson(input_stream)
    analyse_roads(json_dict)
    save_geojson(json_dict, output_stream)



def get_geojson_with_curvature(json_dict):