Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] [jira] Created: (UDIG-1513) error in cursorPosition code

error in cursorPosition code
----------------------------

                 Key: UDIG-1513
                 URL: http://jira.codehaus.org/browse/UDIG-1513
             Project: uDIG
          Issue Type: Bug
          Components: application
    Affects Versions: UDIG 1.2.M3, UDIG 1.2.M2, UDIG 1.1.1, UDIG 1.1.0
         Environment: XP, jre1.6.0_07_win32_gdal, Eclipse Ganymede.
            Reporter: rahul kumar
            Priority: Blocker


There is error in cursorPosition code. Whenever the world co-ordinate is in the exponential form (say 3.3100324202343583E7), the data displayed in the text field is not correct. It is because 3.3100324202343583E7 is being treated as 3.310032420234358 and not 33100324.20234358. My suggestion is that you just need to convert the double in exponential from to decimal form.


Problem is in function: 


private String getString(double value) {
            if (Double.isNaN(value) ){
                return Messages.CursorPosition_not_a_number;
            }
            
            if( Double.isInfinite(value) ){
                return Messages.CursorPosition_infinity;
            }
            
			String string = String.valueOf(value);
			string+="00"; //$NON-NLS-1$
            
//          calculate number of digits to display based on zoom level
            Coordinate coordFactor = getContext().getPixelSize();
            double inverse = (double)1 / coordFactor.x;
            String strFactor = String.valueOf(inverse);
            int factor = strFactor.lastIndexOf('.');

      int end=Math.max(1, Math.min(string.lastIndexOf('.') + factor, string.length() - 1));  //// This line generates the wrong end.
            string = string.substring(0, end); 
            
            if( string.endsWith(".") ){ //$NON-NLS-1$
                string=string.substring(0,string.length()-1);
            }
            
			return string;
		}

-- 
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

        


Back to the top