Git Product home page Git Product logo

Comments (6)

lokkju avatar lokkju commented on May 3, 2024

You might display the bounds of each cellId, instead of it's center point. I think you'll see that there are various cell sizes (levels). You can avoid this feature - if you want to - by specifying the min/max cell levels that the S2RegionCoverer is allowed to return.

from s2-geometry-library-java.

JiZhenfei1211 avatar JiZhenfei1211 commented on May 3, 2024

@lokkju Thanks for reply!
I do want to keep one same level within the circle area and have set the min/max levels to be same, but it seems that it will still automatically replace four child cells with their parent as annotated by author for getCovering().

/**

  • Return a normalized cell union that covers the given region and satisfies
  • the restrictions EXCEPT for min_level() and level_mod(). These criteria
  • cannot be satisfied using a cell union because cell unions are
  • automatically normalized by replacing four child cells with their parent
  • whenever possible. (Note that the list of cell ids passed to the cell union
  • constructor does in fact satisfy all the given restrictions.)
    */
    public S2CellUnion getCovering(S2Region region) {
    S2CellUnion covering = new S2CellUnion();
    getCovering(region, covering);
    return covering;
    }

Is there any alternatives to avoid this feature?

from s2-geometry-library-java.

lokkju avatar lokkju commented on May 3, 2024

you might try:

  1. getSimpleCovering
  2. loop through the S2CellUnion and emit children elements for any parent element above your desired level
  3. use reflection to call getCoveringInternal and get the raw S2CellIds
  4. a custom S2CellUnion that doesn't normalize the results (this code isn't at all tested, just gives you an idea):
public strictfp class S2CellUnionDenormalized extends S2CellUnion {
  public void initSwap(ArrayList<S2CellId> cellIds) {
    initRawSwap(cellIds);
    // skip normalization
    // normalize();
  }
}
S2CellUnionDenormalized s2cud = new S2CellUnionDenormalized();
regionCoverer.getCovering(region, s2cud)

I'd probably suggest (1) or (2) as the best options.

from s2-geometry-library-java.

JiZhenfei1211 avatar JiZhenfei1211 commented on May 3, 2024

@lokkju Get it. Appreciate for your help!

from s2-geometry-library-java.

eengle avatar eengle commented on May 3, 2024

I'd suggest #5: use denormalize, to get the cells at the particular cell level you want.

from s2-geometry-library-java.

eengle avatar eengle commented on May 3, 2024

(Feel free to reopen if that doesn't work well for you)

from s2-geometry-library-java.

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.