You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2017/05/13 14:05:44 UTC
svn commit: r1795064 - in /sis/branches/JDK8/core/sis-referencing/src:
main/java/org/apache/sis/referencing/factory/sql/
test/java/org/apache/sis/referencing/factory/sql/
test/java/org/apache/sis/referencing/factory/sql/epsg/
test/java/org/apache/sis/t...
Author: desruisseaux
Date: Sat May 13 14:05:43 2017
New Revision: 1795064
URL: http://svn.apache.org/viewvc?rev=1795064&view=rev
Log:
Prepare for updating EPSG database from version 8.9 to 9.0: the "epoch realization" column in the Datum table is no longer a year only, but now a year-month-day date.
Added:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSG_README.txt (with props)
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatter.java
- copied, changed from r1795063, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatterTest.java
- copied, changed from r1795063, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatterTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/MethodDimensions.sql
- copied unchanged from r1795063, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGMethodDimensions.sql
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html (with props)
Removed:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatterTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGMethodDimensions.sql
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1795064&r1=1795063&r2=1795064&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] Sat May 13 14:05:43 2017
@@ -1616,11 +1616,29 @@ addURIs: for (int i=0; ; i++) {
if (anchor != null) {
properties.put(Datum.ANCHOR_POINT_KEY, anchor);
}
- if (epoch != null && !epoch.isEmpty()) try {
- final int year = Integer.parseInt(epoch);
- final Calendar calendar = getCalendar();
- calendar.set(year, 0, 1);
- properties.put(Datum.REALIZATION_EPOCH_KEY, calendar.getTime());
+ if (epoch != null) try {
+ /*
+ * Parse the date manually because it is declared as a VARCHAR instead than DATE in original
+ * SQL scripts. Apache SIS installer replaces VARCHAR by DATE, but we have no guarantee that
+ * we are reading an EPSG database created by our installer. Furthermore an older version of
+ * EPSG installer was using SMALLINT instead than DATE, because scripts before EPSG 9.0 were
+ * reporting only the epoch year.
+ */
+ final CharSequence[] fields = CharSequences.split(epoch, '-');
+ int year = 0, month = 0, day = 1;
+ for (int i = Math.min(fields.length, 3); --i >= 0;) {
+ final int f = Integer.parseInt(fields[i].toString());
+ switch (i) {
+ case 0: year = f; break;
+ case 1: month = f-1; break;
+ case 2: day = f; break;
+ }
+ }
+ if (year != 0) {
+ final Calendar calendar = getCalendar();
+ calendar.set(year, month, day);
+ properties.put(Datum.REALIZATION_EPOCH_KEY, calendar.getTime());
+ }
} catch (NumberFormatException exception) {
unexpectedException("createDatum", exception); // Not a fatal error.
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1795064&r1=1795063&r2=1795064&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] Sat May 13 14:05:43 2017
@@ -42,7 +42,8 @@ import static org.apache.sis.internal.ut
/**
* Runs the SQL scripts for creating an EPSG database.
*
- * See {@code EPSGDataFormatter} in the test directory for more information about how the scripts are formatted.
+ * See {@code org.apache.sis.referencing.factory.sql.epsg.DataScriptFormatter}
+ * in the test directory for more information about how the scripts are formatted.
*
* @author Martin Desruisseaux (Geomatys)
* @version 0.8
Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSG_README.txt
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSG_README.txt?rev=1795064&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSG_README.txt (added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSG_README.txt [UTF-8] Sat May 13 14:05:43 2017
@@ -0,0 +1,7 @@
+Do not create an "epsg" sub-package (except for test or maintainance tasks only)
+because the "org.apache.sis.referencing.factory.sql.epsg" package name is owned
+by the "org.apache.sis.non-free:sis-epsg" module and we should not put anything
+in a package owned by another module.
+
+We make this separation for licensing reason since the EPSG geodetic dataset is
+subject to different terms of use than Apache 2 license.
Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSG_README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSG_README.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatter.java (from r1795063, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatter.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatter.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java&r1=1795063&r2=1795064&rev=1795064&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatter.java [UTF-8] Sat May 13 14:05:43 2017
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.referencing.factory.sql;
+package org.apache.sis.referencing.factory.sql.epsg;
import java.util.Map;
import java.util.HashMap;
@@ -42,81 +42,15 @@ import org.apache.sis.internal.metadata.
/**
* Rewrites the {@code INSERT TO ...} statements in a SQL script in a more compact form.
* This class is used only for updating the SQL scripts used by Apache SIS for the EPSG
- * dataset when a newer release of the EPSG dataset is available. Steps to follow:
- *
- * <ol class="verbose">
- * <li><p>Download the latest SQL scripts for PostgreSQL from <a href="http://www.epsg.org">http://www.epsg.org</a>.</p></li>
- * <li><p>Unzip in the directory of your choice (replace "8_9" by the appropriate version number in the ZIP filename),
- * and remember the path to that directory:</p>
- *
- * {@preformat text
- * unzip epsg-v8_9sql-PostgreSQL.zip
- * cd epsg-v8_9sql-PostgreSQL
- * export EPSG_SCRIPTS=$PWD
- * }
- * </li>
- *
- * <li><p>Move to the directory which contains the Apache SIS scripts:</p>
- *
- * {@preformat text
- * cd <SIS_HOME>/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/
- * }
- * </li>
- *
- * <li><p>Overwrite {@code Tables.sql} and {@code FKeys.sql} with the new SQL scripts
- * (replace "8.8" by the appropriate version number in the commands show below).
- * Do not overwrite {@code Data.sql} and {@code Indexes.sql}:</p>
- *
- * {@preformat text
- * cp $EPSG_SCRIPTS/EPSG_v8_8.mdb_Tables_PostgreSQL.sql Tables.sql
- * cp $EPSG_SCRIPTS/EPSG_v8_8.mdb_FKeys_PostgreSQL.sql FKeys.sql
- * }
- * </li>
- *
- * <li><p>Open the {@code Tables.sql} file for edition:</p>
- * <ul>
- * <li>Keep the header comments that existed in the overwritten file.</li>
- * <li>In the statement creating the {@code coordinateaxis} table,
- * add the {@code NOT NULL} constraint to the {@code coord_axis_code} column.</li>
- * <li>In the statement creating the {@code change} table,
- * remove the {@code UNIQUE} constraint on the {@code change_id} column
- * and add a {@code CONSTRAINT pk_change PRIMARY KEY (change_id)} line instead.</li>
- * <li>In the statement creating the {@code epsg_datum} table,
- * change the type of the {@code realization_epoch} column to {@code SMALLINT}.</li>
- * <li>Change the type of {@code ellipsoid_shape}, {@code reverse_op}, {@code param_sign_reversal}
- * {@code show_crs}, {@code show_operation} and all {@code deprecated} fields from {@code SMALLINT}
- * (or sometime {@code VARCHAR(3)}) to {@code BOOLEAN}.</li>
- * <li>Change the type of every {@code table_name} columns from {@code VARCHAR(80)} to {@code epsg_table_name}.</li>
- * <li>Change the type of {@code coord_ref_sys_kind} column from {@code VARCHAR(24)} to {@code epsg_crs_kind}.</li>
- * <li>Change the type of {@code coord_sys_type} column from {@code VARCHAR(24)} to {@code epsg_cs_kind}.</li>
- * <li>Change the type of {@code datum_type} column from {@code VARCHAR(24)} to {@code epsg_datum_kind}.</li>
- * <li>Suppress trailing spaces and save.</li>
- * </ul>
- * <p>Usually this results in no change at all compared to the previous script (ignoring white spaces),
- * in which case the maintainer can just revert the changes in order to preserve the formatting.</p>
- * </li>
- *
- * <li><p>Open the {@code FKeys.sql} file for edition:</p>
- * <ul>
- * <li>At the end of all {@code ALTER TABLE} statement,
- * append {@code ON UPDATE RESTRICT ON DELETE RESTRICT}.</li>
- * <li>suppress trailing spaces and save.</li>
- * </ul>
- * <p>In most cases this results in unmodified {@code FKeys.sql} file compared to the previous version.</p>
- * </li>
- *
- * <li><p>Run the {@code main} method of this class.</p></li>
- *
- * <li><p>Upgrade the {@code FACTORY.VERSION} value defined in the
- * {@code org.apache.sis.referencing.report.CoordinateReferenceSystems} class.</p></li>
- * </ol>
+ * dataset when a newer release of the EPSG dataset is available.
+ * The steps to follow are documented in the {@code package.html} file.
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @version 0.8
* @since 0.7
* @module
*/
-public final class EPSGDataFormatter extends ScriptRunner {
+public final class DataScriptFormatter extends ScriptRunner {
/**
* Compacts the {@code Data.sql} file provided by EPSG. This method expects two arguments.
* The first argument is the file of the SQL script to read, which must exist.
@@ -140,7 +74,7 @@ public final class EPSGDataFormatter ext
}
final DataSource ds = TestDatabase.create("dummy");
try (Connection c = ds.getConnection()) {
- final EPSGDataFormatter f = new EPSGDataFormatter(c);
+ final DataScriptFormatter f = new DataScriptFormatter(c);
f.run(new File(arguments[0]), new File(arguments[1]));
} finally {
TestDatabase.drop(ds);
@@ -169,11 +103,6 @@ public final class EPSGDataFormatter ext
private String insertStatement;
/**
- * {@code true} if insertions are currently done in the datum table.
- */
- private boolean insertDatum;
-
- /**
* Index (in reversal order) of columns to change from type SMALLINT to type BOOLEAN.
* Index 0 is the last columns, index 1 is the column before the last, <i>etc</i>.
* We use the reverse order because most boolean columns in the EPSG dataset are last.
@@ -191,7 +120,7 @@ public final class EPSGDataFormatter ext
* @param c a dummy connection. Will be used for fetching metadata.
* @throws SQLException if an error occurred while fetching metadata.
*/
- private EPSGDataFormatter(final Connection c) throws SQLException {
+ private DataScriptFormatter(final Connection c) throws SQLException {
super(c, Integer.MAX_VALUE);
final Map<String,int[]> m = new HashMap<>();
m.put("epsg_alias", new int[] { });
@@ -225,7 +154,7 @@ public final class EPSGDataFormatter ext
* @return {@code true} if the line should be omitted.
*/
private static boolean omit(final String line) {
- // We omit the following line because we changed the type from VARCHAR to SMALLINT.
+ // We omit the following line because we changed the type from VARCHAR to DATE.
return line.startsWith("UPDATE epsg_datum SET realization_epoch = replace(realization_epoch, CHR(182), CHR(10))");
}
@@ -248,7 +177,7 @@ public final class EPSGDataFormatter ext
"--- See http://www.epsg.org/TermsOfUse (a copy is in ./LICENSE.txt).\n" +
"---\n" +
"--- This file has been reformatted (without any change in the data) for the needs of Apache SIS project.\n" +
- "--- See org.apache.sis.referencing.factory.sql.EPSGDataFormatter.\n" +
+ "--- See org.apache.sis.referencing.factory.sql.epsg.DataScriptFormatter.\n" +
"---\n" +
"\n");
run(inputFile.getName(), in);
@@ -333,9 +262,6 @@ public final class EPSGDataFormatter ext
line = CharSequences.trimWhitespaces(line, insertStatement.length(), line.length()).toString();
line = replaceIntegerByBoolean(line);
line = removeUselessExponents(line);
- if (insertDatum) {
- line = removeRealizationEpochQuotes(line);
- }
out.append(",\n"); // Really want Unix EOL, not the platform-specific one.
writeValues(line);
return 1;
@@ -351,7 +277,6 @@ public final class EPSGDataFormatter ext
}
final String table = CharSequences.trimWhitespaces(line, INSERT_INTO.length(), valuesStart).toString();
booleanColumnIndices = booleanColumnIndicesForTables.get(table);
- insertDatum = table.equals("epsg_datum");
/*
* We are beginning insertions in a new table.
*/
@@ -360,9 +285,6 @@ public final class EPSGDataFormatter ext
line = CharSequences.trimWhitespaces(line, insertStatement.length(), line.length()).toString();
line = replaceIntegerByBoolean(line);
line = removeUselessExponents(line);
- if (insertDatum) {
- line = removeRealizationEpochQuotes(line);
- }
out.append(insertStatement);
out.append('\n');
writeValues(line);
@@ -478,55 +400,6 @@ public final class EPSGDataFormatter ext
}
/**
- * Removes the quotes in REALIZATION_EPOCH column (i.e. change the type from TEXT to INTEGER).
- * This is the 5th column.
- */
- private static String removeRealizationEpochQuotes(final String line) {
- int index = getIndexForColumn(line, 5);
- if (line.charAt(index) != '\'') {
- return line;
- }
- final StringBuilder cleaned = new StringBuilder(line.substring(0, index));
- if (line.charAt(++index) == '\'') {
- cleaned.append("Null");
- } else do {
- cleaned.append(line.charAt(index));
- }
- while (line.charAt(++index) != '\'');
- cleaned.append(line, index+1, line.length());
- return cleaned.toString();
- }
-
- /**
- * Returns the start index for the given column in the specified {@code VALUES} string.
- * Column numbers start at 1.
- */
- private static int getIndexForColumn(final String line, int column) {
- if (--column == 0) {
- return 0;
- }
- boolean quote = false;
- final int length = line.length();
- for (int index=0; index<length; index++) {
- switch (line.charAt(index)) {
- case '\'': {
- if (index == 0 || line.charAt(index-1) != '\\') {
- quote = !quote;
- }
- break;
- }
- case ',': {
- if (!quote && --column==0) {
- return CharSequences.skipLeadingWhitespaces(line, index+1, length);
- }
- break;
- }
- }
- }
- return length;
- }
-
- /**
* Reformats a multi-line text as a single line text. For each occurrence of line feed
* (the {@code '\n'} character) found in the given buffer, this method performs the following steps:
*
Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatterTest.java (from r1795063, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatterTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatterTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatterTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatterTest.java&r1=1795063&r2=1795064&rev=1795064&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatterTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/DataScriptFormatterTest.java [UTF-8] Sat May 13 14:05:43 2017
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.referencing.factory.sql;
+package org.apache.sis.referencing.factory.sql.epsg;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -23,21 +23,21 @@ import static org.junit.Assert.*;
/**
- * Tests {@link EPSGDataFormatter}.
+ * Tests {@link DataScriptFormatter}.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.7
+ * @version 0.8
* @since 0.7
* @module
*/
-public final strictfp class EPSGDataFormatterTest extends TestCase {
+public final strictfp class DataScriptFormatterTest extends TestCase {
/**
- * Tests the {@link EPSGDataFormatter#removeLF(StringBuilder)} method.
+ * Tests the {@link DataScriptFormatter#removeLF(StringBuilder)} method.
*/
@Test
public void testRemoveLF() {
final StringBuilder buffer = new StringBuilder(" \nOne,\nTwo, \n Three Four\nFive \nSix \n");
- EPSGDataFormatter.removeLF(buffer);
+ DataScriptFormatter.removeLF(buffer);
assertEquals("One,Two,Three Four Five Six", buffer.toString());
}
}
Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html?rev=1795064&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html (added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html [UTF-8] Sat May 13 14:05:43 2017
@@ -0,0 +1,126 @@
+<!DOCTYPE html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+ <head>
+ <title>EPSG dateset update procedure</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <p>
+ The <code>org.apache.sis.referencing.factory.sql.epsg</code> package in the <code>non-free:sis-epsg</code> module
+ provides SQL scripts for installing a local copy of the <a href="http://www.epsg.org/">EPSG geodetic dataset</a>.
+ This dataset provides definitions for thousands of Coordinate Reference Systems (CRS),
+ together with parameter values for thousands of Coordinate Operations between various pairs of CRS.
+ EPSG is maintained by the <a href="http://www.iogp.org/">International Association of Oil and Gas Producers</a> (IOGP)
+ Surveying & Positioning Committee and is subject to <a href="http://www.epsg.org/TermsOfUse">EPSG terms of use</a>.
+ Because of incompatibilities between EPSG terms of use and Apache 2 license, the EPSG geodetic dataset is not distributed
+ by default with Apache SIS. A copy of the dataset is provided in a separated module in a separated source code repository.
+ The Maven identifier of that module is <code>org.apache.sis.non-free:sis-epsg</code> and the source repository is located at
+ <a href="http://svn.apache.org/repos/asf/sis/data/non-free/sis-epsg">http://svn.apache.org/repos/asf/sis/data/non-free/sis-epsg</a>.
+ The EPSG scripts are copied in that module with identical content, but in a more compact format.
+ </p>
+
+ <p>
+ This <code>org.apache.sis.referencing.factory.sql.epsg</code> package in <code>core:sis-referencing</code> module
+ contains only tools for maintaining the <code>non-free:sis-epsg</code> module.
+ This package is provided only in the <strong>test</strong> directory, not in the main directory, because the
+ <code>org.apache.sis.referencing.factory.sql.epsg</code> package name is reserved by the <code>non-free:sis-epsg</code> module.
+ The <code>core:sis-referencing</code> module should not distribute anything in packages owned by other modules.
+ However it is okay to use those package names in directories that are not part of the distribution, like tests.
+ We put those tools here for easier maintainance when the core of Apache SIS is modified.
+ </p>
+
+ <h3>How to apply EPSG geodetic dataset updates</h3>
+ <p>
+ This page explains how to convert the SQL scripts published by EPSG into the more compact form used by Apache SIS.
+ This conversion applies only to the data types, the integrity constraints and the way the SQL scripts are written.
+ No data value should be altered. Steps to follow:
+ </p>
+ <ol>
+ <li><p>Download the latest SQL scripts for PostgreSQL from <a href="http://www.epsg.org">http://www.epsg.org</a>.</p></li>
+
+ <li><p>Unzip in the directory of your choice (replace "9_0" by the appropriate version number in the ZIP filename),
+ and remember the path to that directory:</p>
+
+ <pre>unzip epsg-v9_0sql-PostgreSQL.zip
+cd epsg-v9_0sql-PostgreSQL
+export EPSG_SCRIPTS=$PWD</pre>
+ </li>
+
+ <li><p>If a copy of the original SQL scripts (as downloaded from EPSG) for the previous version is still available,
+ and if the following commands report no difference, then jump to step 4.</p>
+
+ <pre>diff EPSG_v9_0.mdb_Tables_PostgreSQL.sql EPSG_v8_9.mdb_Tables_PostgreSQL.sql
+diff EPSG_v9_0.mdb_FKeys_PostgreSQL.sql EPSG_v8_9.mdb_FKeys_PostgreSQL.sql</pre>
+
+ <p>Otherwise:</p>
+ <ol>
+ <li><p>Move to the directory which contains the Apache SIS scripts:</p>
+ <pre>cd <SIS_HOME>/non-free/sis-epsg/src/main/resources/org/apache/sis/referencing/factory/sql/epsg/</pre>
+ </li>
+
+ <li><p>Overwrite <code>Tables.sql</code> and <code>FKeys.sql</code> with the new SQL scripts
+ (replace "9_0" by the appropriate version number in the commands show below).
+ Do not overwrite <code>Data.sql</code> and <code>Indexes.sql</code>:</p>
+ <pre>cp $EPSG_SCRIPTS/EPSG_v9_0.mdb_Tables_PostgreSQL.sql Tables.sql
+cp $EPSG_SCRIPTS/EPSG_v9_0.mdb_FKeys_PostgreSQL.sql FKeys.sql</pre>
+ </li>
+
+ <li><p>Open the <code>Tables.sql</code> file for edition:</p>
+ <ul>
+ <li>Keep the header comments that existed in the overwritten file.</li>
+ <li>In the statement creating the <code>coordinateaxis</code> table,
+ add the <code>NOT NULL</code> constraint to the <code>coord_axis_code</code> column.</li>
+ <li>In the statement creating the <code>change</code> table,
+ remove the <code>UNIQUE</code> constraint on the <code>change_id</code> column
+ and add a <code>CONSTRAINT pk_change PRIMARY KEY (change_id)</code> line instead.</li>
+ <li>In the statement creating the <code>epsg_datum</code> table,
+ change the type of the <code>realization_epoch</code> column to <code>DATE</code>.</li>
+ <li>Change the type of <code>ellipsoid_shape</code>, <code>reverse_op</code>, <code>param_sign_reversal</code>
+ <code>show_crs</code>, <code>show_operation</code> and all <code>deprecated</code> fields from <code>SMALLINT</code>
+ (or sometime <code>VARCHAR(3)</code>) to <code>BOOLEAN</code>.</li>
+ <li>Change the type of every <code>table_name</code> columns from <code>VARCHAR(80)</code> to <code>epsg_table_name</code>.</li>
+ <li>Change the type of <code>coord_ref_sys_kind</code> column from <code>VARCHAR(24)</code> to <code>epsg_crs_kind</code>.</li>
+ <li>Change the type of <code>coord_sys_type</code> column from <code>VARCHAR(24)</code> to <code>epsg_cs_kind</code>.</li>
+ <li>Change the type of <code>datum_type</code> column from <code>VARCHAR(24)</code> to <code>epsg_datum_kind</code>.</li>
+ <li>Suppress trailing spaces and save.</li>
+ </ul>
+ <p>Usually this results in no change at all compared to the previous script (ignoring white spaces),
+ in which case the maintainer can just revert the changes in order to preserve the formatting.</p>
+ </li>
+
+ <li><p>Open the <code>FKeys.sql</code> file for edition:</p>
+ <ul>
+ <li>At the end of all <code>ALTER TABLE</code> statement,
+ append <code>ON UPDATE RESTRICT ON DELETE RESTRICT</code>.</li>
+ <li>suppress trailing spaces and save.</li>
+ </ul>
+ <p>In most cases this results in unmodified <code>FKeys.sql</code> file compared to the previous version.</p>
+ </li>
+ </ol>
+ </li>
+
+ <li><p>Open the <code>org.apache.sis.referencing.factory.sql.epsg.DataScriptFormatter</code> class
+ located in the test directory of the <code>sis-referencing</code> module
+ and run the <code>main</code> method of that class.</p></li>
+
+ <li><p>Upgrade the <code>FACTORY.VERSION</code> value defined in the
+ <code>org.apache.sis.referencing.report.CoordinateReferenceSystems</code> class.</p></li>
+ </ol>
+ </body>
+</html>
Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html;charset=UTF-8
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1795064&r1=1795063&r2=1795064&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Sat May 13 14:05:43 2017
@@ -214,7 +214,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.factory.MultiAuthoritiesFactoryTest.class,
org.apache.sis.referencing.factory.sql.EPSGFactoryTest.class,
org.apache.sis.referencing.factory.sql.EPSGInstallerTest.class,
- org.apache.sis.referencing.factory.sql.EPSGDataFormatterTest.class,
+ org.apache.sis.referencing.factory.sql.epsg.DataScriptFormatterTest.class,
org.apache.sis.referencing.EPSGFactoryFallbackTest.class,
org.apache.sis.referencing.AuthorityFactoriesTest.class,
org.apache.sis.referencing.cs.CodesTest.class,