Giter VIP home page Giter VIP logo

Comments (8)

urschrei avatar urschrei commented on May 22, 2024 1

I agree about optional validity. I really like the idea of validity checks being easily chainable, so you could e.g. carry out a series of "cheap" geo operations, only checking validity before a potentially expensive one, and bailing out with an Err if need be.
Also, if I understand the current state of this part of Rust's type system correctly, it's not possible to conveniently express validity using trait bounds, but that doesn't need to hold us back ā€“ a subset of operations that are guaranteed to produce valid geometries (logic errors and floating-point issues notwithstanding) is something worth exploring IMHO, but we've got plenty of more fundamental stuff to do.

from geo.

frewsxcv avatar frewsxcv commented on May 22, 2024

Relevant: #56

from geo.

amandasaurus avatar amandasaurus commented on May 22, 2024

Something I'm working on appears to require valid geometries, so I'm interested in this. I'd be half tempted to implement what I want as a starting point sometime.

from geo.

frewsxcv avatar frewsxcv commented on May 22, 2024

i have a WIP PR for ensuring valid linestrings: https://github.com/georust/rust-geo/pull/155/files?w=1 if you have any feedback, let me know

from geo.

amandasaurus avatar amandasaurus commented on May 22, 2024

Looks like it solves one case, but there are many ways for a linestring to be invalid, and I hit an odd one (a linestring of 2 identical points!).

However that link from PostGIS splits things 2 ways. Simple, and Valid. In it, there are no invalid linestrings (so long as there's >=2 points). So maybe It's worth adding simplicity check? Or call do a simple & valid check but call that "validity" (my preferred option)?

from geo.

frewsxcv avatar frewsxcv commented on May 22, 2024

for what it's worth, i'm in favor of making validity opt-out. if i have a LineString instance, i'd rather not have to check everytime i work with it if it's valid or not. if we can guarantee validity with low overhead (see my branch), i don't see the downside (besides being a little less ergonomic)

yeah, i knew about the 'no duplicate points' simplicity rule for linestrings, but wasn't sure the best way to address it. logically, it's a pretty straightforward check, but i'm not sure how best to implement it since it could affect performance. for example, if we kept a Vec for LineString, concatenating two large LineStrings could be pretty expensive since we'd have to check the intersection of two Vecs. another option is to use a BTreeSet (an ordered set) which would allow us to use set operations, but i haven't thought too hard about it.

from geo.

amandasaurus avatar amandasaurus commented on May 22, 2024

I also haven't thought about it too much. I think validity should be opt-out too. Sometimes you don't care, or more importantly, you can assume (or know) that the thing is valid, in which case there shouldn't be a performance hit.

from geo.

frewsxcv avatar frewsxcv commented on May 22, 2024

Just opened a new pull request adding a LineString validity constructor: #168

If any of you have some time, would love to get some šŸ‘€ and opinions

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.