Home arrow static arrow Java Programming [Archive] - Problems on Map Coordination
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Problems on Map Coordination
10 Duke Stars available
This topic has 9 replies on 1 page.

Posts:17
Registered: 7/8/04
Problems on Map Coordination  
Jul 30, 2004 4:40 PM



 
My question is to insert a map, which is an image, on to the jframe.
Then, we will be able to use the java application to set x and y coordinate ON TO THE MAP.
Therefore, when we insert any x and y value during runtime, the java application will be able to find the matching coordinate and display a dot on the coordinate.

This sounds like those map for tracking location application.
 

Posts:8,813
Registered: 10/4/00
Re: Problems on Map Coordination  
Jul 30, 2004 5:16 PM (reply 1 of 9)



 
It depends. If you just want to do a simple map, you can just transform the coordinates. Let say your map covers 29-30� North, 94-95� West or one degree in each direction (apolgies to Glen Campbell). For right now, let's assume a degree of longitude or latitude is 70 miles. If the image is rendered at 350x350 pixels, the scale is 5 pixels per miles. So 29.5 North, 94.5 West is at the center of the map or (175,175). You may have to invert the data because for latidtude, greater numbers are above smaller ones, but on the image, greater numbers are below smaller ones.

In real life, a degree of longitude does not equla 69 miles. As you appraoch the poles, it goes to zero. Before I ramble any more, you need to get a little more specific about what you need.
 

Posts:8,813
Registered: 10/4/00
Re: Problems on Map Coordination  
Jul 30, 2004 5:19 PM (reply 2 of 9)



 
...because for latidtude...

Apologies to Jimmy Buffet too.
 

Posts:17
Registered: 7/8/04
Re: Problems on Map Coordination  
Jul 31, 2004 10:50 PM (reply 3 of 9)



 
Ok.. Erm... Is there any sample codes out there that will teach us how to insert this value in? Because my Java language skills is learn through reading of sample codes.

Your reply helps me to understand more.
Thaks alot man.
 

Posts:17
Registered: 7/8/04
Re: Problems on Map Coordination  
Jul 31, 2004 11:02 PM (reply 4 of 9)



 
Your reply is very precious to me..

Once again,
Thank you very much!
 

Posts:8,813
Registered: 10/4/00
Re: Problems on Map Coordination  
Aug 1, 2004 6:39 AM (reply 5 of 9)



 
Can you write code put an image on a JFrame?
Do you know the coordinates of the image?
Do you know the size of the image?
Does the image change?
Do you have to take the curvature of the earth into consideration?
Do you know how to translate coordinate systems?
Do you want someone to write your whole application for you?

What you are asking for could range from easy to incredibly complex. I have no idea what you want to do. If I start guessing, I am sure to be wrong and then I have just wasted my time. I have already expended more effort replying to you than you did in clarifying your question.

Why don't you start by writing code to do the things you know how to to or can figure out by searching the tutorials and forums on this site and using Google to search the internet. Then if you get stuck, you can come back here, post the code you have written and ask a question about a specific part of it.
 

Posts:17
Registered: 7/8/04
Re: Problems on Map Coordination  
Aug 1, 2004 6:48 AM (reply 6 of 9)



 
ok.. Thanks.. but i think my question is
Do you know how to translate the map into coordinate systems?
 

Posts:8,813
Registered: 10/4/00
Re: Problems on Map Coordination  
Aug 1, 2004 7:27 AM (reply 7 of 9)



 
Yes I do. I learned this in algebra quite a few years ago. Later on I learned about spherical coordinates which would allow scaling on a spherical surface such as the earth. I spent 20 minutes looking for a tutorial for you and I finally gave up.

The basic idea is that you have to scale the coordinate system. Lets take the simple case of a line. Let's say in real life the line is 50 miles long (or 50 meters or 50 lightyears) and on the screen it is 200 pixels. Now you want to place an 'x' on the line on the screen which translates to 17 miles. Well, there are 4 pixels per mile (200 pixels/ 50 miles), so now we multiply 17 miles by 4 pixels per mile and we end up with 68 pixels. Put the 'x' over the 68th pixel and you are done. If you do this same thing for both x & y coordinates, you have done what you want.

This gets a little more complicated if both coordinate systems don't start at 0,0. And it get's more complicated again if the x & y scales aren't equal. And it get more complicated if you are trying to map a spherical surface (kinda like the planet we live on).

The kind of instruction you are asking for is a little beyond what a person can be expected to type into a Java forum. You might ask your math teacher. Maybe you could search the internet for a tutorial on cartesian coordinates.
 

Posts:2,909
Registered: 13.8.2003
Re: Problems on Map Coordination  
Aug 1, 2004 11:02 PM (reply 8 of 9)



 
Search for polar coordinates, there's at least some mathworld article that I used. It tells how to convert cartesian to polar and vice versa. That should get you started.
 

Posts:17
Registered: 7/8/04
Re: Problems on Map Coordination  
Aug 2, 2004 7:06 AM (reply 9 of 9)



 
Thanks bbritta and Kayaman.
I have took the advice of both of you and understand some of the algorithm.
But how do create a java gui map with the coordination?
Grid layout?
Or can just do with the JPanel?
Thanks.
 
This topic has 9 replies on 1 page.