-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4536279
commit 164cdd2
Showing
12 changed files
with
1,517 additions
and
181 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use crate::{Error, Result}; | ||
|
||
use geoarrow::table::GeoTable; | ||
use tokio::fs::File; | ||
|
||
use geoarrow::io::parquet::read_geoparquet_async; | ||
use geoarrow::io::parquet::GeoParquetReaderOptions; | ||
|
||
async fn read_geoparquet(file: &str, batch_size: usize) -> Result<GeoTable> { | ||
let file = File::open(file).await.unwrap(); | ||
let options = GeoParquetReaderOptions::new(batch_size, Default::default()); | ||
let geotable = read_geoparquet_async(file, options).await?; | ||
|
||
Ok(geotable) | ||
} | ||
|
||
pub fn process_geotable() -> Result<()> { | ||
let runtime = tokio::runtime::Runtime::new()?; | ||
let geotable = runtime.block_on(read_geoparquet("../../data/saporo.parquet", 1000))?; | ||
let geom_column = geotable.geometry()?; | ||
let geom_type = geom_column.data_type(); | ||
println!("{:?}", geom_type); | ||
let chunks = geom_column.geometry_chunks(); | ||
|
||
// To polygons | ||
// for chunk in chunks { | ||
// let polys = chunk.as_polygon(); | ||
// polys.iter().for_each(|poly| { | ||
// if poly.is_some() { | ||
// let poly = poly.unwrap(); | ||
// let geo_geom = poly.to_geo_geometry(); | ||
// println!("{:?}", geo_geom); | ||
// } | ||
// }); | ||
// } | ||
|
||
Ok(()) | ||
} | ||
|
||
// Write test for reading geoparquet | ||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_read_geoparquet() { | ||
let runtime = tokio::runtime::Runtime::new().unwrap(); | ||
let file_path = "examples/geoparquet/example.parquet"; | ||
let batch_size = 1000; | ||
let result = runtime.block_on(read_geoparquet(file_path, batch_size)).unwrap(); | ||
assert_eq!(result.len(), 5); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod common; | |
mod geo; | ||
pub mod shapefile; | ||
pub mod geojson; | ||
pub mod geoparquet; |
Oops, something went wrong.