-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop flatgeobuf dependency in geozero crate #235
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
use flatgeobuf::{FgbReader, Header}; | ||
use geozero::geojson::GeoJsonReader; | ||
use geozero::svg::SvgWriter; | ||
use geozero::ProcessToSvg; | ||
use seek_bufread::BufReader; | ||
use std::fs::File; | ||
use std::io::Write; | ||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | ||
|
||
#[test] | ||
|
@@ -23,6 +19,16 @@ fn json_to_svg() -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
/* | ||
// FlatgeoBuf to SVG conversion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to keep this, can you leave a comment for us-in-the-future explaining why it's here but commented out? |
||
// Disabled, since we don't want to have a circular dependency between flatgeobuf and geozero | ||
|
||
|
||
use flatgeobuf::{FgbReader, Header}; | ||
use geozero::svg::SvgWriter; | ||
use seek_bufread::BufReader; | ||
use std::io::Write; | ||
|
||
fn invert_y(header: &Header) -> bool { | ||
if let Some(crs) = header.crs() { | ||
if crs.code() == 4326 { | ||
|
@@ -69,3 +75,4 @@ fn fgb_to_svg() -> Result<()> { | |
|
||
Ok(()) | ||
} | ||
*/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you've removed this example because it uses FGB. We could convert it to use geojson, but I'm guessing you've judged it to be not worth the upkeep?
That seems fine, just making sure I understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. This example should go either into the flatgeobuf or the polylabel crate. I tried to use geojson, but I had the same problem with the missing feature iterator.