Skip to content

Commit

Permalink
Allow entry of -90 & 90 degrees latitude in editor
Browse files Browse the repository at this point in the history
Update EMLGeoCoverage model validation and tests

Fixes #2227
  • Loading branch information
robyngit committed Nov 27, 2023
1 parent 8654249 commit 90bd6fe
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
14 changes: 1 addition & 13 deletions src/js/models/metadata/eml211/EMLGeoCoverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ define(["jquery", "underscore", "backbone", "models/DataONEObject"], function (
* than the South latitude
* @property {string} crossesAntiMeridian - When the bounding box crosses
* the anti-meridian
* @property {string} containsPole - When the bounding box contains the
* North or South pole
* @since 2.27.0
*/
errorMessages: {
Expand All @@ -97,7 +95,6 @@ define(["jquery", "underscore", "backbone", "models/DataONEObject"], function (
"needPair": "Location requires at least one coordinate pair. Please add coordinates.",
"northSouthReversed": "North latitude should be greater than South. Please swap the values.",
"crossesAntiMeridian": "Bounding box crosses the anti-meridian. Please use multiple boxes that meet at the anti-meridian instead.",
"containsPole": "Coordinates include a pole. Latitudes should be >-90 and <90."
},

/**
Expand Down Expand Up @@ -408,8 +405,7 @@ define(["jquery", "underscore", "backbone", "models/DataONEObject"], function (
else if (!pointStatuses.south.isSet && pointStatuses.east.isSet)
errors.south = this.getErrorMessage("missing");

// Verify latitudes: north should be > south. Don't allow bounding boxes
// to contain the north or south poles (doesn't really work)
// Verify latitudes: north should be > south.
if (
pointStatuses.north.isSet &&
pointStatuses.south.isSet &&
Expand All @@ -421,14 +417,6 @@ define(["jquery", "underscore", "backbone", "models/DataONEObject"], function (
errors.north = msg;
errors.south = msg;
}
if (
pointStatuses.north.value == 90 ||
pointStatuses.south.value == -90
) {
const msg = this.getErrorMessage("containsPole");
errors.north = msg;
errors.south = msg;
}
}

// For longitudes, don't allow bounding boxes that attempt to traverse
Expand Down
21 changes: 0 additions & 21 deletions test/js/specs/unit/models/metadata/eml211/EMLGeoCoverage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,6 @@ define([
errors.east.should.equal(expectedMsg);
});

it("should give an error if the bounds contain the north pole", function () {
var emlGeoCoverage = new EMLGeoCoverage(
{ objectDOM: this.testEML },
{ parse: true }
);
emlGeoCoverage.set("north", "90");
const errors = emlGeoCoverage.validate();
const expectedMsg = emlGeoCoverage.errorMessages.containsPole;
errors.north.should.equal(expectedMsg);
});

it("should give an error if the bounds contain the south pole", function () {
var emlGeoCoverage = new EMLGeoCoverage(
{ objectDOM: this.testEML },
{ parse: true }
);
emlGeoCoverage.set("south", "-90");
const errors = emlGeoCoverage.validate();
const expectedMsg = emlGeoCoverage.errorMessages.containsPole;
errors.south.should.equal(expectedMsg);
});
});
});
});

0 comments on commit 90bd6fe

Please sign in to comment.