Skip to content

Commit 6877c29

Browse files
author
Phil Varner
authored
revert intersects geometry validation (#550)
* revert intersects geometry validation * update changelog and prep for 2.2.2 release
1 parent 9a53182 commit 6877c29

File tree

5 files changed

+86
-74
lines changed

5 files changed

+86
-74
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [2.2.2] - 2023-07-06
9+
10+
### Changed
11+
12+
- Revert validation of Search intersects geometry added in 2.0.0, as it was too strict
13+
and rejected some usable geometries.
14+
815
## [2.2.1] - 2023-07-06
916

1017
### Fixed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"displayName": "stac-server",
33
"description": "A STAC API running on stac-server",
4-
"version": "2.2.1",
4+
"version": "2.2.2",
55
"repository": "https://github.com/stac-utils/stac-server",
66
"author": "Alireza Jazayeri, Matthew Hanson <matt.a.hanson@gmail.com>, Sean Harkins",
77
"license": "MIT",

src/lib/api.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { pickBy, assign, get as getNested } from 'lodash-es'
22
import extent from '@mapbox/extent'
33
import { DateTime } from 'luxon'
44
import AWS from 'aws-sdk'
5-
import geojsonhint from '@mapbox/geojsonhint'
5+
// import geojsonhint from '@mapbox/geojsonhint'
66
import { isIndexNotFoundError } from './database.js'
77
import logger from './logger.js'
88

@@ -618,18 +618,18 @@ const searchItems = async function (collectionId, queryParameters, backend, endp
618618

619619
logger.info('Search parameters (processed): %j', searchParams)
620620

621-
try { // Attempt to catch invalid geometry before querying Search
622-
const hints = geometry ? geojsonhint.hint(geometry, {}) : []
623-
624-
if (hints.length > 0) {
625-
return {
626-
statusCode: 400,
627-
body: hints.map(({ message }) => ({ message }))
628-
}
629-
}
630-
} catch (e) {
631-
logger.error(e)
632-
}
621+
// try { // Attempt to catch invalid geometry before querying Search
622+
// const hints = geometry ? geojsonhint.hint(geometry, {}) : []
623+
624+
// if (hints.length > 0) {
625+
// return {
626+
// statusCode: 400,
627+
// body: hints.map(({ message }) => ({ message }))
628+
// }
629+
// }
630+
// } catch (e) {
631+
// logger.error(e)
632+
// }
633633

634634
let esResponse
635635
try {

tests/system/test-api-search-post.js

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const __filename = fileURLToPath(import.meta.url)
1414
const __dirname = path.dirname(__filename) // eslint-disable-line no-unused-vars
1515
const intersectsGeometry = fs.readFileSync(path.resolve(__dirname, '../fixtures/stac/intersectsGeometry.json'), 'utf8')
1616

17-
const fixture = (filepath) => fs.readFileSync(path.resolve(__dirname, filepath), 'utf8')
17+
// const fixture = (filepath) => fs.readFileSync(path.resolve(__dirname, filepath), 'utf8')
1818

1919
const ingestEntities = async (fixtures) => {
2020
await ingestItems(
@@ -420,63 +420,68 @@ test('/search preserve intersects geometry in next link', async (t) => {
420420
t.deepEqual(nextLink.body.intersects, intersectsGeometry)
421421
})
422422

423-
test('POST /search using bad geometry, expecting useful error messages', async (t) => {
424-
let response = null
425-
426-
response = await t.context.api.client.post('search', {
427-
json: {
428-
intersects: fixture('../fixtures/geometry/badGeoUnclosed.json')
429-
}
430-
})
431-
t.is(response.statusCode, 400)
432-
t.deepEqual(response.body, [{ message: 'the first and last positions in a LinearRing of coordinates must be the same' }])
433-
434-
response = await t.context.api.client.post('search', {
435-
json: {
436-
intersects: fixture('../fixtures/geometry/badGeoRightHandRule.json')
437-
}
438-
})
439-
t.is(response.statusCode, 400)
440-
t.deepEqual(response.body, [{ message: 'Polygons and MultiPolygons should follow the right-hand rule' }])
441-
442-
response = await t.context.api.client.post('search', {
443-
json: {
444-
intersects: fixture('../fixtures/geometry/badGeoFourPoints.json')
445-
}
446-
})
447-
t.is(response.statusCode, 400)
448-
t.deepEqual(response.body, [
449-
{
450-
reason: 'failed to create query: at least 4 polygon points required'
451-
},
452-
{
453-
reason: 'failed to create query: at least 4 polygon points required'
454-
}
455-
])
456-
457-
response = await t.context.api.client.post('search', {
458-
json: {
459-
intersects: fixture('../fixtures/geometry/badGeoDuplicateConsecutive.json')
460-
}
461-
})
462-
t.is(response.statusCode, 400)
463-
t.deepEqual(response.body, [
464-
{
465-
reason: 'failed to create query: Provided shape has duplicate consecutive coordinates at: (POINT (100.0 1.0))'
466-
},
467-
{
468-
reason: 'failed to create query: Provided shape has duplicate consecutive coordinates at: (POINT (100.0 1.0))'
469-
}
470-
])
471-
472-
response = await t.context.api.client.post('search', {
473-
json: {
474-
intersects: fixture('../fixtures/geometry/badGeoRightHandRule2.json')
475-
}
476-
})
477-
t.is(response.statusCode, 400)
478-
t.deepEqual(response.body, [{ message: 'Polygons and MultiPolygons should follow the right-hand rule' }])
479-
})
423+
// test('POST /search using bad geometry, expecting useful error messages', async (t) => {
424+
// let response = null
425+
426+
// response = await t.context.api.client.post('search', {
427+
// json: {
428+
// intersects: fixture('../fixtures/geometry/badGeoUnclosed.json')
429+
// }
430+
// })
431+
// t.is(response.statusCode, 400)
432+
// t.deepEqual(response.body,
433+
// [{ message: 'the first and last positions in a LinearRing of coordinates must be the same' }])
434+
435+
// response = await t.context.api.client.post('search', {
436+
// json: {
437+
// intersects: fixture('../fixtures/geometry/badGeoRightHandRule.json')
438+
// }
439+
// })
440+
// t.is(response.statusCode, 400)
441+
// t.deepEqual(response.body,
442+
// [{ message: 'Polygons and MultiPolygons should follow the right-hand rule' }])
443+
444+
// response = await t.context.api.client.post('search', {
445+
// json: {
446+
// intersects: fixture('../fixtures/geometry/badGeoFourPoints.json')
447+
// }
448+
// })
449+
// t.is(response.statusCode, 400)
450+
// t.deepEqual(response.body, [
451+
// {
452+
// reason: 'failed to create query: at least 4 polygon points required'
453+
// },
454+
// {
455+
// reason: 'failed to create query: at least 4 polygon points required'
456+
// }
457+
// ])
458+
459+
// response = await t.context.api.client.post('search', {
460+
// json: {
461+
// intersects: fixture('../fixtures/geometry/badGeoDuplicateConsecutive.json')
462+
// }
463+
// })
464+
// t.is(response.statusCode, 400)
465+
// t.deepEqual(response.body, [
466+
// {
467+
// reason: 'failed to create query:
468+
// Provided shape has duplicate consecutive coordinates at: (POINT (100.0 1.0))'
469+
// },
470+
// {
471+
// reason: 'failed to create query:
472+
// Provided shape has duplicate consecutive coordinates at: (POINT (100.0 1.0))'
473+
// }
474+
// ])
475+
476+
// response = await t.context.api.client.post('search', {
477+
// json: {
478+
// intersects: fixture('../fixtures/geometry/badGeoRightHandRule2.json')
479+
// }
480+
// })
481+
// t.is(response.statusCode, 400)
482+
// t.deepEqual(response.body,
483+
// [{ message: 'Polygons and MultiPolygons should follow the right-hand rule' }])
484+
// })
480485

481486
test('/search preserve bbox in prev and next links', async (t) => {
482487
const bbox = [-180, -90, 180, 90]

0 commit comments

Comments
 (0)