Click here to Skip to main content
12,254,527 members (66,868 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# General
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 8-Jan-13 0:06am
Edited 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?
vijayksingh 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.
vijayksingh 9-Jan-13 3:11am
   
I only dont know conversion rest basic things i know very well

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

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));
	}
  Permalink  
v4
Comments
Zoltán Zörgő 8-Jan-13 6:52am
   
Why the downvote? It is doing exactly what the OP requested for.
vijayksingh 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
vijayksingh 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...
vijayksingh 10-Jan-13 0:58am
   
I could have done but i thought - sign may have impact on other values.
Well Thanks for support.
lukeer 10-Apr-13 3:26am
   
Have a 5 for extra patience.
Zoltán Zörgő 10-Apr-13 3:42am
   
Thank you :)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100