This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 6b9580bd91 Fix a `FactoryException` thrown when trying to find the
EPSG code of a CRS named "WGS 84". In EPSG database 9.9.1, exactly one CRS had
that name. But in EPSG 12, there is 3 of them.
6b9580bd91 is described below
commit 6b9580bd914b18f001bf9604cb51628fbf1efece
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Wed Oct 1 11:16:19 2025 +0200
Fix a `FactoryException` thrown when trying to find the EPSG code of a CRS
named "WGS 84".
In EPSG database 9.9.1, exactly one CRS had that name. But in EPSG 12,
there is 3 of them.
---
.../sis/referencing/factory/sql/EPSGDataAccess.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index ccd8b5f226..81a0e58e0e 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@ -837,7 +837,18 @@ public class EPSGDataAccess extends
GeodeticAuthorityFactory implements CRSAutho
}
Integer resolved = null;
for (Integer value : result) {
- resolved = ensureSingleton(value, resolved, code);
+ if (resolved == null) {
+ resolved = value;
+ } else if (!resolved.equals(value)) {
+ /*
+ * Cannot use `ensureSingleton(…)` because we really
need the exception type to be
+ * `NoSuchAuthorityCodeException`, as there are
callers expecting that specific type
+ * in their `catch` statements. It can be understood
as "no unambiguous identifier".
+ */
+ throw new NoSuchAuthorityCodeException(
+
error().getString(Errors.Keys.DuplicatedIdentifier_1, code),
+ Constants.EPSG, code);
+ }
}
if (resolved != null) {
primaryKeys[i] = resolved;
@@ -854,8 +865,7 @@ public class EPSGDataAccess extends
GeodeticAuthorityFactory implements CRSAutho
} catch (NumberFormatException e) {
throw (NoSuchAuthorityCodeException) new
NoSuchAuthorityCodeException(
error().getString(Errors.Keys.IllegalIdentifierForCodespace_2, Constants.EPSG,
code),
- Constants.EPSG,
- code).initCause(e);
+ Constants.EPSG, code).initCause(e);
}
}
return primaryKeys;