Jump to content

Recommended Posts

I can calculate the distance just fine (I found a tutorial that explained it quite well), but I also need to be able to calculate the driving distance between two points. I don't know how accurate it would have to be, but I can't figure out how to do it. Any ideas on where to start? Thanks.

I can calculate the distance just fine (I found a tutorial that explained it quite well),............ Any ideas on where to start? Thanks.

This is basic math... the most basic of basic if you ask me.

 

Think about it.  If it is 100 miles between two points, the only other variable that you need is the speed.  The paradox that you'll run into is that.. obviously no one will ever be going a constant speed for an entire 100 miles.  That's impossible.  You've got dynamics to look at such as

[ot]

- the posted speed limits

- the mileage/condition of the car itself

- the weather

- the tire pressure

- the number of passengers AKA the weight of the car

- the alcohol level of the driver

- the chance of a wreck

- slow drivers in front of you

- back seat drivers ruining your focus

- slowing down to change the radio station...

--- it can go on and on

[/ot]

but all it really boils down to is a relative speed.. You could get all fancy and use sin waves and such if you wanted... but to start off simple.  If you're traveling 65 mph to a distance 100 miles away, how long do you think that would take?

 

Well..  If you can 65 miles in 1 hour..

You should be able to get 100 miles in (100 / 65) hours

........which is 1.54

Sorry, maybe I didn't explain it well enough. The distance, not how long it takes to get there. And I'm talking through php, not just by looking it up online each time. I'll have a bunch of zip codes in the database, but I want to be able to find the approximate driving distance between any two.

I'll have a bunch of zip codes in the database, but I want to be able to find the approximate driving distance between any two.

 

lol

 

You are better off looking it up online. What you need to do is find the latitude and longitude for each ZipCode, after you have that find out how many degrees is considered a mile. Once you have that you should be able to calculate it no problem!

 

The point, you have to have 2 absolute positions and have a way to calculate the distance between two points. Without having or knowing 2 absolute positions, how do you expect to calculate the distance (other then by driving there yourself and doing an average speed etc, which Zane hit on)?

Here, I'll let you in on a super secret.. (passed down from generation to generation) thread/topic that deals about this very question you have asked.  If that doesn't help you out, then I'd recommend premiso's suggestion... manually checking it through Google Maps.. (I highly doubt you'll need to though)

 

http://www.phpfreaks.com/forums/index.php/topic,208965.0.html

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.