Skip to content
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

feature: convert GeozeroDatasource to geo package #38

Open
michaelkirk opened this issue May 26, 2022 · 1 comment
Open

feature: convert GeozeroDatasource to geo package #38

michaelkirk opened this issue May 26, 2022 · 1 comment

Comments

@michaelkirk
Copy link
Member

I see there is some support for encoding/decoding geometry with geo-package: https://github.com/georust/geozero/blob/master/geozero/src/gpkg/geopackage.rs

How about a one-shot conversion of a GeozeroDatasource to convert geometry and feature data to geo package format?

let mut filein = BufReader::new(File::open("countries.fgb")?);
let mut fgb = FgbReader::open(&mut filein)?.select_all()?;
fgb.write_gpkg("contries.gpkg").unwrap();
@pka
Copy link
Member

pka commented Sep 6, 2022

Would definitely be nice to have. It requires more than WKB encoding, which is already available. You have to issue SQL statements for creating tables and inserting properties together with the geometry. And the code should be similar for PostGIS output.

Example for property+geometry insertion:

// Insert geometry
let geom: geo_types::Geometry<f64> = geo::Point::new(10.0, 20.0).into();
let inserted = sqlx::query(
"INSERT INTO point2d (datetimefield, geom) VALUES(now(), ST_SetSRID($1,4326))",
)
.bind(wkb::Encode(geom))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants