Skip to content

Commit

Permalink
feat: updated javascript call to use all slug data endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-hd committed Oct 9, 2024
1 parent c9ff9ba commit ef0c835
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,21 +358,20 @@
const boundaryData = await boundaryResponse.json()
hideSpinner()

if (boundaryData.length === 0) {
if (boundaryData.coordinates.length === 0 && boundaryData.coordinates[0].length) {
const errorMessage = 'Selected location does not have any Native Land boundary'
raiseError(selectionUnit, errorMessage)
throw new Error(errorMessage)
}

const boundary = boundaryData[0]
const boundaryCoordinates = boundary.geometry.coordinates[0]

const boundaryCoordinates = boundaryData.coordinates[0][0]
// reorder so (lon, lat)'s become (lat, lon)'s
boundaryCoordinates.map(row=>row.reverse())

// set Boundary with payload
BoundaryPayLoad = {
source: boundary.properties.description,
name: boundary.properties.Name,
source: boundaryData.description,
name: slug,
boundary: boundaryCoordinates,
should_update_coordinates: true,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,20 @@
const boundaryData = await boundaryResponse.json()
hideSpinner()

if (boundaryData.length === 0) {
if (boundaryData.coordinates.length === 0 && boundaryData.coordinates[0].length) {
const errorMessage = 'Selected location does not have any Native Land boundary'
raiseError(selectionUnit, errorMessage)
throw new Error(errorMessage)
}

const boundary = boundaryData[0]
const boundaryCoordinates = boundary.geometry.coordinates[0]
const boundaryCoordinates = boundaryData.coordinates[0][0]
// reorder so (lon, lat)'s become (lat, lon)'s
boundaryCoordinates.map(row=>row.reverse())

// set Boundary with payload
BoundaryPayLoad = {
source: boundary.properties.description,
name: boundary.properties.Name,
source: boundaryData.description,
name: slug,
boundary: boundaryCoordinates
}
setViewLocationsHref(selectionUnit, boundaryCoordinates)
Expand Down

0 comments on commit ef0c835

Please sign in to comment.