From 3337d6f7c0a26e0b99c99ba7c35550e5de676e99 Mon Sep 17 00:00:00 2001 From: Brian Osborn Date: Fri, 15 Mar 2024 11:22:13 -0600 Subject: [PATCH] validate all crs definitions can be read, attempt to validate the identifier --- CHANGELOG.md | 1 + .../nga/geopackage/dgiwg/DGIWGValidate.java | 46 ++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 872250a7..10245c8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Adheres to [Semantic Versioning](http://semver.org/). * DAO column range support (including geometry envelopes & bounding boxes) to build where clauses & args for queries * User Column integrated Data Columns Schema support * RTree Index and Feature Table Index geodesic support +* DGIWG validation updates: 1 meter tile bounds tolerance, CRS definition parsing validation * sf-wkb version 2.2.3 * sf-wkt version 1.2.3 * sf-proj version 4.3.2 diff --git a/src/main/java/mil/nga/geopackage/dgiwg/DGIWGValidate.java b/src/main/java/mil/nga/geopackage/dgiwg/DGIWGValidate.java index bc479823..9589506f 100644 --- a/src/main/java/mil/nga/geopackage/dgiwg/DGIWGValidate.java +++ b/src/main/java/mil/nga/geopackage/dgiwg/DGIWGValidate.java @@ -1,12 +1,12 @@ package mil.nga.geopackage.dgiwg; -import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import mil.nga.crs.CRS; import mil.nga.crs.CRSType; +import mil.nga.crs.common.Identifier; import mil.nga.crs.operation.OperationMethods; import mil.nga.crs.projected.ProjectedCoordinateReferenceSystem; import mil.nga.crs.wkt.CRSReader; @@ -589,7 +589,7 @@ public static DGIWGValidationErrors validateTileCoordinateReferenceSystem( if (definition != null) { try { definitionCrs = CRSReader.read(definition); - } catch (IOException e) { + } catch (Exception e) { errors.add(new DGIWGValidationError( SpatialReferenceSystem.TABLE_NAME, SpatialReferenceSystem.COLUMN_DEFINITION, @@ -873,6 +873,48 @@ private static CoordinateReferenceSystem validateCoordinateReferenceSystem( definition, "Missing required coordinate reference system well-known text definition", DGIWGRequirement.CRS_WKT, primaryKey(srs))); + } else { + CRS definitionCrs = null; + try { + definitionCrs = CRSReader.read(definition); + } catch (Exception e) { + errors.add(new DGIWGValidationError( + SpatialReferenceSystem.TABLE_NAME, + SpatialReferenceSystem.COLUMN_DEFINITION, + definition, + "Failed to read coordinate reference system definition: " + + e.getMessage(), + DGIWGRequirement.CRS_WKT, primaryKey(srs))); + } + if (definitionCrs != null) { + if (definitionCrs.hasIdentifiers()) { + boolean found = false; + for (Identifier identifier : definitionCrs + .getIdentifiers()) { + if (crs.getAuthority() + .equalsIgnoreCase(identifier.getName()) + && String.valueOf(crs.getCode()) + .equalsIgnoreCase(identifier + .getUniqueIdentifier())) { + found = true; + } + } + if (!found) { + for (Identifier identifier : definitionCrs + .getIdentifiers()) { + errors.add(new DGIWGValidationError( + SpatialReferenceSystem.TABLE_NAME, + SpatialReferenceSystem.COLUMN_DEFINITION, + identifier.toString(), + new Identifier(crs.getAuthority(), + String.valueOf(crs.getCode())) + .toString(), + DGIWGRequirement.CRS_WKT, + primaryKey(srs))); + } + } + } + } } if (!srs.getSrsName().equalsIgnoreCase(crs.getName())) {