Referenced Envelope swaps x-values with y-values after a few calls to the class
using it
----------------------------------------------------------------------------------------
Key: GEOT-1722
URL: http://jira.codehaus.org/browse/GEOT-1722
Project: GeoTools
Issue Type: Bug
Components: core referencing
Environment: Windows and Linux
Reporter: Ashraf Memon
Assignee: Martin Desruisseaux
Priority: Critical
I have created a jsp with the following code
<%@ page import="
java.text.DecimalFormat,
org.geotools.geometry.jts.JTS,
org.geotools.referencing.CRS,
org.opengis.referencing.crs.CoordinateReferenceSystem,
org.opengis.referencing.operation.MathTransform,
org.geotools.geometry.jts.ReferencedEnvelope
"
%>
<%
double minx = Double.parseDouble(request.getParameter("minx"));
double miny = Double.parseDouble(request.getParameter("miny"));
double maxx = Double.parseDouble(request.getParameter("maxx"));
double maxy = Double.parseDouble(request.getParameter("maxy"));
String inEPSG = request.getParameter("inEPSG");
String outEPSG = request.getParameter("outEPSG");
CoordinateReferenceSystem sourceCRS;
CoordinateReferenceSystem targetCRS;
String pCoordinates=null;
try {
sourceCRS = CRS.decode("EPSG:" + inEPSG);
targetCRS = CRS.decode("EPSG:" + outEPSG);
ReferencedEnvelope envelope = new ReferencedEnvelope(miny,
maxy, minx, maxx,sourceCRS);
MathTransform transform = CRS.findMathTransform(sourceCRS,
targetCRS);
ReferencedEnvelope result = envelope.transform(targetCRS,true);
DecimalFormat df = new DecimalFormat("##.####");
pCoordinates = df.format(result.getMinX()) + ","
+ df.format(result.getMinY()) +
"," + df.format(result.getMaxX())
+ "," +
df.format(result.getMaxY());
} catch (Exception e) {
out.println(pCoordinates);
}
out.println(pCoordinates);
%>
This code works when I deploy it and restart the server and It works fine for a
few days and then starts giving in correct results for the projections. Careful
analysis and debugging hinted that the ReferencedEnvelope swaps the values of
minx,maxx with miny,maxy. For example this code works fine for a few days
ReferencedEnvelope envelope = new ReferencedEnvelope(minx, maxx,miny, maxy,
sourceCRS);
and then after a few days the above code gives incorrect results and this new
code yields same result
ReferencedEnvelope envelope = new ReferencedEnvelope(minx, maxx,miny, maxy,
sourceCRS);
I know this sounds weird but I have spent 2 weeks with different things, but
nothing works. Please help.
Thanks,
Ashraf
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel