Git Product home page Git Product logo

Comments (4)

dsymonds avatar dsymonds commented on May 26, 2024

One could argue that the boundary of a region is not completely contained by that region (per the ContainsCell docs on the Region interface), so the behaviour of that method on s2.Loop and s2.Polygon is reasonable. I can see how the reflexive predicate is a special case here.

I just eyeballed the Go code in parallel with the C++ code, and they look equivalent, so I might guess that the C++ code has the same behaviour. If that's the case (care to check?), then we won't change Go unless C++ changes first (consider Go to be a downstream port of the C++).

@jmr might have thoughts.

from geo.

jmr avatar jmr commented on May 26, 2024

The same thing happens in C++, at least for the cell id I picked.

I think the comment on the C++ S2Loop(S2Cell) constructor explains what's going on for the loop and polygon.

  // Construct a loop corresponding to the given cell.
  //
  // Note that the loop and cell *do not* contain exactly the same set of
  // points, because S2Loop and S2Cell have slightly different definitions of
  // point containment.  For example, an S2Cell vertex is contained by all
  // four neighboring S2Cells, but it is contained by exactly one of four
  // S2Loops constructed from those cells.  As another example, the S2Cell
  // coverings of "cell" and "S2Loop(cell)" will be different, because the
  // loop contains points on its boundary that actually belong to other cells
  // (i.e., the covering will include a layer of neighboring cells).
  explicit S2Loop(const S2Cell& cell);

The class level loop comments explain why.

// Point containment of loops is defined such that if the sphere is subdivided
// into faces (loops), every point is contained by exactly one face.  This
// implies that loops do not necessarily contain their vertices.
//
// Note: The reason that duplicate vertices and intersecting edges are not
// allowed is that they make it harder to define and implement loop
// relationships, e.g. whether one loop contains another.  If your data does
// not satisfy these restrictions, you can use S2Builder to normalize it.

What documentation of Region says the calls should all return the same result?

@ericveach may have more to add.

from geo.

ericveach avatar ericveach commented on May 26, 2024

Jesse's explanation is correct. And yes, there is no requirement that the Region::ContainsCell() should return the same result for "cell" and S2.LoopFromCell(cell), because those two regions are not the same.

from geo.

dsymonds avatar dsymonds commented on May 26, 2024

Thanks guys. It sounds like this is working as intended, just slightly non-obvious.

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.