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

[FEAT] Add simple-features geometry type and initial operations #3061

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

amitschang
Copy link
Contributor

After discussion with @desmondcheongzx in #3017, I thought it might be worthwhile to open a PR for this work I've done making a (e)wkb backed geometry type representing "simple-features" geometries. Basically it implements a logical Geometry type whose physical backing is the validated (e)wkb bytes. This method incurs cost in serde upon operations, but enables earlier and potentially wider support for geo operations (due to existing library support) and supports collections and non-uniform geometries - so should have use before and even after native types would be added.

Here are included encoding/decoding (wkt/wkb) and a number of operations within the "geo" expression namespace to demonstrate combinations of unary/binary to bool/float/geometry, but is not meant to be in any way complete.

There are more examples in the discussion linked above, but very briefly what it looks like:

d = daft.from_pydict({'p1': ['POINT(0 0)', 'POINT(1 1)', 'POINT(0 1)'], 'p2': ['POINT(0 0)']*3})
d = d.with_column('p1g', d['p1'].geo.decode()).with_column('p2g', d['p2'].geo.decode())
d.select('p1', 'p2', d['p1g'].geo.distance(d['p2g']).alias('dist'), 'p1g').sort('dist').collect()
╭────────────┬────────────┬────────────────────┬────────────╮                                                                                 
│ p1p2distp1g        │                                                                                 
│ ------------        │                                                                                 
│ Utf8Utf8Float64Geometry   │                                                                                 
╞════════════╪════════════╪════════════════════╪════════════╡                                                                                 
│ POINT(0 0) ┆ POINT(0 0) ┆ 0<Geometry> │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ POINT(0 1) ┆ POINT(0 0) ┆ 1<Geometry> │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ POINT(1 1) ┆ POINT(0 0) ┆ 1.4142135623730951<Geometry> │
╰────────────┴────────────┴────────────────────┴────────────╯

There are probably a number of missing/wrong things in here, and some organizational improvements that could be made (daft-geo crate?), and docs - but may be a start 😄

@github-actions github-actions bot added the enhancement New feature or request label Oct 16, 2024
Copy link

codspeed-hq bot commented Oct 16, 2024

CodSpeed Performance Report

Merging #3061 will not alter performance

Comparing amitschang:geotype (3b7a1ec) with main (1aaf3cf)

Summary

✅ 17 untouched benchmarks

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

Successfully merging this pull request may close these issues.

1 participant