IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Unverified Commit 4f4b209b authored by Anthony Palumbo's avatar Anthony Palumbo Committed by GitHub
Browse files

Switching Geospatial and Temporal Queries from a GET to a POST (#90)

GET to POST
parent aac981be
......@@ -11,7 +11,7 @@ const DISTANCE_ENDPOINT = `${GEOMETRY_ENDPOINT}/distance`;
const POLYGON_ENDPOINT = `${GEOMETRY_ENDPOINT}/polygon`;
describe('GET assets/geometrySearch/envelope', () => {
describe('POST assets/geometrySearch/envelope', () => {
beforeAll(async () => {
jest.setTimeout(30000);
await setup();
......@@ -35,7 +35,7 @@ describe('GET assets/geometrySearch/envelope', () => {
});
await request(app)
.get(ENVELOPE_ENDPOINT + `?${envelopeQuery}`)
.post(ENVELOPE_ENDPOINT + `?${envelopeQuery}`)
.expect(200);
});
......@@ -51,7 +51,7 @@ describe('GET assets/geometrySearch/envelope', () => {
});
await request(app)
.get(ENVELOPE_ENDPOINT + `?${envelopeQuery}`)
.post(ENVELOPE_ENDPOINT + `?${envelopeQuery}`)
.expect(200)
.then((res) => {
expect(res.body).toHaveLength(1);
......@@ -62,7 +62,7 @@ describe('GET assets/geometrySearch/envelope', () => {
});
});
describe('GET assets/geometrySearch/distance', () => {
describe('POST assets/geometrySearch/distance', () => {
beforeAll(async () => {
jest.setTimeout(30000);
await setup();
......@@ -85,12 +85,12 @@ describe('GET assets/geometrySearch/distance', () => {
});
await request(app)
.get(DISTANCE_ENDPOINT + `?${distanceQuery}`)
.post(DISTANCE_ENDPOINT + `?${distanceQuery}`)
.expect(200);
});
});
describe('GET assets/geometrySearch/polygon', () => {
describe('POST assets/geometrySearch/polygon', () => {
// Helper function
let pack = (lat, lon) => { return { latitude: lat, longitude: lon}; };
......@@ -114,7 +114,7 @@ describe('GET assets/geometrySearch/polygon', () => {
const validBody = { coordinates : [pack('13.3', '33'), pack('12', '44'), pack('12', '3')]};
await request(app)
.get(POLYGON_ENDPOINT)
.post(POLYGON_ENDPOINT)
.send(validBody)
.expect(200);
});
......
......@@ -4,7 +4,7 @@ const { setup, teardown, loadSQL } = require('../setup');
const ENDPOINT = '/api/v1/assets/properties/temporalSearch';
describe('GET assets/properties/temporalSearch', () => {
describe('POST assets/properties/temporalSearch', () => {
const polygon_search = {
'geometry': {
......@@ -42,14 +42,14 @@ describe('GET assets/properties/temporalSearch', () => {
it('returns HTTP 200 with "Polygon" search', async () => {
await request(app)
.get(ENDPOINT)
.post(ENDPOINT)
.send(polygon_search)
.expect(200);
});
it('returns HTTP 200 with "Circle" search', async () => {
await request(app)
.get(ENDPOINT)
.post(ENDPOINT)
.send(circle_search)
.expect(200);
});
......
......@@ -17,7 +17,7 @@ const {
} = require('../controllers');
// Geometry Searches
router.get(
router.post(
'/assets/geometrySearch/envelope',
validate(param.query, 'minimumLatitude', type.latitude, true),
validate(param.query, 'minimumLongitude', type.longitude, true),
......@@ -27,7 +27,7 @@ router.get(
);
// Geometry Searches
router.get(
router.post(
'/assets/geometrySearch/distance',
validate(param.query, 'latitude', type.latitude, true),
validate(param.query, 'longitude', type.longitude, true),
......@@ -35,13 +35,13 @@ router.get(
geometrySearch.distanceFind
);
router.get(
router.post(
'/assets/geometrySearch/polygon',
validate(param.body, 'coordinates', type.coordinates, true),
geometrySearch.polygonFind
);
router.get(
router.post(
'/assets/properties/temporalSearch',
validate(param.body, 'asset_id', type.id),
validate(param.body, 'sponsor', type.sponsorName),
......
{
"/assets/properties/temporalSearch": {
"get": {
"post": {
"requestBody": {
"description": "Gets an array of assets' historical properties.",
"content": {
......
......@@ -109,10 +109,10 @@ export default class GeoQuery extends LightningElement {
distanceURL.searchParams.append('longitude', `${mlon}`);
distanceURL.searchParams.append('radiusMeters', `${rad}`);
console.log('Getting: ' + distanceURL.href);
console.log('Posting to: ' + distanceURL.href);
// Send out the GET request
this.assetsPromise = utils.get(distanceURL.href);
// Send out the request
this.assetsPromise = utils.post(distanceURL.href);
// When the promise is fulfilled handle it
this.assetsPromise.then(response => {
......@@ -143,4 +143,3 @@ export default class GeoQuery extends LightningElement {
// this.map.on('click', this.onMapClicked);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment