Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to convert dd.dddddd to ddmm.mmmm/dddmm.mmmm




User Enters Lat Long in below format (dd.dddddd):
Latitude 19.025352
Longitude 72.099148
on GUI but My Other Application Accepts only
Dec Mins (ddmm.mmmm dddmm.mmmm)
1901.52112, 07205.94888 ( or 19°01.52112', 072°05.94888')

I need a logic to Convert the same for destination system.
Posted
Updated 8-Jan-13 0:45am
v2
Comments
ridoy 8-Jan-13 6:13am    
Your question isn't understandable until you explain briefly what your problem is,what do you want to do and what is your code to do that?
Singh Vijay Kumar 8-Jan-13 7:16am    
User Enters Lat Long in below format (dd.dddddd):
Latitude 19.025352
Longitude 72.099148
on GUI but My Other Application Accepts only
Dec Mins (ddmm.mmmm dddmm.mmmm)
1901.52112, 07205.94888 ( or 19°01.52112', 072°05.94888')

I need a logic to Convert the same for destination system
Bernhard Hiller 9-Jan-13 2:42am    
Before you started that project, you actually ought to learn some basics on geography! Learn that a degree has 60 minutes, and a minute has 60 seconds. And learn the different methods for showing direction (North, East, South, West). And maybe some projections...
Now you write code which might work but you do not understand it.
Singh Vijay Kumar 9-Jan-13 3:11am    
I only dont know conversion rest basic things i know very well

1 solution

I don't know hat your ddmm.mmmm format is, especially , but check this:

C#
string ConvertDoubleToSpecial(double coord)
	{
		int deg = (int)coord;
		double min = (coord - (int)coord)*60.0;
		return String.Format("{0}*{1:00.00000}'", deg, Math.Abs(min));
	}
 
Share this answer
 
v4
Comments
Zoltán Zörgő 8-Jan-13 6:52am    
Why the downvote? It is doing exactly what the OP requested for.
Singh Vijay Kumar 8-Jan-13 7:51am    
Its Not Working in Required Format well thanks for support.
Zoltán Zörgő 8-Jan-13 8:41am    
See update
Singh Vijay Kumar 9-Jan-13 0:01am    
Its failing for negative coordinates like -180.xxxx its output is -180-5.xxxxxx
Please Check since i am new to lat long.
Zoltán Zörgő 9-Jan-13 1:47am    
Well, can't you change as little as this one? See update...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900