Jump to content


Photo

UK Cities....


  • Please log in to reply
11 replies to this topic

#1 puritystandsout

puritystandsout
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 13 July 2006 - 11:57 AM

Besides having to pay a big subscription fee to the post office in the uk to search on post codes...

I want to be able search on UK Cities and certain proximities like 50 mile radius...

Does anyone have any idea how I'd go about this?  Has anyone done this before?

Please help.  Thanks...

Regards and Jesus Christ's blessings,

Chris Cundill

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 13 July 2006 - 12:15 PM

You can work it out from the cities grid references with a bit of Pythagoras. There are a number of databases about online with postcodes/references for free. Quick search on Google should help you out.
<?php
function distance($na,$ea,$nb,$eb) {
    $dist_n = $na - $nb;
    $dist_e = $ea - $eb;

    $hypot = sqrt(($dist_n * $dist_n) + ($dist_e * $dist_e));
    return "Distance between $na(N) $ea(E) and $nb(N) $eb(E) is: ".round($hypot/1000,2)."kms";
}
?>


#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 13 July 2006 - 12:20 PM

First you need a database of

location, latitude, longitude.

Once you know where all the places are you can find them with a search. Searching in a square centered on you location is easier than radial distances. So if the bottom left corner of the square is at x1, y1 and top right is at x2, y2 then you search for

SELECT location WHERE long BETWEEN x1 and x2 AND lat BETWEEN y1 AND y2.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 puritystandsout

puritystandsout
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 14 July 2006 - 01:22 PM

I'm getting somewhere I think...

What Barand said made sense its just his sql statement is not quite what I need.

Would someone be able to elaborate on this to help me understand how to actually return the distance between two points.

Many Thanks.

Regards and Jesus Christ's blessings,

Chris Cundill

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 July 2006 - 01:29 PM

You can work it out from the cities grid references with a bit of Pythagoras. There are a number of databases about online with postcodes/references for free. Quick search on Google should help you out./


postcode database were please cheers.

I googled and there all paid ones were can i get the postcode database free cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 14 July 2006 - 01:35 PM

i dont know of any free scripts, but can i point out that uk postcodes are a trademark of royal mail and if people are found using them, u may get a hefty fine..

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 July 2006 - 01:39 PM

So does that mean that company's and websites using the postcodes for gavering information for orders to pay are useing the royal mail post code service.

nice to know cheers.


So in reality there the ones offering the service to website users with a subcrition of some salt.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 14 July 2006 - 01:44 PM

well not really sure, i think it is only if you have a database of them, but i dont know, maybe u can use them for free, im just looking it up, see if i can come up with anything

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 July 2006 - 01:45 PM

cheers mate
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 Guest_huey4657_*

Guest_huey4657_*
  • Guests

Posted 14 July 2006 - 01:48 PM

I have a few links here - not sure if it is what you are loking for but here they are:-

http://www.grcdi.nl/linkspc.htm
http://www.evoxfacil...o.uk/index.html
http://en.wikipedia...._United_Kingdom
http://en.wikipedia...._United_Kingdom
http://en.wikipedia....of_postal_codes


#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 July 2006 - 01:56 PM

Thank you for your help cheers i try them.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#12 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 14 July 2006 - 02:52 PM

Distance Calculation

http://www.movable-t...ts/LatLong.html
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users