featureserver
Version:
*An open source implementation of the GeoServices specification*
21 lines (17 loc) • 571 B
JavaScript
const { calculateBounds } = require('@terraformer/spatial')
const normalizeExtent = require('./normalize-extent')
const debug = process.env.KOOP_LOG_LEVEL === 'debug' || process.env.LOG_LEVEL === 'debug'
function calculateExtent ({ isLayer, geojson, spatialReference }) {
if (!isLayer) {
return
}
try {
const bounds = calculateBounds(geojson)
return normalizeExtent(bounds, spatialReference)
} catch (error) {
if (debug) {
console.log(`Could not calculate extent from data: ${error.message}`)
}
}
}
module.exports = calculateExtent