GithubHelp home page GithubHelp logo

geoarrow / geoarrow-rs Goto Github PK

View Code? Open in Web Editor NEW
224.0 6.0 13.0 7.57 MB

GeoArrow in Rust, Python, and JavaScript (WebAssembly) with vectorized geometry operations

Home Page: http://geoarrow.org/geoarrow-rs/

License: Apache License 2.0

Rust 96.22% TypeScript 0.12% Shell 0.14% Python 3.49% CSS 0.02%
geospatial rust wasm-bindgen webassembly apache-arrow javascript typescript geoarrow pyo3 python

geoarrow-rs's Introduction

geoarrow-rs

A Rust implementation of the GeoArrow specification and bindings to GeoRust algorithms for efficient spatial operations on GeoArrow memory.

This repository also includes Python bindings and JavaScript (WebAssembly) bindings, wrapping the GeoArrow memory layout and offering vectorized geometry operations.

Documentation

Examples

Install

Add this to your Cargo.toml:

geoarrow = "0.1"

References

geoarrow-rs's People

Contributors

gadomski avatar h-plus-time avatar kylebarron avatar lewiszlw avatar robinlovelace avatar weiji14 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

geoarrow-rs's Issues

check slicing

check that slicing is accurate. we should not be slicing the underlying arrays? when should we be slicing arrays vs slicing offsets?

JS: How to handle geometry overloading

E.g. for contains, I want to support contains between each geometry type to each other geometry type. In Rust, I can do that via traits, and so contains() will work on each combination of types automatically. But in JS it doesn't have overloading, so I need to do something like adding a GeometryArray class that can be any geometry type?

RectArray follow ups

  • Add docstring. Be explicit that this is not included in the geoarrow specification.
  • Add impl From<RectArray> for PolygonArray

Documentation on how to use `geoarrow-wasm` from a standalone rust crate

I.e. it should be possible for me to publish geoarrow-wasm to crates.io and give an example of using that with a custom operation.

pub use geoarrow_wasm::*;
  • Use no-default-features on the geoarrow_wasm dependency... only bring in the core geoarrow data structures and bindings, without geo algorithms.
  • Example of some custom operation on the data arrays

JS: Mutations of an affine transform

I.e. we should let people do

const transform = AffineTransform.identity().scale(1).skew(2); // etc

Then let people pass that into array.affine_transform().

Ideally these affine mutations should be vectorized as well.

Probably these should be by value rather than by reference so that you don't leak memory? And then that also allows you to mutate the array of affine transforms in place.

Wrap `TriangulateEarcut` trait.

Earcut functionality would be useful to support.

  • Does a TriangleArray make sense? It wouldn't be exactly aligned with (today's) formal geoarrow types, but it would be really high performance. A TriangleArray could naively be defined as a FixedSizeList[3]. We could have a to_polygon_array method on the TriangleArray struct, which should be high performance because we know the size of the output coordinate array and output offsets array at the start.
  • earcut_triangles_raw is quite useful because the triangle indices are already in a flat array.
    • Is the order of vertices in the result guaranteed to be the same as the original vertices? They are in the example but you should look/ask to see whether this is always the case. If it is, then you can reuse the input coordinate array and just shift the indices of the output indices as needed to make it accurate in the full array.

Implement correct array/scalar equality

Right now I'm adding a derived PartialEq, which just checks that the constituent parts are the same, but we need to check that the equality on sliced arrays works as expected. If it just checks equality on the underlying buffers, then array equality will not be true whenever comparing a sliced array to a non-sliced array.

Fix skipped tests

Several tests have

#[ignore = "This is failing on coordinate access"]

What is the correct implementation of an invalid point?

I.e. is a point with coordinates NaN, NaN and the validity bitmask set to true allowed? I.e. a point that exists but is unknown? This is subtly different than the bitmask set to false, which says the point is missing. WKT allows Point Empty I believe

This is probably something to ask on the geoarrow spec repo.

Validate broadcasting

add a function to validate that the broadcasted array has the same length as the other array it's being zipped onto

geoarrow-wasm feature flags?

How many JS feature flags should there be?

Ideally it should be possible to take out most features to make geoarrow-wasm have a really really tiny bundle size. But that comes at a cost of build complexity.

Generic over i32/i64 offsets

This would make it easier to use arrow js ffi in the browser where presumably we'll never have a need for i64 offsets

Tests with empty geometries

The format specifies that empty geometries (which are not the same as missing!) have an empty inner array.

We need to make sure that this works with the layout I have, and we should also make sure that is_empty is accurate for this!

Also an empty point is defined with NaN values, so we should validate that (and write a custom PartialEq probably)

JS: how to handle scalars?

E.g. in algorithms like contains and euclidean_distance where you want to broadcast against a single scalar

Explore type-preserving operations

Right now we have operations like

pub fn area(array: GeometryArray) -> Result<PrimitiveArray<f64>> {}

We then need a verbose match on the array type. But when the area function is implemented on every geometry type, there should be some way to do

pub fn area<'a, T: GeometryArrayTrait<'a>>(array: T) -> Result<PrimitiveArray<f64>> {}

Then we wouldn't need a match statement with a lot of copying between match arms. The downsides there are:

  • returning iterators from traits is not yet stable I think?
  • We'd have to have to return a geo::Geometry I think, not a different geometry type per trait implementation? Or always have to convert the local geometry type into geo::Geometry?

Optimize affine transformations

Right now I'm implementing the simplest way, which is to go through geo objects, but I think it should be possible to get some speedups by using arrow arrays as much as possible. for example, Scale::scale() just takes the center of every geometry and then applies affine_transform. It might be more efficient if we first do center(geometry_array) and then pass that to affine_transform directly.

Especially if/once we implement COW apis for affine transforms

Owned scalar types

I.e. a Point that isn't a reference onto another array.

This could even be implemented as

pub struct OwnedPoint(PointArray)

where the invariant is that the underlying array only has one item

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.