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 2016/01/29 23:19:43 UTC
svn commit: r1727656 - in /sis/branches/JDK8/core/sis-referencing/src:
main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
Author: desruisseaux
Date: Fri Jan 29 22:19:43 2016
New Revision: 1727656
URL: http://svn.apache.org/viewvc?rev=1727656&view=rev
Log:
Fix the reporting of deprecated CRS definitions.
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/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.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=1727656&r1=1727655&r2=1727656&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] Fri Jan 29 22:19:43 2016
@@ -1029,6 +1029,7 @@ addURIs: for (int i=0; ; i++) {
final ImmutableIdentifier identifier;
if (deprecated) {
identifier = new DeprecatedCode(authority, Constants.EPSG, codeString, version, getSupersession(table, code, locale));
+ properties.put(AbstractIdentifiedObject.DEPRECATED_KEY, Boolean.TRUE);
} else {
identifier = new ImmutableIdentifier(authority, Constants.EPSG, codeString, version,
(gn != null) ? gn.toInternationalString() : null);
@@ -2558,6 +2559,7 @@ addURIs: for (int i=0; ; i++) {
* However, this default number of dimensions is not generalizable to other kind of operation methods.
* For example the "Geocentric translation" operation method has 3-dimensional source and target CRS.
*/
+ boolean isDimensionKnown = true;
final int sourceDimensions, targetDimensions;
final CoordinateReferenceSystem sourceCRS, targetCRS;
if (sourceCode != null) {
@@ -2566,6 +2568,7 @@ addURIs: for (int i=0; ; i++) {
} else {
sourceCRS = null;
sourceDimensions = 2; // Acceptable default for projections only.
+ isDimensionKnown = false;
}
if (targetCode != null) {
targetCRS = parent.createCoordinateReferenceSystem(targetCode);
@@ -2573,6 +2576,7 @@ addURIs: for (int i=0; ; i++) {
} else {
targetCRS = null;
targetDimensions = 2; // Acceptable default for projections only.
+ isDimensionKnown = false;
}
/*
* Get the operation method. This is mandatory for conversions and transformations
@@ -2586,7 +2590,9 @@ addURIs: for (int i=0; ; i++) {
parameters = null;
} else {
method = parent.createOperationMethod(methodCode.toString());
- method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions);
+ if (isDimensionKnown) {
+ method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions);
+ }
parameters = method.getParameters().createValue();
fillParameterValues(methodCode, epsg, parameters);
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java?rev=1727656&r1=1727655&r2=1727656&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] Fri Jan 29 22:19:43 2016
@@ -20,6 +20,7 @@ import java.util.Locale;
import java.io.File;
import java.io.IOException;
+import org.opengis.metadata.Identifier;
import org.opengis.util.FactoryException;
import org.opengis.util.InternationalString;
import org.opengis.referencing.IdentifiedObject;
@@ -89,10 +90,6 @@ public strictfp class CoordinateReferenc
"</ul>");
factory = org.apache.sis.referencing.CRS.getAuthorityFactory(null);
add(factory);
- /*
- * We have to use this hack for now because exceptions are formatted in the current locale.
- */
- Locale.setDefault(getLocale());
}
/**
@@ -118,6 +115,7 @@ public strictfp class CoordinateReferenc
*/
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public static void main(final String[] args) throws FactoryException, IOException {
+ Locale.setDefault(Locale.US); // We have to use this hack for now because exceptions are formatted in the current locale.
final CoordinateReferenceSystems writer = new CoordinateReferenceSystems();
final File file = writer.write(new File("CoordinateReferenceSystems.html"));
System.out.println("Created " + file.getAbsolutePath());
@@ -188,25 +186,16 @@ public strictfp class CoordinateReferenc
* Don't take the whole comment, because it may be pretty long.
*/
if (row.isDeprecated) {
- final InternationalString i18n = object.getRemarks();
- if (i18n != null) {
- String remark = i18n.toString(getLocale());
- final int s = Math.max(remark.lastIndexOf("Superseded"),
- Math.max(remark.lastIndexOf("superseded"),
- Math.max(remark.lastIndexOf("Replaced"),
- Math.max(remark.lastIndexOf("replaced"),
- Math.max(remark.lastIndexOf("See"),
- remark.lastIndexOf("see"))))));
- if (s >= 0) {
- final int start = remark.lastIndexOf('.', s) + 1;
- final int end = remark.indexOf('.', s);
- remark = (end >= 0) ? remark.substring(start, end) : remark.substring(start);
- remark = CharSequences.trimWhitespaces(remark.replace('ΒΆ', '\n').trim());
- if (!remark.isEmpty()) {
- row.remark = remark;
- }
+ InternationalString i18n = object.getRemarks();
+ for (final Identifier id : object.getIdentifiers()) {
+ if (id instanceof Deprecable && ((Deprecable) id).isDeprecated()) {
+ i18n = ((Deprecable) id).getRemarks();
+ break;
}
}
+ if (i18n != null) {
+ row.remark = i18n.toString(getLocale());
+ }
}
return row;
}