Closed Oreilles closed 11 months ago
TBH, I am not too happy about changing all of the APIs to force the user to always be WKT dialect aware. I would much rather keep the existing API, plus perhaps add a new constructor, e.g. keep the WktWriter::new(w: impl Write)
, and add another one like WktWriter::with_dialect(w: impl Write, dialect: WktDialect)
?
Sure, I changed the signature of the constructor for the sake of consistency with WkbWriter
but I would definetly understand that an API change would not be acceptable.
oh, i didn't realize we already did it that way with WkbWriter... I'm a bit on a fence on this one then - ideally I would want Wkb to also be done the same way - WkbWriter::with_dialect(...)
, but I will let @pka to chime in on this one
Thanks for the review, I ran fmt
and took example on the linked PR to remove the WktReader
lifetime 👍
@Oreilles thx! Do you need help merging main branch into your PRs?
I just rebased onto main
and solved the few conflicts.
After discussing the PR with @nyurik, I'm also for keeping the WktWriter::new
signature and adding a second method WktWriter::with_dialect
. For WkbWriter
the dialect is essential, but WKT users usually don't care and I don't want to force them to think about it. What's your use case of using EWKT
? Can't remember anyone mentioning it for a long time.
After discussing the PR with @nyurik, I'm also for keeping the WktWriter::new signature and adding a second method WktWriter::with_dialect. For WkbWriter the dialect is essential, but WKT users usually don't care and I don't want to force them to think about it.
That's understandable, I'll do the modification 👍
What's your use case of using EWKT ?
Even though it's not a standard, thanks to PostGIS success it's still quite common and (AFAIAA) is the only human-friendly geometry format that allows SRID declaration. It will be used as a user input format in a product I'm working on.
I made a few more suggestions for this PR in https://github.com/Oreilles/geozero/pull/2
to_wkt_dialect
-> to_wkt_with_opts
WktWriter
content private! It's ridiculous to have write access to a writer from outsideWktWriter::with_dims
to allow creation of a writer with the needed params
This PR adds:
enum WktDialect
with optionsWktDialect::Wkt
andWktDialect::Ewkt
towkt
modulestruct EwktString(pub String)
fn to_ewkt(&self, srid: Option<i32>) -> Result<String>
to traitToWkt
fn to_wkt_dialect(&self, dialect: WktDialect, dims: CoordDimensions, srid: Option<i32>) -> Result<String>
to traitToWkt
The trait
FromWkb
is implemented forEwktString
so that the srid is inferred from the Wkb stream if available. The later is made possible by implementingGeomProcessor::srid
forWktWriter
and callingprocessor.srid(info.srid)
inprocess_wkb_geom
.Side notes:
wkt
crate.ProcessToCsv::to_csv_ewkt
and/orProcessToCsv::to_csv_dialect
?