Stuck with GeoZero/Flatgeobuf: trait not satifsied when calling a method

I've added flatgeobuf to my project, and iterating over features and reading geometries worked fine. But now I try to read a field, called "x" (it's the X coordinate of the tile the object is in), and it's giving me an error.

// [dependencies]
// geozero = "0.9"
// flatgeobuf = "3.24.0"

// #2 and #3 are traits that are required to be in scope
use flatgeobuf::{FgbReader, FallibleStreamingIterator, FeatureProperties};
use std::{
	error::Error,
	fs::File,
	io::BufReader,
};


fn read_sources() -> Result<(), Box<dyn Error>> {
	let sources_path = "sources.fgb";
	let mut file = BufReader::new(File::open(sources_path)?);
	let mut sources = FgbReader::open(&mut file)?.select_all()?;

	while let Some(item) = sources.next()? {
		let g = item.geometry().unwrap().xy().unwrap();
		let x = item.property("x")?;
		let y = item.property("y")?;
		//println!("{} {} {:?}", x, y, g);  // won't work anyway
		break;
	}

	Ok(())
}

This fails to compile at item.property(...):

error[E0277]: the trait bound `(): geozero::property_processor::PropertyReadType` is not satisfied
   --> src/main.rs:127:16
    |
127 |         let x = item.property("x")?;
    |                      ^^^^^^^^ the trait `geozero::property_processor::PropertyReadType` is not implemented for `()`
    |
note: required by a bound in `property`
   --> /home/culebron/.cargo/registry/src/github.com-1ecc6299db9ec823/geozero-0.9.5/src/api.rs:67:20
    |
67  |     fn property<T: PropertyReadType>(&self, name: &str) -> Result<T> {
    |                    ^^^^^^^^^^^^^^^^ required by this bound in `property`

I tried importing these traits, but it made no difference.

Is this fatal? (like I can't use the crate because it won't compile anyway?)

P.S.: I saw that versions in flatgeobuf are weird: 0.7, 0.8, then immediately 3.24.0. So I switched version to 0.8.0, but the error was exactly the same.

Found the trick here: you must tell it the type of the field.

let x = item.property::<i64>("x")?;
let y = item.property::<i64>("y")?;

Read the error messages carefully they said...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.