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 to inches

Status
Not open for further replies.

DeeDee

Programmer
Jul 13, 2000
34
US
I have a 2D map which the user clicks on that has the waypoints set in latitude/longitude. There is a program that has the 3D version of the map that waypoints are set in inches. I need to convert the lat/long of the 2D map to inches to import the waypoints into the 3D. Does anybody know a way I can do this (if it makes sense!!)? Thanks in advance for any help!!
 
Yes, it makes sense.

Its possible that you can do a rough transformation assuming a linear relationship at least within the grid that your doing the coordination transformation. Error will be introduced, and the amount of error will be based on the size of the transformation grid.

The first question is where on the 2D map do the waypoints appear, and how is the lat/long information stored for those waypoints? Similarly, when and how is the inch information represented on the 3D map? And are the waypoints mapped to each other. In other words, for each lat/long waypoint on the the 2D map is there a correspondong waypoint in inches on the 3D map?

Also, when the 2D mapped is clicked, how do you know the location where the click occurred, and what is the basis point for the click coordinates? Do you have the location in the click coordinates of any of the waypoints on the 2D map?

There are several different approaches, and the answers to these question will hopefully provide some indication of what would be the most efficient approach. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
You need to know which projection the map is draw in.
The simplest is a latitude-longitude plot (but it is rarely used because the distortion for high latitudes is large). If you know which projection is used, I might be able to help you.

Solution for the lat-lon projection:
**************
Dim MaxX As Integer, MaxY As Integer, MinX As Integer, MinY As Integer 'the pixel coordinates of the map
Dim alon As Single, alat As Single, blat As Single, blon As Single 'the geographic coordinates of the map

'set the 8 parameter to their respective values here...

'The solution is 2 linear equations, calculate the coefficients:
alon = (MinX - MaxX) / (MinLon - MaxLon)
blon = MaxX - alon * MaxLon


'Calculate lon from coordinate
Public Function GetLon(X As Single) As Single
GetLon = (X - blon) / alon
End Function

'Calculate lat from coordinate
Public Function GetLat(Y As Single) As Single
GetLat = (Y - blat) / alat
End Function
************

[sup]
ps. The Mars Polar Lander (a several 100 million dollar project) crashed on mars december 3, 1999 because s flight engineer had given the altitude in feet and not in meters (NASA has clearly defined that all numbers must be given in the SI system). That just came to mind when I saw 'waypoints' and 'inches' in the same sentence...[/sup]
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
The scaletop, scaleleft, scalewidth, scaleheight of the picturebox are set according to the 2D map's lat/lon. This code is in the Picture1_MouseDown event: Picture1.PSet (x, y). That is where the waypoint on the 2D map is coming from. I guess what I'm trying to accomplish is the answer to this question.........for each lat/long waypoint on the the 2D map is there a correspondong waypoint in inches on the 3D map? Does that make any sense????!!! Sorry if I'm not explaining myself very well.

 
What you can try is a linear map between the two.

Looking at the 2D map. You have the X coordinate (LX) of the left edge, and the X coordinate of the right edge (RX). When they click, based on the mouse location of the click (MX), how far in percentage the click occurred moving from the left edge to the right.

LocPerc = (MX - LX) / (RX - LX)

Now go to the 3D map, and use that same percentage to determine where the same relative location occurs in the 3D map, using the corresponding 3D points that are consistent with the 2D left and right borders.

Apply the same procedure for the Y Coordinate.

Note, this is a linear mapping and there will be some error. The smaller (less actual distance from left border to right border) the maps, the less the error.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
The 2D map gives the coordinates of a point the user has clicked on, but, I need an offset in inches. I have the coordinates (Lat/Long) for the corners of the 2D map:

NW - 35~30'00'' N
117~0'00'' W

NE - 35~30'0'' N
116~30'00'' W

SW - 35~0'00'' N
117~0'00'' W

SE - 35~0'00'' N
116~30'00'' W



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top