---
# System prepended metadata

title: Untitled

---

import json


"""
points and node...
doc z 的資料相較於 xy 不準確性太大了，所以算距離的時候，只考慮投影在 xy 上距離
補design doc
tick用 t 做，有時候會停下，沒辦法反映距離變化，
用 xyz 會是最理想的
我們使用 xy 因為 z 太不精準

"""

class Route():
    
    def __init__(self, route_type, src_marker, geojson):

    def read_src_marker(self):
        # read src_marker
        pass
    def read_geojson(self):
        pass

    def export_geojson(self):
        pass

    def create_route(self):
        # set up self.members
        self.elev_geodata = elev_geodata
        self.lon_geodata = lon_geodata
        self.lat_geodata = lat_geodata
        self.utc_geodata = utc_geodata
        self.geodata_T = data_geojson_T
        self.geodata = data_geojson

    def set_node_info(self):
        # set up self memebers related to self.node_list
        pass

    def gen_node_list_from_src_marker(self):
        # set up self.node_list
        pass

    def update_node_list(self):
        pass

    def fetch_controlled_nodes(self, node2align_set):
        control_nodes = []
        pass
        return control_nodes

    
    def clear_controlled_points(self):
        pass

    def gen_GPS_dist_ticks():
        # to be used in adjust_GPS
        pass

    def adjust_GPS(self, control_nodes):
        pass

    def adjust_elevation(self, control_nodes):
        pass

    @staticmethod
    def dist_GPS_utm(gps1, gps2):
        return dist


"""
k = 1
拿 k = 1, k+1
routes_k0 = []
routes_k1 = []
for route, rank in zip(routes, ranks):
    if rank == k:
        routes_k0.append(route)
    ....

"""



import numpy as np
from Route import Route

class AlignRoutes():
    def __init__(self, routes, 
                       main_route_idx, 
                       geojson, 
                       nodes=None):
       # If source_marker is None, then generate nodes,
        #routes_src_info
        
        self.routes_src_info = routes_src_info

    
    # combine create_routes_w_src_marker, wo_src_marker
    def create_routes_w_src_marker(self):
        # go throgh routes_src_info
        # route.create_route() to create self.routes_list
        # route.gen_node_list_from_src_marker()
        # route.set_node_info()
        pass

    def create_routes_wo_src_marker(self):
        # go through routes_list
        # route.create_route()
        # call self.node_detection() to set up node_list for each route
        # route.set_node_info

    def assign_rank(self):
        # loop over route_list and assign rank for each route
        # assign self.route_set
        # report disconnected routes

    def node2align_set(self, route_set):
        # from nodes in route_set fetch unique node set
        return node_set

    def adjust_routes(self):
        # go through self.route_set
        # gen node_set with  self.node2align_set()
        # fetch_controlled_points
        # adjust_GPS()
        pass

    def node_detection(self):
        # go through self.routes_list and find nodes
        # route.node_list will be set here

    def align_routes_w_src_marker(self):
        # main flow for align routes w src marker

    def align_routes_wo_src_marker(self):
        # main flow for align routes wo src marker