Skip to content

Commit

Permalink
Don't pass around enum references
Browse files Browse the repository at this point in the history
  • Loading branch information
Notgnoshi committed May 26, 2024
1 parent 159dcce commit 6af8663
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions generative/io/wkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use log::warn;
use wkb::{geom_to_wkb, wkb_to_geom, write_geom_to_wkb};
use wkt::{ToWkt, Wkt};

#[derive(Debug, Clone, ValueEnum)]
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum GeometryFormat {
/// One WKT geometry per line. Ignores trailing garbage; does not skip over leading garbage.
Wkt,
Expand Down Expand Up @@ -168,7 +168,7 @@ where
}
}

pub fn write_geometries<W, G>(writer: W, geometries: G, format: &GeometryFormat)
pub fn write_geometries<W, G>(writer: W, geometries: G, format: GeometryFormat)
where
W: Write,
G: IntoIterator<Item = Geometry<f64>>,
Expand Down
10 changes: 5 additions & 5 deletions tools/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn expression(engine: &Engine, ast: &AST, x: i64, y: i64) -> Result<i64, Box<Eva
engine.eval_ast_with_scope::<i64>(&mut scope, ast)
}

fn write_line<W>(writer: W, format: &GeometryFormat, x1: i64, y1: i64, x2: i64, y2: i64)
fn write_line<W>(writer: W, format: GeometryFormat, x1: i64, y1: i64, x2: i64, y2: i64)
where
W: Write,
{
Expand All @@ -79,7 +79,7 @@ where
write_geometries(writer, geometries, format);
}

fn write_point<W>(writer: W, format: &GeometryFormat, x1: i64, y1: i64)
fn write_point<W>(writer: W, format: GeometryFormat, x1: i64, y1: i64)
where
W: Write,
{
Expand Down Expand Up @@ -163,7 +163,7 @@ fn main() -> Result<(), Box<EvalAltResult>> {
None
});

write_geometries(writer, geometries, &args.output_format);
write_geometries(writer, geometries, args.output_format);
} else {
log::info!(
"Searching neighbors in order: {:?}",
Expand All @@ -175,13 +175,13 @@ fn main() -> Result<(), Box<EvalAltResult>> {
for n in args.neighbor_search_order.iter() {
let (x2, y2) = neighbor(x, y, n.clone());
if expression(&engine, &ast, x2, y2)? > 0 {
write_line(&mut writer, &args.output_format, x, y, x2, y2);
write_line(&mut writer, args.output_format, x, y, x2, y2);
wrote_line = true;
break;
}
}
if !wrote_line {
write_point(&mut writer, &args.output_format, x, y);
write_point(&mut writer, args.output_format, x, y);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ fn main() {
let geometries = std::iter::once(geo::Geometry::GeometryCollection(bundle));

let writer = get_output_writer(&args.output).unwrap();
write_geometries(writer, geometries, &args.output_format);
write_geometries(writer, geometries, args.output_format);
}
2 changes: 1 addition & 1 deletion tools/geom2graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ fn main() {
Box::new(geometries)
};

write_geometries(writer, geometries, &args.geometry_format);
write_geometries(writer, geometries, args.geometry_format);
}
}
2 changes: 1 addition & 1 deletion tools/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ fn main() {
GridFormat::Points => write_geometries(
writer,
graph.node_weights().map(|p| Geometry::Point(*p)),
&GeometryFormat::Wkt,
GeometryFormat::Wkt,
),
}
}
2 changes: 1 addition & 1 deletion tools/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ fn main() -> Result<(), String> {
}

let writer = get_output_writer(&args.output).unwrap();
write_geometries(writer, geometries, &args.output_format);
write_geometries(writer, geometries, args.output_format);
Ok(())
}
2 changes: 1 addition & 1 deletion tools/smooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ fn main() {
});

let writer = get_output_writer(&args.output).unwrap();
write_geometries(writer, geometries, &args.output_format);
write_geometries(writer, geometries, args.output_format);
}
2 changes: 1 addition & 1 deletion tools/snap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn main() {
InputFormat::Wkt | InputFormat::WkbHex | InputFormat::WkbRaw => {
let geometries = read_geometries(reader, &args.input_format.clone().into());
let geometries = snap_geoms(geometries, strategy);
write_geometries(writer, geometries, &args.input_format.into());
write_geometries(writer, geometries, args.input_format.into());
}
InputFormat::Tgf => {
let graph: GeometryGraph<Undirected> = read_tgf_graph(reader);
Expand Down
8 changes: 4 additions & 4 deletions tools/streamline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl VectorField {
((y - self.min_y) / self.stride) as usize
}

fn write<W>(&self, writer: &mut W, format: &GeometryFormat)
fn write<W>(&self, writer: &mut W, format: GeometryFormat)
where
W: std::io::Write,
{
Expand Down Expand Up @@ -436,7 +436,7 @@ fn main() -> Result<(), Box<EvalAltResult>> {
for style in args.vector_field_style {
writeln!(&mut writer, "{style}").unwrap();
}
field.write(&mut writer, &args.output_format);
field.write(&mut writer, args.output_format);
}

let geometries = read_geometries(reader, &args.input_format);
Expand All @@ -458,13 +458,13 @@ fn main() -> Result<(), Box<EvalAltResult>> {
for style in args.streamline_style {
writeln!(&mut writer, "{style}").unwrap();
}
write_geometries(&mut writer, streamlines, &args.output_format);
write_geometries(&mut writer, streamlines, args.output_format);
}
if args.draw_geometries {
for style in args.geometry_style {
writeln!(&mut writer, "{style}").unwrap();
}
write_geometries(&mut writer, geometries, &args.output_format);
write_geometries(&mut writer, geometries, args.output_format);
}
Ok(())
}
2 changes: 1 addition & 1 deletion tools/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ fn main() {
// Do some kind of transformation to the geometries here.

let writer = get_output_writer(&args.output).unwrap();
write_geometries(writer, geometries, &args.output_format);
write_geometries(writer, geometries, args.output_format);
}
2 changes: 1 addition & 1 deletion tools/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,5 @@ fn main() {
transformed = Box::new(geoms_coordwise(transformed, from_polar));
}

write_geometries(writer, transformed, &args.output_format);
write_geometries(writer, transformed, args.output_format);
}
4 changes: 2 additions & 2 deletions tools/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ fn main() {
.map(Geometry::LineString);

let mut writer = get_output_writer(&args.output).unwrap();
write_geometries(&mut writer, traversals, &args.output_format);
write_geometries(&mut writer, traversals, args.output_format);

// dump the remaining nodes
if args.untraversed {
write_geometries(
&mut writer,
graph.node_weights().map(|p| Geometry::Point(*p)),
&args.output_format,
args.output_format,
);
}
}

0 comments on commit 6af8663

Please sign in to comment.