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 c221ff093a Make possible to request the inclusion of deprecated CRS in
the list returned `getAuthorityCodes()`. It make easier to regenerate the list
of supported codes during SIS releases.
c221ff093a is described below
commit c221ff093a286357ac22f92d41a923c6f7111f56
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sat Sep 27 19:50:24 2025 +0200
Make possible to request the inclusion of deprecated CRS in the list
returned `getAuthorityCodes()`.
It make easier to regenerate the list of supported codes during SIS
releases.
---
.../apache/sis/referencing/factory/sql/AuthorityCodes.java | 13 +++++++++----
.../org/apache/sis/referencing/factory/sql/EPSGFactory.java | 12 ++++++++++++
.../sis/referencing/report/CoordinateReferenceSystems.java | 10 +++++++++-
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
index 204e1b7613..b2ca6ba0a4 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
@@ -151,11 +151,16 @@ final class AuthorityCodes extends
AbstractMap<String,String> implements Seriali
buffer.append(" FROM ").append(table.fromClause);
cacheKey = table.appendWhere(factory, object, buffer);
final int conditionStart = buffer.length();
- if (table.showColumn != null) {
- buffer.append(table.showColumn).append("=TRUE AND ");
+ if (factory.owner.showDeprecated) {
+ buffer.append("TRUE");
+ } else {
+ // Do not put spaces around "=" - SQLTranslator searches for these
exact matches.
+ if (table.showColumn != null) {
+ buffer.append(table.showColumn).append("=TRUE AND ");
+ }
+ buffer.append("DEPRECATED=FALSE");
}
- // Do not put spaces around "=" - SQLTranslator searches for this
exact match.
- sql[ALL_CODES] = buffer.append("DEPRECATED=FALSE ORDER BY
").append(table.codeColumn).toString();
+ sql[ALL_CODES] = buffer.append(" ORDER BY
").append(table.codeColumn).toString();
/*
* Build the SQL query for fetching the codes of object having a name
matching a pattern.
* It is of the form:
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java
index a776938bb9..58e61128a3 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java
@@ -168,6 +168,13 @@ public class EPSGFactory extends
ConcurrentAuthorityFactory<EPSGDataAccess> impl
*/
private volatile SQLTranslator translator;
+ /**
+ * Whether to include deprecated objects in the list of objects returned
by {@code getAuthorityCodes(…)}.
+ * This flag is set to {@code true} if the properties given to the
constructor contains a key named
+ * {@code "showDeprecated"} associated to {@link Boolean#TRUE}.
+ */
+ final boolean showDeprecated;
+
/**
* The locale for producing error messages. This is usually the default
locale.
*
@@ -228,6 +235,10 @@ public class EPSGFactory extends
ConcurrentAuthorityFactory<EPSGDataAccess> impl
* <td>{@link InstallationScriptProvider}</td>
* <td>A provider of SQL scripts to use if {@code EPSGFactory} needs to
create the database.</td>
* </tr><tr>
+ * <td>{@code showDeprecated}</td>
+ * <td>{@link Boolean}</td>
+ * <td>Whether the {@linkplain #getAuthorityCodes(Class) list of
<abbr>EPSG</abbr> codes} should includes deprecated codes.</td>
+ * </tr><tr>
* <td>{@code locale}</td>
* <td>{@link Locale}</td>
* <td>The locale for producing error messages on a <em>best effort</em>
basis.</td>
@@ -262,6 +273,7 @@ public class EPSGFactory extends
ConcurrentAuthorityFactory<EPSGDataAccess> impl
schema = (String) properties.get("schema");
catalog = (String)
properties.get("catalog");
scriptProvider = (InstallationScriptProvider)
properties.get("scriptProvider");
+ showDeprecated = Boolean.TRUE.equals
(properties.get("showDeprecated"));
if (locale == null) {
locale = Locale.getDefault(Locale.Category.DISPLAY);
}
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
index 93059b4f41..23b2c3c33d 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Set;
+import java.util.Map;
import java.util.TreeMap;
import java.util.Optional;
import java.util.Collections;
@@ -57,6 +58,9 @@ import org.apache.sis.util.Version;
import org.apache.sis.util.internal.shared.Constants;
import org.apache.sis.referencing.crs.AbstractCRS;
import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.factory.CommonAuthorityFactory;
+import org.apache.sis.referencing.factory.MultiAuthoritiesFactory;
+import org.apache.sis.referencing.factory.sql.EPSGFactory;
import org.apache.sis.util.internal.shared.URLs;
import org.apache.sis.util.iso.DefaultNameSpace;
import org.apache.sis.util.logging.Logging;
@@ -166,7 +170,11 @@ public final class CoordinateReferenceSystems extends
HTMLGenerator {
super("CoordinateReferenceSystems.html",
"Coordinate Reference Systems recognized by Apache SIS™",
"crs-report.css");
- factory = CRS.getAuthorityFactory(null);
+
+ final var ogc = new CommonAuthorityFactory();
+ final var epsg = new EPSGFactory(Map.of("showDeprecated",
Boolean.TRUE));
+ final var asSet = Set.of(epsg);
+ factory = new MultiAuthoritiesFactory(List.of(ogc, epsg), asSet,
asSet, asSet);
final GeographicCRS anyCRS = factory.createGeographicCRS("EPSG:4326");
versionEPSG = IdentifiedObjects.getIdentifier(anyCRS,
Citations.EPSG).getVersion();
}