Jump to content

[SOLVED] Calculating distances ...


budimir

Recommended Posts

Hey guys,

 

I'm creating a script where I should display distances between two cities. User can choose From - To cities and then distance is displayed

 

For example:

 

City 1    ->    City2    = 56km

City55    ->  City72  = 110km

...

 

In my DB I have this fields:

ID

date

from_city

to_city

distance

 

How do I calculate which is distance from one city to another???

 

Link to comment
https://forums.phpfreaks.com/topic/128102-solved-calculating-distances/
Share on other sites

Here it is:

 

ID  From        To        Distance

1    Zagreb    Karlovac  52Km

2    Zagreb    Knin        274Km

3    Zagreb    Virovitica 154Km

4    Zagreb    Split        374Km

5    Karlovac  Pula        234Km

 

These are values from DB.

 

I'm not sure how to calculate distance (for example) from Karlovac to Knin??? And other combinations??

With this data it isn't possible to calculate the distance from karlovac to knin. You would need to use the angle between the triangle knin/zagreb/karlovac along with the law of cosines to find the distance... Unfortunately since you don't have the angle it's impossible to tell.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.