# All files / components/geo/processing mixins.ts

26.31% Statements 5/19
0% Branches 0/4
0% Functions 0/2
27.77% Lines 5/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    342x
    2x
    2x

    2x

    2x

     import {S2} from 's2-geometry'
    import {HEX_DIGIT_NUM} from '../../../utils/geo'
    import {CoordinateEncoding} from './GeoTable'
    import {Coordinates} from './GeoTable'
    export const getLatLonMixin = function(index: number): Coordinates {
      Iif (this.coordinateEncoding === CoordinateEncoding.FIELDS) {
        return {
          lon: this.getValue(index, this.latLonColumns.lon.column),
          lat: this.getValue(index, this.latLonColumns.lat.column),
        }
      }
      const cellId = this.getS2CellID(index)
      Iif (cellId === null || cellId.length > HEX_DIGIT_NUM) {
        return null
      }
      const precisionTrimmingTable = [BigInt(1)]
      precisionTrimming(precisionTrimmingTable)
      const fixed =
        BigInt('0x' + cellId) *
        precisionTrimmingTable[HEX_DIGIT_NUM - cellId.length]
      const latLng = S2.idToLatLng(fixed.toString())
      return {
        lon: latLng.lng,
        lat: latLng.lat,
      }
    }

    const precisionTrimming = precisionTrimmingTable => {
      for (let i = 1; i < 17; i++) {
        precisionTrimmingTable[i] = precisionTrimmingTable[i - 1] * BigInt(16)
      }
      return precisionTrimmingTable
    }