On Thursday, October 11, 2012 7:53:22 PM UTC+2, Lew wrote:
>
> Karl Kristian Markman wrote:
>
>> So here is the code I use to transform the Lat long to UTM ( in case
>> anyone else wouders..)
>>
>> [code]
>>
>> public void convert (){
>>
>> double a = 6378137;
>>
>
> Strictly speaking, you should use a double constant to initialize a double
> variable.
> Fortunately Java does the conversion for you.
>
>
>> double b = 6356752.3142;
>>
>> e = Math.sqrt(1-Math.pow(b,2)/Math.pow(a, 2)); // a and
>> b are constants.
>>
>
> 'a' and 'b' are not constants in the Java sense unless they're declared
> 'final'.
>
> 'Math.pow()' for squares, really? Why?
>
>
>> e2 = e*e/(1-(e*e));
>>
>
> Yet here you use the multiplication idiom for squares. Why the difference?
>
>
>> n =(a-b)/(a+b);
>> A0 = a*(1 - n + (5/4)*(Math.pow(n,2) - Math.pow(n,3)) +
>> (81/64)*(Math.pow(n,4) - Math.pow(n,5)));
>> B0 =(3*a*n/2)*(1 - n - (7*n*n/8)*(1-n) + (55/64)*(Math.pow(n,
>> 4)-Math.pow(n, 5)));
>> C0 =(15*a*n*n/16)*(1 - n +(3*n*n/4)*(1-n));
>> D0 =(35*a*Math.pow(n, 3)/48)*(1 - n + 11*n*n/16);
>> E0 =(315*a*Math.pow(n,4)/51)*(1-n);
>> zone = (int) (31 + (lngdeg/6));
>> double pi = 6* zone -183;
>> double pii = (lngdeg-pi)*Math.PI/180;
>> double rho1 = (1-(e*e) * (Math.sin(lat)*( Math.sin(lat))));
>> rho = a * (1-e*e)/ Math.pow(rho1, (3/2));
>> nu = a/(Math.pow((1-(e*e *(Math.sin(lat))*(Math.sin(lat)))), (1/2)));
>> S = A0* lat - B0 * Math.sin(2*lat) + C0 * Math.sin(4*lat) - D0 *
>> Math.sin(6*lat) + E0 * Math.sin(8*lat);
>> double Ki = S * knu;
>> double Kii = knu * nu *Math.sin(lat)*Math.cos(lat)/2;
>> double Kiii = (knu * nu
>> *Math.sin(lat)*Math.pow(Math.cos(lat),3)/24)*(5-Math.pow(Math.tan(lat),2)+9*Math.pow(e2,2)*Math.pow(Math.cos(lat),2)+4*Math.pow(e2
>>
>> ,2)*Math.pow(Math.cos(lat),4));
>> double Kiv = knu * nu *Math.cos(lat);
>> double Kv = knu *
>> Math.pow(Math.cos(lat),3)*(nu/6)*(1-Math.pow(Math.tan(lat),2)+e2*Math.pow(Math.cos(lat),2));
>>
>> double UTMni = (Ki+Kii*Math.pow(pii, 2)+ Kiii * Math.pow(pii,4));
>> double UTMei = 500000 + (Kiv*pii + Kv * Math.pow(pii, 3));
>> UTMn = (int) UTMni;
>> UTMe = (int) UTMei;
>> }
>> [/code]
>>
>
> OMFG, dude! You are just all over the place with this. Variables out of
> nowhere,
> terse obscure names, varying idioms for the same kinds of calculations,
> utter
> lack of comments or whitespace, except for the exorbitant indentation,
> variable names
> that imply different values, and the one and only comment you include
> tells nothing
> except for a falsehood that isn't relevant anyway, and would have been
> self-explanatory
> in code if the variables had been constants.
>
> I gather this code is meant neither to be re-used, shared nor maintained.
>
> --
> Lew
>
Have you see the formulas for converting Lew?
Yes i agree I have not been good with comments. If its any constalation I
will update the code mow that its working....
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en