diff --git a/packages/featureserver/src/helpers/calculate-extent.js b/packages/featureserver/src/helpers/calculate-extent.js deleted file mode 100644 index 98610b0c1..000000000 --- a/packages/featureserver/src/helpers/calculate-extent.js +++ /dev/null @@ -1,18 +0,0 @@ -const { calculateBounds } = require('@terraformer/spatial'); -const logManager = require('../log-manager'); -const normalizeExtent = require('./normalize-extent'); - -function calculateExtent ({ isLayer, geojson, spatialReference }) { - if (!isLayer) { - return; - } - - try { - const bounds = calculateBounds(geojson); - return normalizeExtent(bounds, spatialReference); - } catch (error) { - logManager.logger.debug(`Could not calculate extent from data: ${error.message}`); - } -} - -module.exports = calculateExtent; diff --git a/packages/featureserver/src/helpers/calculate-extent.spec.js b/packages/featureserver/src/helpers/calculate-extent.spec.js deleted file mode 100644 index 1caab0095..000000000 --- a/packages/featureserver/src/helpers/calculate-extent.spec.js +++ /dev/null @@ -1,77 +0,0 @@ -const should = require('should') // eslint-disable-line -const calculateExtent = require('./calculate-extent'); - -describe('calculate-extent', () => { - it('calculateExtent: no data passed', () => { - const extent = calculateExtent({}); - should(extent).equal(undefined); - }); - - it('calculateExtent: Point', () => { - const extent = calculateExtent({ - isLayer: true, - geojson: { - type: 'Feature', - geometry: { - type: 'Point', - coordinates: [102.0, 0.5] - }, - properties: { - prop0: 'value0' - } - }, - spatialReference: 4326 - }); - should(extent).deepEqual({ xmin: 102, ymin: 0.5, xmax: 102, ymax: 0.5, spatialReference: 4326 }); - }); - - it('calculateExtent: LineString', () => { - const extent = calculateExtent({ - isLayer: true, - geojson: { - type: 'Feature', - geometry: { - type: 'LineString', - coordinates: [ - [102.0, 0.5], - [102.3, 0.8], - [103.1, 1.2], - [103.0, 1.0], - [102.6, 0.9] - ] - }, - properties: { - prop0: 'value0' - } - }, - spatialReference: 4326 - }); - should(extent).deepEqual({ xmin: 102, ymin: 0.5, xmax: 103.1, ymax: 1.2, spatialReference: 4326 }); - }); - - it('calculateExtent: Polygon', () => { - const extent = calculateExtent({ - isLayer: true, - geojson: { - type: 'Feature', - geometry: { - type: 'Polygon', - coordinates: [ - [ - [100.0, 0.0], - [101.0, 0.0], - [101.0, 1.0], - [100.0, 1.0], - [100.0, 0.0] - ] - ] - }, - properties: { - prop0: 'value0' - } - }, - spatialReference: 102100 - }); - should(extent).deepEqual({ xmin: 100, ymin: 0.0, xmax: 101.0, ymax: 1.0, spatialReference: 102100 }); - }); -});