From 0d2d78f84c84ad67e73d4232be500bceeaab5a94 Mon Sep 17 00:00:00 2001 From: Leila Gonzales <lmg@agiweb.org> Date: Wed, 28 Jun 2017 05:14:09 -0700 Subject: [PATCH] check for invalid longitude values during indexing (#998) --- .../src/org/vufind/index/GeoTools.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/import/index_java/src/org/vufind/index/GeoTools.java b/import/index_java/src/org/vufind/index/GeoTools.java index d04aa161321..65d5fe7e7dd 100644 --- a/import/index_java/src/org/vufind/index/GeoTools.java +++ b/import/index_java/src/org/vufind/index/GeoTools.java @@ -254,19 +254,21 @@ public class GeoTools boolean validLines = true; boolean validExtent = true; boolean validNorthSouth = true; + boolean validEastWest = true; boolean validCoordDist = true; if (validateValues(record, west, east, north, south)) { validLines = validateLines(record, west, east, north, south); validExtent = validateExtent(record, west, east, north, south); validNorthSouth = validateNorthSouth(record, north, south); + validEastWest = validateEastWest(record, east, west); validCoordDist = validateCoordinateDistance(record, west, east, north, south); } else { return false; } // Validate all coordinate combinations - if (!validLines || !validExtent || !validNorthSouth || !validCoordDist) { + if (!validLines || !validExtent || !validNorthSouth || !validEastWest || !validCoordDist) { return false; } else { return true; @@ -347,6 +349,33 @@ public class GeoTools return true; } + /** + * Check decimal degree coordinates to make sure that east is not less than west. + * + * @param Record record + * @param Double east, west + * @return boolean + */ + public boolean validateEastWest(Record record, Double east, Double west) { + if (east < west) { + // Convert to 360 degree grid + if (east < 0) { + east = 360 + east; + } + if (west < 0) { + west = 360 + west; + } + // Check again + if (east < west) { + ControlField recID = (ControlField) record.getVariableField("001"); + String recNum = recID.getData(); + logger.error("Record ID: " + recNum.trim() + " - East < West."); + return false; + } + } + return true; + } + /** * Check decimal degree coordinates to make sure they are not too close. * Coordinates too close will cause Solr to run out of memory during indexing. -- GitLab