Simone Giannecchini ha scritto:
> Mmmh,
> I do not manage to reproduce the failure for the moment.
Simone, it's the third day in a row I cannot build GeoTools
trunk. Mind if I revert your change? It's this one:
--------------------------------------------------------
Author: simonegiannecchini
Date: 2010-02-14 17:20:29 -0500 (Sun, 14 Feb 2010)
New Revision: 34890
Modified:
trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/WarpTransform2D.java
Log:
trying to achieve more robustness against GEOT-1601
Modified:
trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/WarpTransform2D.java
===================================================================
---
trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/WarpTransform2D.java
2010-02-14 15:39:01 UTC (rev 34889)
+++
trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/WarpTransform2D.java
2010-02-14 22:20:29 UTC (rev 34890)
@@ -19,36 +19,42 @@
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import javax.media.jai.JAI;
import javax.media.jai.Warp;
import javax.media.jai.WarpAffine;
-import javax.media.jai.WarpQuadratic;
import javax.media.jai.WarpCubic;
+import javax.media.jai.WarpGeneralPolynomial;
import javax.media.jai.WarpPolynomial;
-import javax.media.jai.WarpGeneralPolynomial;
+import javax.media.jai.WarpQuadratic;
-import org.opengis.parameter.ParameterValue;
-import org.opengis.parameter.ParameterValueGroup;
+import org.geotools.metadata.iso.citation.Citations;
+import org.geotools.parameter.DefaultParameterDescriptor;
+import org.geotools.parameter.Parameter;
+import org.geotools.parameter.ParameterGroup;
+import org.geotools.referencing.NamedIdentifier;
+import org.geotools.referencing.operation.MathTransformProvider;
+import org.geotools.resources.XArray;
+import org.geotools.resources.i18n.Vocabulary;
+import org.geotools.resources.i18n.VocabularyKeys;
+import org.geotools.util.Utilities;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
+import org.opengis.parameter.ParameterValue;
+import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransform2D;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.opengis.referencing.operation.Transformation;
-import org.geotools.util.Utilities;
-import org.geotools.referencing.NamedIdentifier;
-import org.geotools.referencing.operation.MathTransformProvider;
-import org.geotools.metadata.iso.citation.Citations;
-import org.geotools.parameter.DefaultParameterDescriptor;
-import org.geotools.parameter.ParameterGroup;
-import org.geotools.parameter.Parameter;
-import org.geotools.resources.XArray;
-import org.geotools.resources.i18n.Vocabulary;
-import org.geotools.resources.i18n.VocabularyKeys;
-
/**
* Wraps an arbitrary {...@link Warp} object as a {...@linkplain
MathTransform2D two-dimensional transform}.
* Calls to {...@linkplain #transform(float[],int,float[],int,int)
transform} methods are forwarded to
@@ -84,6 +90,26 @@
* Serial number for interoperability with different versions.
*/
private static final long serialVersionUID = -7949539694656719923L;
+
+ private final static boolean USE_HACK;
+ static{
+ final String buildVersion=JAI.getBuildVersion();
+ final SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd'
'hh:mm:ss.SSSZ");
+ final TimeZone tz= TimeZone.getTimeZone("UTC");
+ df.setTimeZone(tz);
+ boolean hack=false;
+ try {
+ final Date date =
buildVersion!=null?df.parse(buildVersion):new
java.util.Date();
+ final GregorianCalendar version113= new
GregorianCalendar(tz);
+ version113.set(2006, 8, 12, 00, 23, 56);
+ version113.set(Calendar.MILLISECOND, 159);
+
+ hack=!date.after(version113.getTime());
+ } catch (ParseException e) {
+ hack=false;
+ }
+ USE_HACK=hack;
+ }
/**
* The maximal polynomial degree allowed.
@@ -121,7 +147,7 @@
* </table>
*
* @param srcCoords Source coordinates.
- * @param dstCoords Destination coordinates.
+ * @param dstCoords Desination coordinates.
* @param degree The desired degree of the warp polynomials.
*/
public WarpTransform2D(final Point2D[] srcCoords, final Point2D[]
dstCoords, final int degree) {
@@ -218,21 +244,23 @@
* according the scale values, but the 'preScale' and
'postScale' are interchanged.
* When JAI bug will be fixed, delete all the following block
until the next comment.
*/
- final double scaleX = preScaleX / postScaleX;
- final double scaleY = preScaleY / postScaleY;
- if (scaleX!=1 || scaleY!=1) {
- final int n = numCoords*2;
- if (cloneCoords) {
- float[] o;
- o=srcCoords; srcCoords=new float[n];
System.arraycopy(o, srcOffset, srcCoords, 0, n); srcOffset=0;
- o=dstCoords; dstCoords=new float[n];
System.arraycopy(o, dstOffset, dstCoords, 0, n); dstOffset=0;
- }
- for (int i=0; i<n;) {
- srcCoords[srcOffset + i ] /= scaleX;
- dstCoords[dstOffset + i++] *= scaleX;
- srcCoords[srcOffset + i ] /= scaleY;
- dstCoords[dstOffset + i++] *= scaleY;
- }
+ if(USE_HACK){
+ final double scaleX = preScaleX / postScaleX;
+ final double scaleY = preScaleY / postScaleY;
+ if (scaleX!=1 || scaleY!=1) {
+ final int n = numCoords*2;
+ if (cloneCoords) {
+ float[] o;
+ o=srcCoords; srcCoords=new float[n];
System.arraycopy(o, srcOffset, srcCoords, 0, n); srcOffset=0;
+ o=dstCoords; dstCoords=new float[n];
System.arraycopy(o, dstOffset, dstCoords, 0, n); dstOffset=0;
+ }
+ for (int i=0; i<n;) {
+ srcCoords[srcOffset + i ] /= scaleX;
+ dstCoords[dstOffset + i++] *= scaleX;
+ srcCoords[srcOffset + i ] /= scaleY;
+ dstCoords[dstOffset + i++] *= scaleY;
+ }
+ }
}
/*
* Note: Warp semantic (transforms coordinates from
destination to source) is the
----------------------------------------------------------------
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel