Closed JiZhenfei1211 closed 3 years ago
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.
@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?
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.
@lokkju Get it. Appreciate for your help!
I'd suggest #5: use denormalize, to get the cells at the particular cell level you want.
(Feel free to reopen if that doesn't work well for you)
Dear list,
I want to implement a function which could get all cellids within a circle of specific radius. it looks like:
but when I print the cellidlist on the map, it obviously loses some cells. The following image is the result when I want to get all cellids within a circle of 5km radius, as you can see there are some cells lost around the central of the circle. (please ignore the color of the small dots)
Is there any problems in my code or is it a bug?
Thanks a lot!