Skip to content

Commit

Permalink
update geodatafusion examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Dec 19, 2024
1 parent 9495893 commit 23814c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 12 additions & 3 deletions rust/geodatafusion/src/udf/native/measurement/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,24 @@ mod test {
use geoarrow::algorithm::native::Cast;
use geoarrow::array::CoordType;
use geoarrow::datatypes::NativeType;
use geoarrow::io::flatgeobuf::read_flatgeobuf;
use geoarrow::io::flatgeobuf::{FlatGeobufReaderBuilder, FlatGeobufReaderOptions};
use geoarrow::table::Table;
use std::fs::File;
use std::sync::Arc;

use super::*;

fn load_file() -> RecordBatch {
let mut file = File::open("../../fixtures/flatgeobuf/countries.fgb").unwrap();
let table = read_flatgeobuf(&mut file, Default::default()).unwrap();
let file = File::open("../../fixtures/flatgeobuf/countries.fgb").unwrap();
let reader_builder = FlatGeobufReaderBuilder::open(file).unwrap();
let options = FlatGeobufReaderOptions {
coord_type: CoordType::Separated,
..Default::default()
};
let reader = reader_builder.read(options).unwrap();
let table =
Table::try_from(Box::new(reader) as Box<dyn arrow_array::RecordBatchReader>).unwrap();

let geometry = table.geometry_column(None).unwrap();
let geometry = geometry
.as_ref()
Expand Down
15 changes: 12 additions & 3 deletions rust/geodatafusion/src/udf/native/processing/centroid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,24 @@ mod test {
use geoarrow::algorithm::native::Cast;
use geoarrow::array::CoordType;
use geoarrow::datatypes::NativeType;
use geoarrow::io::flatgeobuf::read_flatgeobuf;
use geoarrow::io::flatgeobuf::{FlatGeobufReaderBuilder, FlatGeobufReaderOptions};
use geoarrow::table::Table;
use std::fs::File;
use std::sync::Arc;

use super::*;

fn load_file() -> RecordBatch {
let mut file = File::open("../../fixtures/flatgeobuf/countries.fgb").unwrap();
let table = read_flatgeobuf(&mut file, Default::default()).unwrap();
let file = File::open("../../fixtures/flatgeobuf/countries.fgb").unwrap();
let reader_builder = FlatGeobufReaderBuilder::open(file).unwrap();
let options = FlatGeobufReaderOptions {
coord_type: CoordType::Separated,
..Default::default()
};
let reader = reader_builder.read(options).unwrap();
let table =
Table::try_from(Box::new(reader) as Box<dyn arrow_array::RecordBatchReader>).unwrap();

let geometry = table.geometry_column(None).unwrap();
let geometry = geometry
.as_ref()
Expand Down

0 comments on commit 23814c9

Please sign in to comment.