Skip to content

Reference

Build

unweaver.build.build_graph.build_graph(path, precision=7, changes_sign=None, counter=None)

Build a graph in a project directory.

Parameters:

Name Type Description Default
path str

Path to the project directory.

required
precision int

Rounding precision for whether to connect two LineStrings end-to-end. Defaults to about 10 cm.

7
changes_sign Optional[List[str]]

A list of numeric edge fields whose values should change sign when traversed in the "reverse" direction. An incline value is an example of this: uphill is positive, downhill negative.

None
counter Optional[ProgressBar]

An optional Click counter.

None
Source code in unweaver/build/build_graph.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def build_graph(
    path: str,
    precision: int = 7,
    changes_sign: Optional[List[str]] = None,
    counter: Optional[ProgressBar] = None,
) -> DiGraphGPKG:
    """Build a graph in a project directory.

    :param path: Path to the project directory.
    :param precision: Rounding precision for whether to connect two
    LineStrings end-to-end. Defaults to about 10 cm.
    :param changes_sign: A list of numeric edge fields whose values should
    change sign when traversed in the "reverse" direction. An incline value
    is an example of this: uphill is positive, downhill negative.
    :param counter: An optional Click counter.

    """
    builder = GraphBuilder(precision=precision, changes_sign=changes_sign)

    paths = get_layers_paths(path)
    db_path = os.path.join(path, DB_PATH)

    for path in paths:
        builder.add_edges_from(path, counter=counter)

    builder.finalize_db(db_path)

    return builder.G