MCPcopy Create free account
hub / github.com/Notgnoshi/generative / main

Function main

tools/geom2graph.rs:66–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64}
65
66fn main() -> eyre::Result<()> {
67 color_eyre::install()?;
68 let args = CmdlineOptions::parse();
69
70 let filter = tracing_subscriber::EnvFilter::builder()
71 .with_default_directive(args.log_level.into())
72 .from_env_lossy();
73 tracing_subscriber::fmt()
74 .with_env_filter(filter)
75 .with_ansi(true)
76 .with_writer(std::io::stderr)
77 .init();
78
79 let reader = get_input_reader(&args.input)?;
80 let writer = get_output_writer(&args.output)?;
81
82 let strategy = match args.snap_strategy {
83 CliSnappingStrategy::ClosestPoint => {
84 SnappingStrategy::ClosestPoint(args.tolerance.unwrap_or_default())
85 }
86 CliSnappingStrategy::RegularGrid => {
87 SnappingStrategy::RegularGrid(args.tolerance.unwrap_or_default())
88 }
89 };
90
91 if args.geom2graph || !args.graph2geom {
92 let geometries = read_geometries(reader);
93 let graph = node::<_, petgraph::Undirected>(geometries);
94
95 let graph = if args.tolerance.is_some() {
96 snap_graph(graph, strategy)
97 } else {
98 graph
99 };
100
101 write_graph(writer, &graph, &args.graph_format)
102 } else {
103 let graph: GeometryGraph<petgraph::Undirected> = read_tgf_graph(reader);
104 let (polygons, dangles) = polygonize(&graph);
105 let polygons = polygons.into_iter().map(Geometry::Polygon);
106 let dangles = dangles.into_iter().map(Geometry::LineString);
107 let geometries = polygons.chain(dangles);
108
109 let geometries = if args.tolerance.is_some() {
110 snap_geoms(geometries, strategy)
111 } else {
112 Box::new(geometries)
113 };
114
115 write_geometries(writer, geometries)
116 }
117}

Callers

nothing calls this directly

Calls 9

get_input_readerFunction · 0.85
get_output_writerFunction · 0.85
read_geometriesFunction · 0.85
snap_graphFunction · 0.85
write_graphFunction · 0.85
read_tgf_graphFunction · 0.85
snap_geomsFunction · 0.85
write_geometriesFunction · 0.85
polygonizeFunction · 0.50

Tested by

no test coverage detected