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
commit 073df1665d295b2315bc8fe7e5d60924cbc6a908 Author: Martin Desruisseaux <[email protected]> AuthorDate: Sun Aug 10 13:43:00 2025 +0200 Use a consistent naming convention for the tables that are new in EPSG 10+. --- .../referencing/factory/sql/EPSGDataAccess.java | 18 ++-- .../sis/referencing/factory/sql/EPSGInstaller.java | 10 +-- .../sis/referencing/factory/sql/EPSG_Prepare.sql | 9 +- .../sis/referencing/factory/sql/SQLTranslator.java | 100 +++++++++++---------- 4 files changed, 73 insertions(+), 64 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 59997d0496..88c53ef737 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 @@ -2009,9 +2009,9 @@ search: try (ResultSet result = executeMetadataQuery("Deprecation", { double max = Double.NaN; try (ResultSet result = executeQueryForCodes( - "DatumEnsemble", + "Datum Ensemble", "SELECT ENSEMBLE_ACCURACY" - + " FROM \"DatumEnsemble\"" + + " FROM \"Datum Ensemble\"" + " WHERE DATUM_ENSEMBLE_CODE = ?", code)) { // Should have exactly one value. The loop is a paranoiac safety. @@ -2025,9 +2025,9 @@ search: try (ResultSet result = executeMetadataQuery("Deprecation", final var accuracy = PositionalAccuracyConstant.ensemble(max); final List<Datum> members = createComponents( GeodeticAuthorityFactory::createDatum, - "DatumEnsembleMember", + "Datum Ensemble Member", "SELECT DATUM_CODE" - + " FROM \"DatumEnsembleMember\"" + + " FROM \"Datum Ensemble Member\"" + " WHERE DATUM_ENSEMBLE_CODE = ?" + " ORDER BY DATUM_SEQUENCE", code); return (factory, metadata) -> DefaultDatumEnsemble.castOrCopy(factory.createDatumEnsemble(metadata, members, accuracy)); @@ -2104,12 +2104,12 @@ search: try (ResultSet result = executeMetadataQuery("Deprecation", var returnValue = (IdentifiedObject) localCache.get(cacheKey); if (returnValue == null) { try (ResultSet result = executeQueryForCodes( - "ConventionalRS", + "Conventional RS", "SELECT"+ /* column 1 */ " CONVENTIONAL_RS_CODE," + /* column 2 */ " CONVENTIONAL_RS_NAME," + /* column 3 */ " REMARKS," + /* column 4 */ " DEPRECATED" - + " FROM \"ConventionalRS\"" + + " FROM \"Conventional RS\"" + " WHERE CONVENTIONAL_RS_CODE = ?", code)) { while (result.next()) { @@ -2123,7 +2123,7 @@ search: try (ResultSet result = executeMetadataQuery("Deprecation", */ @SuppressWarnings("LocalVariableHidesMemberVariable") final Map<String,Object> properties = createProperties( - "ConventionalRS", epsg, name, null, null, null, remarks, deprecated); + "Conventional RS", epsg, name, null, null, null, remarks, deprecated); returnValue = ensureSingleton(new AbstractIdentifiedObject(properties), returnValue, code); if (result.isClosed()) break; // See createProperties(…) for explanation. } @@ -2723,9 +2723,9 @@ search: try (ResultSet result = executeMetadataQuery("Deprecation", var returnValue = (RealizationMethod) localCache.get(cacheKey); if (returnValue == null && code != null) { try (ResultSet result = executeQueryForCodes( - "DatumRealizationMethod", + "Datum Realization Method", "SELECT REALIZATION_METHOD_NAME" - + " FROM \"DatumRealizationMethod\"" + + " FROM \"Datum Realization Method\"" + " WHERE REALIZATION_METHOD_CODE = ?", code)) { while (result.next()) { diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGInstaller.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGInstaller.java index 124eb96682..637aba0ca8 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGInstaller.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGInstaller.java @@ -124,7 +124,7 @@ final class EPSGInstaller extends ScriptRunner { addReplacement(SQLTranslator.TABLE_PREFIX + "alias", "Alias"); addReplacement(SQLTranslator.TABLE_PREFIX + "area", "Area"); // Deprecated (removed in EPSG 10) addReplacement(SQLTranslator.TABLE_PREFIX + "change", "Change"); - addReplacement(SQLTranslator.TABLE_PREFIX + "conventionalrs", "ConventionalRS"); + addReplacement(SQLTranslator.TABLE_PREFIX + "conventionalrs", "Conventional RS"); addReplacement(SQLTranslator.TABLE_PREFIX + "coordinateaxis", "Coordinate Axis"); addReplacement(SQLTranslator.TABLE_PREFIX + "coordinateaxisname", "Coordinate Axis Name"); addReplacement(SQLTranslator.TABLE_PREFIX + "coordoperation", "Coordinate_Operation"); @@ -136,10 +136,10 @@ final class EPSGInstaller extends ScriptRunner { addReplacement(SQLTranslator.TABLE_PREFIX + "coordinatereferencesystem", "Coordinate Reference System"); addReplacement(SQLTranslator.TABLE_PREFIX + "coordinatesystem", "Coordinate System"); addReplacement(SQLTranslator.TABLE_PREFIX + "datum", "Datum"); - addReplacement(SQLTranslator.TABLE_PREFIX + "datumensemble", "DatumEnsemble"); - addReplacement(SQLTranslator.TABLE_PREFIX + "datumensemblemember", "DatumEnsembleMember"); - addReplacement(SQLTranslator.TABLE_PREFIX + "datumrealizationmethod", "DatumRealizationMethod"); - addReplacement(SQLTranslator.TABLE_PREFIX + "definingoperation", "DefiningOperation"); + addReplacement(SQLTranslator.TABLE_PREFIX + "datumensemble", "Datum Ensemble"); + addReplacement(SQLTranslator.TABLE_PREFIX + "datumensemblemember", "Datum Ensemble Member"); + addReplacement(SQLTranslator.TABLE_PREFIX + "datumrealizationmethod", "Datum Realization Method"); + addReplacement(SQLTranslator.TABLE_PREFIX + "definingoperation", "Defining Operation"); addReplacement(SQLTranslator.TABLE_PREFIX + "deprecation", "Deprecation"); addReplacement(SQLTranslator.TABLE_PREFIX + "ellipsoid", "Ellipsoid"); addReplacement(SQLTranslator.TABLE_PREFIX + "extent", "Extent"); diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSG_Prepare.sql b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSG_Prepare.sql index b84c8ad6d4..7e0bdb267b 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSG_Prepare.sql +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSG_Prepare.sql @@ -17,7 +17,6 @@ CREATE TYPE epsg_supersession_type AS ENUM ('Supersession'); CREATE TYPE epsg_table_name AS ENUM ('Alias', 'Area', -- Deprecated (removed in EPSG 10). - 'AxisName', -- Deprecated (removed in EPSG 10). 'Change', 'ConventionalRS', 'Coordinate Axis', @@ -31,10 +30,10 @@ CREATE TYPE epsg_table_name AS ENUM 'Coordinate Reference System', 'Coordinate System', 'Datum', - 'DatumEnsemble', - 'DatumEnsembleMember', - 'DatumRealizationMethod', - 'DefiningOperation', + 'Datum Ensemble', + 'Datum Ensemble Member', + 'Datum Realization Method', + 'Defining Operation', 'Deprecation', 'Ellipsoid', 'Extent', diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/SQLTranslator.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/SQLTranslator.java index ca2979436d..95327f20ac 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/SQLTranslator.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/SQLTranslator.java @@ -55,58 +55,68 @@ import org.apache.sis.referencing.internal.Resources; * <li>{@code SELECT * FROM epsg_CoordinateReferenceSystem} (same as above with {@code "epsg_"} prefix added)</li> * </ul> * - * Above possibilities differ in the letter cases, spaces and {@code "epsg_"} prefix (non-exhaustive). - * Those differences exist between the <abbr>EPSG</abbr> databases distributed in MS-Access format or - * as <abbr>SQL</abbr> scripts. More differences may exist for handling the differences between version - * 9 and 10 of the <abbr>EPSG</abbr> database schema. + * Some differences are the lower or camel case, the spaces between words and the {@code "epsg_"} prefix. + * Those differences exist because the <abbr>EPSG</abbr> database is distributed in two family of formats: + * as an MS-Access file and as <abbr>SQL</abbr> scripts, and those two families use different table names. + * In addition to format-dependent differences, there is also changes in the database schema between some + * versions of the <abbr>EPSG</abbr> dataset. * - * <p>Apache <abbr>SIS</abbr> generally uses the naming convention found in the MS-Access database, - * because it provides more readable <abbr>SQL</abbr> statements. <abbr>SIS</abbr> also assumes an - * <abbr>EPSG</abbr> database schema version 10 or latter. If {@link EPSGFactory} is connected to - * a database which uses a different table naming convention, or to <abbr>EPSG</abbr> version 9, - * then this {@code SQLTranslator} class will translate the <abbr>SQL</abbr> statements on-the-fly. - * The following table gives the mapping between the two naming conventions:</p> + * <h2>Table naming convention</h2> + * For readability reasons, + * Apache <abbr>SIS</abbr> generally uses the naming convention found in the MS-Access database, + * except for the cases shown in the "Name in Apache <abbr>SIS</abbr>" column of the table below. + * The <abbr>SQL</abbr> statements given to the {@link #apply(String)} method use the latter. + * The following table gives the mapping between the naming conventions: * * <table class="sis"> - * <caption>Table and column names</caption> - * <tr><th>Element</th> <th>Name in MS-Access database</th> <th>Name in <abbr>SQL</abbr> scripts</th></tr> - * <tr><td>Table</td> <td>{@code Alias}</td> <td>{@code epsg_alias}</td></tr> - * <tr><td>Legacy table</td> <td>{@code Area}</td> <td>{@code epsg_area}</td></tr> - * <tr><td>Table</td> <td>{@code Change}</td> <td>{@code epsg_change}</td></tr> - * <tr><td>Table</td> <td>{@code ConventionalRS}</td> <td>{@code epsg_conventionalrs}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate Axis}</td> <td>{@code epsg_coordinateaxis}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate Axis Name}</td> <td>{@code epsg_coordinateaxisname}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate_Operation}</td> <td>{@code epsg_coordoperation}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate_Operation Method}</td> <td>{@code epsg_coordoperationmethod}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate_Operation Parameter}</td> <td>{@code epsg_coordoperationparam}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate_Operation Parameter Usage}</td> <td>{@code epsg_coordoperationparamusage}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate_Operation Parameter Value}</td> <td>{@code epsg_coordoperationparamvalue}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate_Operation Path}</td> <td>{@code epsg_coordoperationpath}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate Reference System}</td> <td>{@code epsg_coordinatereferencesystem}</td></tr> - * <tr><td>Table</td> <td>{@code Coordinate System}</td> <td>{@code epsg_coordinatesystem}</td></tr> - * <tr><td>Table</td> <td>{@code Datum}</td> <td>{@code epsg_datum}</td></tr> - * <tr><td>Table</td> <td>{@code DatumEnsemble}</td> <td>{@code epsg_datumensemble}</td></tr> - * <tr><td>Table</td> <td>{@code DatumEnsembleMember}</td> <td>{@code epsg_datumensemblemember}</td></tr> - * <tr><td>Table</td> <td>{@code DatumRealizationMethod}</td> <td>{@code epsg_datumrealizationmethod}</td></tr> - * <tr><td>Table</td> <td>{@code DefiningOperation}</td> <td>{@code epsg_definingoperation}</td></tr> - * <tr><td>Table</td> <td>{@code Deprecation}</td> <td>{@code epsg_deprecation}</td></tr> - * <tr><td>Table</td> <td>{@code Ellipsoid}</td> <td>{@code epsg_ellipsoid}</td></tr> - * <tr><td>Table</td> <td>{@code Extent}</td> <td>{@code epsg_extent}</td></tr> - * <tr><td>Table</td> <td>{@code Naming System}</td> <td>{@code epsg_namingsystem}</td></tr> - * <tr><td>Table</td> <td>{@code Prime Meridian}</td> <td>{@code epsg_primemeridian}</td></tr> - * <tr><td>Table</td> <td>{@code Scope}</td> <td>{@code epsg_scope}</td></tr> - * <tr><td>Table</td> <td>{@code Supersession}</td> <td>{@code epsg_supersession}</td></tr> - * <tr><td>Table</td> <td>{@code Unit of Measure}</td> <td>{@code epsg_unitofmeasure}</td></tr> - * <tr><td>Table</td> <td>{@code Version History}</td> <td>{@code epsg_versionhistory}</td></tr> - * <tr><td>Table</td> <td>{@code Usage}</td> <td>{@code epsg_usage}</td></tr> - * <tr><td>Column</td> <td>{@code ORDER}</td> <td>{@code coord_axis_order}</td></tr> + * <caption>Mapping of table names</caption> + * <tr><th>Name in <abbr>SQL</abbr> scripts</th> <th>Name in MS-Access database</th> <th>Name in Apache <abbr>SIS</abbr></th></tr> + * <tr><td>{@code epsg_alias}</td> <td>{@code Alias}</td> <td>″</td></tr> + * <tr><td>{@code epsg_area}</td> <td>{@code Area}</td> <td>″</td></tr> + * <tr><td>{@code epsg_change}</td> <td>{@code Change}</td> <td>″</td></tr> + * <tr><td>{@code epsg_conventionalrs}</td> <td>{@code ConventionalRS}</td> <td>{@code Conventional RS}</td></tr> + * <tr><td>{@code epsg_coordinateaxis}</td> <td>{@code Coordinate Axis}</td> <td>″</td></tr> + * <tr><td>{@code epsg_coordinateaxisname}</td> <td>{@code Coordinate Axis Name}</td> <td>″</td></tr> + * <tr><td>{@code epsg_coordoperation}</td> <td>{@code Coordinate_Operation}</td> <td>″</td></tr> + * <tr><td>{@code epsg_coordoperationmethod}</td> <td>{@code Coordinate_Operation Method}</td> <td>″</td></tr> + * <tr><td>{@code epsg_coordoperationparam}</td> <td>{@code Coordinate_Operation Parameter}</td> <td>″</td></tr> + * <tr><td>{@code epsg_coordoperationparamusage}</td> <td>{@code Coordinate_Operation Parameter Usage}</td><td>″</td></tr> + * <tr><td>{@code epsg_coordoperationparamvalue}</td> <td>{@code Coordinate_Operation Parameter Value}</td><td>″</td></tr> + * <tr><td>{@code epsg_coordoperationpath}</td> <td>{@code Coordinate_Operation Path}</td> <td>″</td></tr> + * <tr><td>{@code epsg_coordinatereferencesystem}</td><td>{@code Coordinate Reference System}</td> <td>″</td></tr> + * <tr><td>{@code epsg_coordinatesystem}</td> <td>{@code Coordinate System}</td> <td>″</td></tr> + * <tr><td>{@code epsg_datum}</td> <td>{@code Datum}</td> <td>″</td></tr> + * <tr><td>{@code epsg_datumensemble}</td> <td>{@code DatumEnsemble}</td> <td>{@code Datum Ensemble}</td></tr> + * <tr><td>{@code epsg_datumensemblemember}</td> <td>{@code DatumEnsembleMember}</td> <td>{@code Datum Ensemble Member}</td></tr> + * <tr><td>{@code epsg_datumrealizationmethod}</td> <td>{@code DatumRealizationMethod}</td> <td>{@code Datum Realization Method}</td></tr> + * <tr><td>{@code epsg_definingoperation}</td> <td>{@code DefiningOperation}</td> <td>{@code Defining Operation}</td></tr> + * <tr><td>{@code epsg_deprecation}</td> <td>{@code Deprecation}</td> <td>″</td></tr> + * <tr><td>{@code epsg_ellipsoid}</td> <td>{@code Ellipsoid}</td> <td>″</td></tr> + * <tr><td>{@code epsg_extent}</td> <td>{@code Extent}</td> <td>″</td></tr> + * <tr><td>{@code epsg_namingsystem}</td> <td>{@code Naming System}</td> <td>″</td></tr> + * <tr><td>{@code epsg_primemeridian}</td> <td>{@code Prime Meridian}</td> <td>″</td></tr> + * <tr><td>{@code epsg_scope}</td> <td>{@code Scope}</td> <td>″</td></tr> + * <tr><td>{@code epsg_supersession}</td> <td>{@code Supersession}</td> <td>″</td></tr> + * <tr><td>{@code epsg_unitofmeasure}</td> <td>{@code Unit of Measure}</td> <td>″</td></tr> + * <tr><td>{@code epsg_versionhistory}</td> <td>{@code Version History}</td> <td>″</td></tr> + * <tr><td>{@code epsg_usage}</td> <td>{@code Usage}</td> <td>″</td></tr> * </table> * - * Apache <abbr>SIS</abbr> automatically detects which convention is used, regardless the database engine. + * Columns have the same name in all formats, with only one exception: + * for avoiding confusion with the <abbr>SQL</abbr> keyword of the same name, + * the {@code ORDER} column in MS-Access has been renamed {@code coord_axis_order} in <abbr>SQL</abbr> scripts. + * Apache <abbr>SIS</abbr> uses the latter. + * + * <p>Apache <abbr>SIS</abbr> automatically detects which name convention is used, regardless the database engine. * For example, it is legal to use the mixed-case variant in a PostgreSQL database * even if <abbr>EPSG</abbr> distributes the PostgreSQL scripts in lower-case. * The {@code "epsg_"} prefix is redundant with database schema and can be omitted. - * {@code SQLTranslator} automatically detects which database schema contains the <abbr>EPSG</abbr> tables. + * {@code SQLTranslator} automatically detects which database schema contains the <abbr>EPSG</abbr> tables.</p> + * + * <h2>Versions of <abbr>EPSG</abbr> schema</h2> + * Apache <abbr>SIS</abbr> assumes an <abbr>EPSG</abbr> database schema version 10 or latter. + * If {@link EPSGFactory} is connected to the <abbr>EPSG</abbr> version 9 database, + * then this {@code SQLTranslator} class will modify the <abbr>SQL</abbr> statements on-the-fly. * * <h2>Thread safety</h2> * All {@code SQLTranslator} instances given to the {@link EPSGFactory} constructor @@ -232,7 +242,7 @@ public class SQLTranslator implements UnaryOperator<String> { private boolean useBoolean; /** - * Whether the sentinel table "Coordinate_Operation" or a variant has been found. + * Whether the sentinel table {@code "Coordinate_Operation"} or a variant has been found. * If {@code false}, then {@link EPSGInstaller} needs to be run. * Note that the {@linkplain #schema} may be {@code null}. *
