Lat/Long to String

Lat/Long to String

Sinc
Advisor Advisor
881 Views
6 Replies
Message 1 of 7

Lat/Long to String

Sinc
Advisor
Advisor
Lat/Long seems to be stored as a double. How do I convert this to a string?
Sinc
0 Likes
882 Views
6 Replies
Replies (6)
Message 2 of 7

Sinc
Advisor
Advisor
With some exploration, I think I've figured out enough to convert it to a string "the long way". It looks like a positive value means North or East, while a negative value means South or West. Then there are all those settings and enums in AeccSettingsLatLong, indicating long or short name, etc., that can be used to piece together a string.

Is that the only way to do it?
Sinc
0 Likes
Message 3 of 7

Anonymous
Not applicable
Hi Sinc

Is it feasible that the format parameters may do the trick for you"

Something like:

MyString = Format(MyDouble, "DD-MM-SS")

Things to look for would include a constant offset from the Date parameters.

Regards


Laurie Comerford


dei-feif wrote:
> With some exploration, I think I've figured out enough to convert it to
> a string "the long way". It looks like a positive value means North or
> East, while a negative value means South or West. Then there are all
> those settings and enums in AeccSettingsLatLong, indicating long or
> short name, etc., that can be used to piece together a string.
>
> Is that the only way to do it?
0 Likes
Message 4 of 7

Sinc
Advisor
Advisor
I'm doing the .NET equivalent (Converter.AngleToString) in order to convert the double to an angle. The problem is the rest of the Lat/Long. There are a variety of formatting options - short name prepended, short name appended, long name prepended, short name spaced prepended, capitalization options, etc.



I actually just did it "the hard way", and did all that processing myself. I couldn't find anything in the API that would do it. But I think I have something that works now.



The only real trick seems to be that the double must be converted to an absolute value, because a value of "-30" for Latitude means "South30°", not 330°. And then there's a lot of grunge, of course, to get the rest.



-- Sinc

http://www.ejsurveying.com

http://www.quux.biz

http://www.sincpac3d.com
Sinc
0 Likes
Message 5 of 7

Sinc
Advisor
Advisor
I'm doing the .NET equivalent (Converter.AngleToString) in order to convert the double to an angle. The problem is the rest of the Lat/Long. There are a variety of formatting options - short name prepended, short name appended, long name prepended, short name spaced prepended, capitalization options, etc.



I actually just did it "the hard way", and did all that processing myself. I couldn't find anything in the API that would do it. But I think I have something that works now.



The only real trick seems to be that the double must be converted to an absolute value, because a value of "-30" for Latitude means "South30°", not 330°. And then there's a lot of grunge, of course, to get the rest.



-- Sinc

http://www.ejsurveying.com

http://www.quux.biz

http://www.sincpac3d.com
Sinc
0 Likes
Message 6 of 7

Sinc
Advisor
Advisor
Oh, and of course there's also the problem that the Converter.AngleToString method drops the leading zeros in minutes and seconds, but those are relatively easy to add with a RegEx.



-- Sinc

http://www.ejsurveying.com

http://www.quux.biz

http://www.sincpac3d.com
Sinc
0 Likes
Message 7 of 7

Sinc
Advisor
Advisor
I ran into a couple of other bugs in C3D in this process, as well.



First is that the "Short name suffix" and "Short name suffix spaced" options do not seem to work in C3D. The settings work, and they work for my program, but when I configure C3D to use one of those "Short name suffix" options, I get the long name displayed in C3D instead. This includes all Point Displays, such as in the Details Pane and the Panorama view, as well as tool tips.



The other is that, in the API, the enums contain an entry for "AeccLatLongDirectionType.aeccLatLongDirectionSinged" - it should be "AeccLatLongDirectionType.aeccLatLongDirectionSigned". One of Autodesk's programmers must be either dyslexic or a pyromaniac. 🙂



-- Sinc

http://www.ejsurveying.com

http://www.quux.biz

http://www.sincpac3d.com
Sinc
0 Likes