Is any other Java API i can use or any programming logic or data structure i can use to solve tis problem ?
Googling for "distance between cities" finds a number of online applications. If nothing better comes along, you should be able to drive one of those using the HttpUrlConnection class, and then parsing the resulting HTML.
Hi So you means i need to hit a site which offer to calculate distence between two cities and parse the repsonse html file for desired oupput distance !! But how can i set that parameter of 'From City' to 'To city' on that site ?
Joined: Mar 22, 2005
Here's an example of how to post a form with parameters and read the response that is being sent.
There will be classes and methods in java.awt that convert rectangular screen co-ordiantes to polar co-ordinates. You can provide the appropriate class with (int x, int y, int delta-x, int delta-y) using city first(x,y) for the first two then city second(x,y) to the second pair of ints then call rectangular to polar and get magnitude on the result.
To do surface of Earth ( Great Circle Distance ) is complex, but one does not get asked to do Great Circle Distance unless your instructor is a Pilot or Astronomer.
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
But i already started working on what 'Ulf Dittmer' was suggest . I hit the URL to get XML file as a response and extract longitude and latitude , which gives me a approximate distance (i.e a straight nautical distance )
Hey thanks ahmd and welocme to JavaRanch
I already implemented my requirement, (which is a year old) and its working fine.
I hadn't explore the library yet, but one question for you ?
Can I calculate the distance of any city of the word to any city ? And a short description about how it calculate the longitude and latitude of a city, I mean is it request this data from internet or do you have you own logic/data structure inside.
Joined: Jul 10, 2009
it is just calculate the Distance between Latitude and longitude coordinates
i assume you know the Latitude and longitude coordinates of the city