Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lat/Long format 1

Status
Not open for further replies.

korytnackaruzova

Technical User
Apr 5, 2016
18
US
I need the Lat and Long where it is a 2 digit whole number then decimal and the rest of the numbers. I know there is a term for this type of lat/long format, but I couldn't remember it. Currently Lat Long comes from the database as one number, for example 12345678 and I need that to be 12.345678 for longtitude it is 12345678 and I need that to be -12.345678

Any help would be very much appreciated!
 
You might have no decimal point, as the number is stored as integer. That has an advantage: It is exact.
To get decimals divide by 100. To get negative instead of positive, multiply by -1. It's not hard at all.
If you have strings VAL(field) will turn that to a number.

If you want a query to do what you need, please specify in more detail what you have at hand, name of dbfs, fields, types of fields would help write code you might simply use as given.

Bye, Olaf.

 
Thank you! This is actually going to work.. I just write a formula:
Latitude: =C2/1000000
Longitude: =-(C2/1000000)

It's so simple.. Why didn't I think about that? :) Thank you again!
 
miskacherry said:
I know there is a term for this type of lat/long format, but I couldn't remember it
I don't know, there is no specific geographic coordinate type in Visual FoxPro. So two numbers with latitude/longitude are describing what you can have in VFP anyway. All calculations done on such coordinates have no specific type and operators and will need to be done with basic math, but that shouldn't be a problem, you'll find formulas, eg for determining distances and even better, there are map services in the web to do routing. So - no need to worry about that aspect(s).

Bye, Olaf.
 
Please remember that a negative latitude and a positive longitude is possible, so to assume that the longitude is negative would be wrong.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Also keep in mind that while latitude values can never be more than +90 to -90, longitude can range from +180 to -180 across the globe. Perhaps that isn't a huge consideration where you are located but someday someone may try to enter values in that higher range. So best to program everything now to anticipate such usage. Therefore make sure your strings are large enough for that potential extra digit. Same for table fields (storage) and screen sizes (display) as well as indexes and filters (program logic).
 
Maybe the one numeric value you have there has to be split to two coordinates.
Coordiniates with lat=-long are only along a certain line (just like y=x or y=-x would just be valid for points on a certain quadrant halfing lines in the cartesian coordinates space).

To identify which parts of a number would belong to longitute or latitude, it would help to know the location of one such coordniate (eg city/state belonging) to compare against the geographical coordinate range for that region.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top