Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Rw 105 sandbox #94

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM node:12-alpine
FROM node:12-bullseye
MAINTAINER [email protected]

ENV NAME gfw-geostore-api
ENV USER microservice

RUN apk update && apk upgrade && \
apk add --no-cache --update bash git openssh python alpine-sdk
RUN apt-get update -y && apt-get upgrade -y && \
apt-get install -y bash git ssh python3 make

RUN addgroup $USER && adduser -s /bin/bash -D -G $USER $USER

RUN yarn global add grunt-cli bunyan
RUN addgroup $USER && useradd -ms /bin/bash $USER -g $USER
RUN yarn global add bunyan grunt

RUN mkdir -p /opt/$NAME
COPY package.json /opt/$NAME/package.json
Expand Down
37 changes: 36 additions & 1 deletion app/test/e2e/utils/test.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,45 @@ const DEFAULT_GEOJSON = {
}],
};

const ANTIMERIDIAN_GEOJSON = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [
[
[
176.55029296875,
-20.11783963049162
],
[
183.09814453125,
-20.11783963049162
],
[
183.09814453125,
-14.827991347352068
],
[
176.55029296875,
-14.827991347352068
],
[
176.55029296875,
-20.11783963049162
]
]
]
}
}],
};

const MOCK_RESULT_CARTODB = [{
geojson: '{"type":"MultiPolygon","coordinates":[[[[7.4134,43.7346],[7.4396,43.7492],[7.4179,43.7226],[7.4095,43.7299],[7.4134,43.7346]]]]}',
area_ha: 235.490994944,
name: 'Monaco'
}];

module.exports = { DEFAULT_GEOJSON, MOCK_RESULT_CARTODB };
module.exports = { DEFAULT_GEOJSON, ANTIMERIDIAN_GEOJSON, MOCK_RESULT_CARTODB };
34 changes: 33 additions & 1 deletion app/test/e2e/v1/geostore-get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = require('config');
const GeoStore = require('models/geoStore');

const { createRequest } = require('../utils/test-server');
const { DEFAULT_GEOJSON } = require('../utils/test.constants');
const { DEFAULT_GEOJSON, ANTIMERIDIAN_GEOJSON } = require('../utils/test.constants');
const { getUUID, ensureCorrectError, createGeostore } = require('../utils/utils');

chai.should();
Expand Down Expand Up @@ -61,6 +61,38 @@ describe('Geostore v1 tests - Get geostores', () => {
hash.should.equal(createdGeostore.hash);
});

it('Getting a geostore that crosses the antimeridian should give a bbox [position 0 and 2] from [-180, 180] to [0, 360] (happy case)', async () => {
const createdGeostore = await createGeostore({}, ANTIMERIDIAN_GEOJSON);
const response = await geostore.get(createdGeostore.hash);

response.status.should.equal(200);
response.body.should.instanceOf(Object).and.have.property('data');

const { data } = response.body;
data.id.should.equal(createdGeostore.hash);
data.type.should.equal('geoStore');
data.should.have.property('attributes').and.should.instanceOf(Object);
data.attributes.should.instanceOf(Object);

const { geojson, bbox, hash } = data.attributes;

const expectedGeojson = {
...ANTIMERIDIAN_GEOJSON,
crs: {},
};
delete expectedGeojson.features[0].properties;

geojson.should.deep.equal(expectedGeojson);
bbox.should.instanceOf(Array);
bbox.should.deep.equal([
176.55029296875,
-20.11783963049162,
183.09814453125,
-14.827991347352068
]);
hash.should.equal(createdGeostore.hash);
});

it('Getting geostore with format esri should return the result with esrijson (happy case)', async () => {
const createdGeostore = await createGeostore();
const response = await geostore.get(createdGeostore.hash).query({ format: 'esri' });
Expand Down