s2-geometry-library-csharp
s2-geometry-library-csharp copied to clipboard
Getting S2 Cell ID for specific position and level
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?
I too am wanting to achieve this.
@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);