-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop flatgeobuf dependency in geozero crate (#235)
Solves flatgeobuf/flatgeobuf#283
- Loading branch information
Showing
7 changed files
with
56 additions
and
125 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,38 +1,17 @@ | ||
use flatgeobuf::{FgbReader, HttpFgbReader}; | ||
use geozero::geojson::GeoJsonWriter; | ||
use geozero::ProcessToJson; | ||
use seek_bufread::BufReader; | ||
use std::fs::File; | ||
use std::io::BufWriter; | ||
use geozero::{wkt::Wkt, ToJson}; | ||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | ||
|
||
#[test] | ||
fn fgb_to_geojson() -> Result<()> { | ||
let mut filein = BufReader::new(File::open("tests/data/countries.fgb")?); | ||
let mut fgb = FgbReader::open(&mut filein)?.select_bbox(8.8, 47.2, 9.5, 55.3)?; | ||
let json = fgb.to_json()?; | ||
fn wkt_to_geojson_feature() -> Result<()> { | ||
let wkt = Wkt("MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), | ||
((35 10, 45 45, 15 40, 10 20, 35 10), | ||
(20 30, 35 35, 30 20, 20 30)))"); | ||
let json = wkt.to_json()?; | ||
|
||
println!("{json}"); | ||
assert_eq!( | ||
&json[0..215], | ||
r#"{ | ||
"type": "FeatureCollection", | ||
"name": "countries", | ||
"features": [{"type": "Feature", "properties": {"id": "DNK", "name": "Denmark"}, "geometry": {"type": "MultiPolygon", "coordinates": [[[[12.690006,55.609991],[12.0"# | ||
&json, | ||
r#"{"type": "MultiPolygon", "coordinates": [[[[40,40],[20,45],[45,30],[40,40]]],[[[35,10],[45,45],[15,40],[10,20],[35,10]],[[20,30],[35,35],[30,20],[20,30]]]]}"# | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[allow(dead_code)] | ||
// #[tokio::test] | ||
async fn http_fbg_to_json() -> Result<()> { | ||
let url = "https://flatgeobuf.org/test/data/countries.fgb"; | ||
let mut fgb = HttpFgbReader::open(url) | ||
.await? | ||
.select_bbox(8.8, 47.2, 9.5, 55.3) | ||
.await?; | ||
|
||
let mut fout = BufWriter::new(File::create("countries.json")?); | ||
let mut json = GeoJsonWriter::new(&mut fout); | ||
fgb.process_features(&mut json).await?; | ||
|
||
Ok(()) | ||
} |
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 was deleted.
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