Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting S2 Cell ID for specific position and level #8

Open
VampireSilence opened this issue Feb 7, 2020 · 2 comments
Open

Getting S2 Cell ID for specific position and level #8

VampireSilence opened this issue Feb 7, 2020 · 2 comments

Comments

@VampireSilence
Copy link

I am trying to get the level 10 cell ID for central Manchester.

Google says its coordinate is 53.479683, -2.242776. So i tried it like that:
S2LatLng ll = S2LatLng.FromDegrees(53.479683, -2.242776);
But now if i try to get the ID like this:
S2CellId.FromLatLng(ll).Id.ToString();
It returns the wrong cell ID and
S2CellId.FromLatLng(ll).Level
is always level 30 without any chance of choosing it. How can i set the S2 cell level i like and get the right cell ID?

@mahgo
Copy link

mahgo commented Feb 17, 2020

I too am wanting to achieve this.

@mahgo
Copy link

mahgo commented Feb 17, 2020

@VampireSilence Here's how I achieved it:

S2LatLng s2LatLng = S2LatLng.FromDegrees(latitude, longitude); S2Cell s2Cell = new S2Cell(s2LatLng); S2CellId s2CellId = s2Cell.Id; S2CellId s2Cell11Id = s2CellId.ParentForLevel(11);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants