Author: desruisseaux Date: Tue Aug 8 12:00:10 2017 New Revision: 1804404 URL: http://svn.apache.org/viewvc?rev=1804404&view=rev Log: Format "+towgs84" parameter in Proj.4 string.
Modified: sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java Modified: sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java?rev=1804404&r1=1804403&r2=1804404&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java [UTF-8] Tue Aug 8 12:00:10 2017 @@ -42,7 +42,10 @@ import org.opengis.referencing.operation import org.apache.sis.referencing.operation.AbstractCoordinateOperation; import org.apache.sis.referencing.factory.UnavailableFactoryException; import org.apache.sis.referencing.factory.InvalidGeodeticParameterException; +import org.apache.sis.referencing.datum.DefaultGeodeticDatum; +import org.apache.sis.referencing.datum.BursaWolfParameters; import org.apache.sis.referencing.IdentifiedObjects; +import org.apache.sis.referencing.CommonCRS; import org.apache.sis.referencing.CRS; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.internal.metadata.AxisDirections; @@ -51,6 +54,7 @@ import org.apache.sis.internal.system.OS import org.apache.sis.util.logging.Logging; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.ArgumentChecks; +import org.apache.sis.util.Utilities; import org.apache.sis.util.Static; import org.apache.sis.util.iso.Types; import org.apache.sis.measure.Units; @@ -255,7 +259,23 @@ public final class Proj4 extends Static definition.append("to_meter=").append(Units.toStandardUnit(unit)); } } + /* + * Append the "+towgs84" element if any. This is the last piece of information. + * Note that the use of a "+towgs84" parameter is an "early binding" approach, + * which is usually not recommended. But Proj4 works that way. + */ if (validCS) { + if (datum instanceof DefaultGeodeticDatum) { + for (final BursaWolfParameters bwp : ((DefaultGeodeticDatum) datum).getBursaWolfParameters()) { + if (Utilities.equalsIgnoreMetadata(CommonCRS.WGS84.datum(), bwp.getTargetDatum())) { + definition.append(" +towgs84=").append(bwp.tX).append(',').append(bwp.tY).append(',').append(bwp.tZ); + if (!bwp.isTranslation()) { + definition.append(',').append(bwp.rX).append(',').append(bwp.rY).append(',').append(bwp.rZ).append(',').append(bwp.dS); + } + break; + } + } + } return definition.toString(); } /*