Created
December 8, 2021 12:53
-
-
Save anton-petrov/890b4f672abff8585cb04568a1dfe595 to your computer and use it in GitHub Desktop.
Test centerline fork
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pickle | |
| from shapely.geometry import Polygon | |
| from centerline.geometry import Centerline | |
| import time | |
| def st_time(func): | |
| """ | |
| st decorator to calculate the total time of a func | |
| """ | |
| def st_func(*args, **keyArgs): | |
| t1 = time.time() | |
| r = func(*args, **keyArgs) | |
| t2 = time.time() | |
| print("Function=%s, Time=%s" % (func.__name__, t2 - t1)) | |
| return r | |
| return st_func | |
| file_name = '' | |
| with open(file_name + '.pkl', 'rb') as f: | |
| input_data = pickle.load(f) | |
| print(type(input_data)) | |
| attributes = {"id": 1, "name": "polygon", "valid": True, | |
| 'interpolation_distance': 0.0001, "multiprocess": True} | |
| @st_time | |
| def get_centerline(): | |
| centerline_simple = Centerline(input_data, **attributes) | |
| return centerline_simple | |
| output_data = get_centerline() | |
| print(type(output_data)) | |
| with open(file_name + '_centerline.pkl', 'wb') as f: | |
| pickle.dump(output_data, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment