georust / geozero

Zero-Copy reading and writing of geospatial data.
Apache License 2.0
336 stars 33 forks source link

wip: proj transform #22

Open michaelkirk opened 2 years ago

michaelkirk commented 2 years ago

This is a demo of an API I'd like to be able to use with geozero to do more kinds of processing with the library.

Currently, it seems like processing is usually limited to "input -> output", which works great for converting formats and for some kinds of processing:

let wkt = WktStr("POINT (4760096.421921 3744293.729449)");
wkt
  .to_json()
  .unwrap()

But often I want to do some kind of pipeline of operations. One such example here:

  1. read geometry from some input format
  2. project the geometries
  3. write to some output format (maybe the same as input)
let from = "EPSG:2230";
let to = "EPSG:26946";
let proj = Proj::new_known_crs(from, to, None).unwrap();

let wkt = WktStr("POINT (4760096.421921 3744293.729449)");
wkt
  .to_projected(proj)
  .to_json()
  .unwrap());

I personally think the user facing API is pretty good - but implementing it has some problems that I'll highlight below.

pka commented 2 years ago

I'm currently experimenting with a new event based API, which should support chaining of processors. Other advantages of an event stream would be serializing and buffering.

michaelkirk commented 2 years ago

Excited to see what you come up with!