()
| 151 | } |
| 152 | |
| 153 | fn main() -> eyre::Result<()> { |
| 154 | color_eyre::install()?; |
| 155 | let args = CmdlineOptions::parse(); |
| 156 | let filter = tracing_subscriber::EnvFilter::builder() |
| 157 | .with_default_directive(args.log_level.into()) |
| 158 | .from_env_lossy(); |
| 159 | tracing_subscriber::fmt() |
| 160 | .with_env_filter(filter) |
| 161 | .with_ansi(true) |
| 162 | .with_writer(std::io::stderr) |
| 163 | .init(); |
| 164 | |
| 165 | let expr_fn = build_expression(&args.expression)?; |
| 166 | |
| 167 | let xs = args.x_min..args.x_max; |
| 168 | let ys = args.y_min..args.y_max; |
| 169 | let cross = xs.cartesian_product(ys); |
| 170 | |
| 171 | let mut writer = get_output_writer(&args.output)?; |
| 172 | if args.points { |
| 173 | let geometries = cross.filter_map(|(x, y)| { |
| 174 | let value = expr_fn(x, y); |
| 175 | if value > 0 { |
| 176 | return Some(Geometry::Point(Point::new(x as f64, y as f64))); |
| 177 | } |
| 178 | None |
| 179 | }); |
| 180 | |
| 181 | write_geometries(writer, geometries)?; |
| 182 | } else { |
| 183 | tracing::info!( |
| 184 | "Searching neighbors in order: {:?}", |
| 185 | args.neighbor_search_order |
| 186 | ); |
| 187 | for (x, y) in cross { |
| 188 | if expr_fn(x, y) > 0 { |
| 189 | let mut wrote_line = false; |
| 190 | for n in args.neighbor_search_order.iter() { |
| 191 | let (x2, y2) = neighbor(x, y, *n); |
| 192 | if expr_fn(x2, y2) > 0 { |
| 193 | write_line(&mut writer, x, y, x2, y2)?; |
| 194 | wrote_line = true; |
| 195 | break; |
| 196 | } |
| 197 | } |
| 198 | if !wrote_line { |
| 199 | write_point(&mut writer, x, y)?; |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | Ok(()) |
| 206 | } |
nothing calls this directly
no test coverage detected