modules/geo-layers/src/s2-layer/s2-utils.js
function getLevelFromToken(token) {
  // leaf level token size is 16. Each 2 bit add a level
  const lastHex = token.substr(token.length - 1);
  // a) token = trailing-zero trimmed hex id
  // b) 64 bit hex id - 3 face bit + 60 bits for 30 levels + 1 bit lsb marker
  const level = 2 * (token.length - 1) - ((lastHex & 1) === 0);
  // c) If lsb bit of last hex digit is zero, we have one more level less of
  return level;
}
function getLevelFromToken(token) {
  // leaf level token size is 16. Each 2 bit add a level
  const lastHex = token.substr(token.length - 1);
  // a) token = trailing-zero trimmed hex id
  // b) 64 bit hex id - 3 face bit + 60 bits for 30 levels + 1 bit lsb marker
  const level = 2 * (token.length - 1) - ((lastHex & 1) === 0);
  // c) If lsb bit of last hex digit is zero, we have one more level less of
  return level;
}
function getLevelFromToken ( token ) { // leaf level token size is 16. Each 2 bit add a level const lastHex = token . substr ( token . length - 1 ) ; // a) token = trailing-zero trimmed hex id // b) 64 bit hex id - 3 face bit + 60 bits for 30 levels + 1 bit lsb marker const level = 2 * ( token . length - 1 ) - ( ( lastHex & 1 ) === 0 ) ; // c) If lsb bit of last hex digit is zero, we have one more level less of return level ; }
Given a S2 hex token this function returns cell level
cells level is a number between 1 and 30

S2 cell id is a 64 bit number
S2 token removed all trailing zeros from the 16 bit converted number
Given a S2 hex token this function returns cell level cells level is a number between 1 and 30