Coder Social home page Coder Social logo

Comments (8)

amandasaurus avatar amandasaurus commented on June 3, 2024 2

My motivation for this was when working with the MVT vector tile format for OpenStreetMap. In that file format, vector geometry is stored as integers.


the intersection of two integral line segments

Yes I had those problems. For my use case I just choose some point that's "good enough". the Intersection algoritm is probably one where you Floats are required.


I do think a rasterize operation onto a given grid at the end is the way to go -- that way the user could provide whatever grid they wanted.

You can do this with the MapCoords trait, which allows you to change the types. You could convert f64 to i32 etc. (That's one of the reasons I wrote it like this.


We should definitely explain what's going on in the docs, point out caveats etc. when this turns into a PR, though.

Agreed. I didn't do the "grunt work" in the fork because I wasn't sure if the idea was acceptable and likely to be merged. Now that I see the support, I'll work on cleaning it up and making a real PR.

from geo.

amandasaurus avatar amandasaurus commented on June 3, 2024 1

I have worked on this a little more, and reworked it against current master. The new branch is https://github.com/rory/rust-geo/tree/any-num-coordinates

Any feedback? Is this something that rust-geo should have?

from geo.

mbattifarano avatar mbattifarano commented on June 3, 2024

Would you mind pushing the branch? I'm curious to take a look. I don't think I understand how this would work since many operations on integral geometries won't always return integral geometries.

For example, the intersection of two integral line segments: l1 = (0, 0), (2, 1) and l2 = (0, 1), (1, 0) is (2/3, 1/3). Walking through the algorithm with ints (and integer division) you'd get (0,0) (or one of the other endpoints depending on the implementation).

At first glance, I do think a rasterize operation onto a given grid at the end is the way to go -- that way the user could provide whatever grid they wanted.

from geo.

amandasaurus avatar amandasaurus commented on June 3, 2024

There's a branch here: https://github.com/rory/rust-geo/tree/any-num

This commit is how I implemented it. I created CoordinateType to replace the Float. Then it's almost just a find and replace to use that instead.

Some operations (like line intersection or area) might not make sense, and still require the Float trait.

from geo.

jdroenner avatar jdroenner commented on June 3, 2024

I like it. Operations can still limit the generic type to Float if they require it.

from geo.

frewsxcv avatar frewsxcv commented on June 3, 2024

yep, looks good to me too 👍

from geo.

urschrei avatar urschrei commented on June 3, 2024

I don't do much raster stuff atm so I'm not really qualified, but it definitely seems like a good idea. We should definitely explain what's going on in the docs, point out caveats etc. when this turns into a PR, though.

from geo.

amandasaurus avatar amandasaurus commented on June 3, 2024

PR #187 fixes this, so I'll close the issue. Discussion should take place on the PR

from geo.

Related Issues (20)

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.