All files / lib/helpers get-spatial-reference.js

84.61% Statements 11/13
78.57% Branches 11/14
100% Functions 1/1
90.9% Lines 10/11

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 211x 1x 1x     7x 6x   6x   6x   6x 6x           1x  
const _ = require('lodash')
const getCollectionCrs = require('./get-collection-crs')
const normalizeSpatialReference = require('./normalize-spatial-reference')
 
function getSpatialReference (geojson, { inputCrs, sourceSR } = {}) {
  if (!inputCrs && !sourceSR && _.isEmpty(geojson)) return
  const spatialReference = inputCrs || sourceSR || getCollectionCrs(geojson) || { wkid: 4326, latestWkid: 4326 }
 
  Iif (!spatialReference) return
 
  const { latestWkid, wkid, wkt } = normalizeSpatialReference(spatialReference)
 
  Eif (wkid) {
    return { wkid, latestWkid }
  }
 
  return { wkt }
}
 
module.exports = getSpatialReference