-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FCRM-4507 removed all references to removed getByPoint service
- Loading branch information
Showing
4 changed files
with
4 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,11 @@ | ||
const util = require('../util') | ||
const config = require('../../config') | ||
const url = config.service + '/zones' | ||
const urlByPolygon = config.service + '/zones-by-polygon' | ||
const getAreaPolygon = require('area-polygon') | ||
|
||
const getByPoint = (easting, northing) => { | ||
if (!easting || !northing) { | ||
throw new Error('No Point provided') | ||
} | ||
|
||
return util.getJson(`${url}/${easting}/${northing}/1`) | ||
} | ||
const getByPolygon = (polygon) => { | ||
if (!polygon) { | ||
throw new Error('No Polygon provided') | ||
} | ||
const { coordinates = [] } = JSON.parse(polygon) | ||
|
||
const area = getAreaPolygon(coordinates[0]) | ||
if (area === 0 || area === '0') { | ||
return getByPoint(coordinates[0][0][0], coordinates[0][0][1]) | ||
} else { | ||
return util.getJson(`${urlByPolygon}?polygon=${polygon}`) | ||
} | ||
return util.getJson(`${urlByPolygon}?polygon=${polygon}`) | ||
} | ||
module.exports = { getByPoint, getByPolygon } | ||
module.exports = { getByPolygon } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters