Longitude/Latitude to screen coordinates

  • Thread starter Thread starter computerex
  • Start date Start date
  • Tags Tags
    Coordinates Screen
Click For Summary
The discussion revolves around converting longitude and latitude coordinates to screen coordinates for a cylindrical Earth map with a 1:2 ratio. The user seeks guidance on how to accurately plot these coordinates while acknowledging the inherent distortions that occur when mapping a sphere onto a cylinder. Key formulas are provided for calculating horizontal and vertical pixel positions based on the screen dimensions and the specified coordinates. The conversation also touches on the complexities of visualizing data on a 3D sphere and the challenges of maintaining accuracy when wrapping a flat image around a globe. Ultimately, the discussion emphasizes the need for careful mathematical transformations to achieve a realistic representation of geographic data.
  • #31
DrGreg said:
Well it depends what you mean by "2D map" i.e. what projection has been used to generate the map.

If the 2D map simply plots latitude against longitude, as Cartesian coordinates, then there's nothing more to do, the "client engine" will do the necessary conversion, presumably using equations similar to the ones I quoted in my first post in this thread. (Assuming I've understood this correctly.)

If the 2D map uses some other projection, you'll need to convert to latitude/longitude coordinates first.

2D map - as in the one supplied by the OP in post 3.

In this case, the 2D map is simply a jpg / bmp image.

I'd recommend you check the client engine before we continue as it is clearly distorting the images (you may have to download to see the 'flat pack' stuff).

It is simply wrapping the image and not doing anything special. Like I said, if the OP is happy then they should go with it. But it looks ridiculous to me.
 
Technology news on Phys.org
  • #32
DrGreg said:
I'm having some difficulty working out what shlomi's question actually is

level 1 and 2 are 2D but the only difference is that level 1 is actual data (flash objects: grid, trees, lights etc) and level 2 is the textures that render (offline on the server) to show level's 1 objects. for our conversation it's the same or moreover, level 1 shouldn't be discuss of since i don't need to make any conversion from it to sphere.

DrGreg said:
My understanding of post #22 is that he/she already knows how to do this using "the client's engine", the website linked to from that post, which is why I'm confused as to what the question is.

the component I'm using to show a sphere on the client side required the image i attached in post #11, this image ia already distorted, mean - as i understands that - the component must get a distorted image and then it's wrap the 3d sphere with it, the transformation between this distorted 2d image and the 3d sphere create the reality view on the sphere.

follow by this, it's mean that i need to prepare the distorted image for the system, follow by the user's data, and this is the thing I'm looking for.
from my side it's looks like i need to render image like the one on post #18 and after that distort it to be like the #11's one.

thanks guys.
 
  • #33
hi guys.

i'll did some illustration to show you a little bit more clearly what is my problem:

there are attached images:
1. planet2d.png
2. 3dWithoutRotation.jpg
3. 3dWithRotateSouth45Deg.jpg
4. 3dWithNorthPoleOnCenter.jpg (you can see it on the next post - since this forum allowed max 3 images in thread)

the #1st image is the distorted texture for wrapping the sphere.
the #2nd image is the sphere (after #1's wrapping) without any rotation of the sphere.
the #3rd image is (about - ~) 45 degrees rotation (north to south / up to down)
the #4th image is (about - ~) 90 degrees rotation (north to south / up to down).

as you can see there are 2 objects on the #1st image (red and yellow), in the real world they're with the same surface/dimensions and this is the reason you can see them dimensions equally on the sphere while you rotate it, but in the #1st image i must have the distortion (as we already discussed before) so the wrapping of the 3d sphere will show the right data.

i did the #1st image by my self with Gimp (this is the reason it's not 100% equal - I'm a programmer - not a designer !:)) and what I'm looking for the some math formula that allowed me to generate this image (#1st) automatically based on the data i have on the DB (as you probably understood - the data from the DB is the 2 areas on thew #1st image: red and yellow)
this formula should grow/decrease the object dimensions follow by your location: as much as you go to north or south your height will grow and east to west your width will grow.

hope it's better explanation.

TA

Shlomi.
 

Attachments

  • planet2d.jpg
    planet2d.jpg
    5.5 KB · Views: 470
  • 3dWithoutRotation.jpg
    3dWithoutRotation.jpg
    13.2 KB · Views: 396
  • 3dWithRotateSouth45Deg.jpg
    3dWithRotateSouth45Deg.jpg
    12.4 KB · Views: 445
  • #34
the #4th image for the previous replay (!)
 

Attachments

  • 3dWithNorthPoleOnCenter.jpg
    3dWithNorthPoleOnCenter.jpg
    9.7 KB · Views: 510
  • #35
shlomi said:
i did the #1st image by my self with Gimp (this is the reason it's not 100% equal - I'm a programmer - not a designer !:)) and what I'm looking for the some math formula that allowed me to generate this image (#1st) automatically based on the data i have on the DB (as you probably understood - the data from the DB is the 2 areas on thew #1st image: red and yellow)
this formula should grow/decrease the object dimensions follow by your location: as much as you go to north or south your height will grow and east to west your width will grow.

I'm leaving the mapping stuff out now, the OP has a method in mind so it's futile trying to explain otherwise.

The easiest way to achieve the above, is to lay a grid over your image (using the lat and lon values for x and y). You then have a database of 'what goes where' and so you would query the database for the coordinates (x and y) and what the object is (let's say it's a ball, you could then query another table to retrieve the ball picture - see normalisation if you're unfamiliar, it cuts down redundancy). You then plot them on the grid overlaid on the map.

This can either be dynamically wrapped around the sphere, or easier would be to save it as an image and simply wrap it as is.
 
  • #36
jarednjames said:
You then plot them on the grid overlaid on the map.

i already have the process against the DB, mean i have an image pattern for each object i have on the DB and i can draw it on the big texture based on the object's coordinate (long, lat).
but after that all of the objects are draw on the big image, i need to distort the image to be like image #1 ( or maybe distort the object before i plot it on the biug image) and this is what I'm looking for: how can i know how much distortion (via transformation) i need to do for object that for instance, located on the equator of for object that located on the north?
 
  • #37
Why do you need to distort it?

If you print the images onto the map, and then save that as a new temporary image (so you have a flat map with the objects on it as a picture file), you can simply wrap that directly onto the world with your engine. It will do the distortion for you.

It's not the best way to do it, but it's the easieast if you want to check the results.
 
  • #38
as i understanding, the distortion is needed.
to show you that - i took the same 2d image like before (2d.png) and i added a non-distorted object on it (the gray one) but i left the distorted one (yellow), now, you can see those objects on the sphere (sphere1.jpg, sphere2.jpg and sphere3.jpg), the distorted (yellow) look realistic but the gray one (that have the same dimensions like the red but another location on the world) not appear realistic, if I'll convert it with the same distortion like the yellow one it'll looks fine.

Over the weekend i read a children book (of my little daughters) that explain things about geography and i found an explanation about how create maps based on sphere (see cBookMerkator.jpg) and i found the 'Mercator projection' method, i think this is what i need but i need to find the proper math formula that let me create the distortion function.
i found http://www.experts-exchange.com/Programming/Algorithms/Q_24509438.html" article on the internet but the answers are costing money :) so i'll keep search.

[P.S. sphere1.jpg and cBookMerkator.jpg are attached on the next post]
 

Attachments

  • 2d.jpg
    2d.jpg
    5.6 KB · Views: 424
  • sphere2.jpg
    sphere2.jpg
    8.8 KB · Views: 415
  • sphere3.jpg
    sphere3.jpg
    13.5 KB · Views: 396
Last edited by a moderator:
  • #39
attached sphere1.jpg and cBookMerkator.jpg for the previous post
 

Attachments

  • sphere1.jpg
    sphere1.jpg
    13.3 KB · Views: 440
  • cBookMerkator.jpg
    cBookMerkator.jpg
    31.7 KB · Views: 456
  • #40
I don't know what you're going on about. You're not reading anything I've written.

I've told you exactly what you need to do.

You do not need the above merkator technique - that is for expanding a globe and you are not doing that.

For the last time:

1. Plot your objects onto the flat 2D map (the rectangle one you want to wrap).
2. Save that as a temporary image.
3. Wrap it on the globe.
4. The engine will distort the map and the items you marked on it.

That's all there is to it.
 
  • #41
OK.. thanks for your patient... i'll try it.
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 16 ·
Replies
16
Views
6K
  • · Replies 24 ·
Replies
24
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
3
Views
2K