PDA

View Full Version : postcode search



imi_99
11-03-2006, 11:50 PM
Hello everyone,
I am thinking to create a search similar to autotrader. I havea car website. What I want to do if someone search using postcode search word then it should show searches according to distance from postcode.
Like if someone type london postcode, then it shows result first which is close to it postcode.

Any one have idea.
Any question please email me.

djr33
11-04-2006, 06:15 AM
1. You need a database (or *maybe* something similar, but that's a bad idea).
2. You need the name of the "place" and the postcode for that "place" in the database for each "place" as a row.
3. Just search and see what's closest.

You could just be lazy and code based on numbers... see which is closest. It would give an approximate answer.

With US zip codes, 00345 would be closer to 00385 than 99204, but it would be imprecise with close distances.

So.. basically... you need a master list of ALL zipcodes and a way to determine distance from each other. I suppose you could design a sort of grid using coordinates and set up math for that. But you'd need a list of ALL zipcodes and coordinates and such. Kinda hard.

Twey
11-04-2006, 05:16 PM
S/he said post codes, not ZIP codes (and the URL is a .org.uk). Here (http://www.jibble.org/ukpostcodes/) is a large list of UK post codes. You can either enter those into a database somehow, or parse them directly for each request. The former would probably be more efficient in the long run.

imi_99
11-05-2006, 11:43 PM
Thanks for your comments. The system need for only uk site and I realy want to implement using postcode search.
I got idea that i have to use coordinate system like this

AB10,392900,804900,57.135,-2.117
AB11,394500,805300,57.138,-2.092
AB12,393300,801100,57.101,-2.111
AB13,385600,801900,57.108,-2.237
AB14,383600,801100,57.101,-2.27
AB15,390000,805300,57.138,-2.164
AB16,390600,807800,57.161,-2.156
- etc -

Suppose one person search from postcode AB13 then how it will compare search result using cartesian coordinates system. Need some more clue/example to understand this.

any idea,

Imran

djr33
11-06-2006, 08:21 AM
Yes, postcodes, not zipcodes. Since I'm from the US, I was using those as an example. But I'm sure the system is similar.

As for coordinates, you could need to use basic geometry-- the "difference theorem", which, really, is a fancy way to look at the pythagorean theorem.

It's all about right trianges.

A^2+B^2=C^2
In a right triangle (90 degree corner), the lengths of the "legs" (shorter sides connected to the right angle) are A and B (doesn't really matter which is which), and C is the distance between the ends of A and B, the other side, called the hypotenuse.

For example, the most common set of numbers used is:
3,4,5
9+16=25


Aaaanyway...

To get the length of the legs (A/B) from coordinates, you subtract.

abs(ycoord1-ycoord2) = A
abs(xcoord1-xcoord2) = B

where abs() is a function for absolute value (non-zero representation of the difference--- -5=5, and 5=5, meaning distance), and ycoord1 is the vertical coordinate from the first point, and ycoord2 is the vert. coord. from the 2nd pt., etc.

so...

abs(y1-y2)^2+abs(x1-x2)^2=dist^2

finally:

sqrt(abs(y1-y2)^2+abs(x1-x2)^2)=dist



I hope this is clear.

I'm good at explaining math.... ask if you need clarification. I'm finding it painfully hard to type this out... I need a blackboard or at least somewhere to draw a triangle :p

That work for you?

Nomad
11-08-2006, 08:15 AM
If you have the latitude and longitude, try going here http://www.zipcodeworld.com/developers.htm to download the script in the language of your choice. The PHP script works very well.

imi_99
10-04-2007, 04:29 PM
I am looking for UK postcode. Anyone knows from where i can download free uk postcodes list. thanks

Twey
10-04-2007, 04:47 PM
I am looking for UK postcode. Anyone knows from where i can download free uk postcodes list. thanksI showed you...
Suppose one person search from postcode AB13 then how it will compare search result using cartesian coordinates system. Need some more clue/example to understand this.I don't understand your question. Can you clarify?

imi_99
10-04-2007, 10:56 PM
thanks again. I could not complete this work and started again.

The link of UK postcode do not work at the time when I checked. Either it is removed or not working.

Regarding my question


Suppose one person search from postcode AB13 then how it will compare search result using cartesian coordinates system. Need some more clue/example to understand this.

Now I read the djr formula again and as far as i unederstood is,
Suppose someone search postcode "ls3 4rt" and it is located in list here
(ls3 4rt,392900,804900,57.135,-2.117) and it gets a distance value by using square root formula as it discussed above by djr. Suppose the value we get is 55. Am I right.

So the distance value we get=55. This is the location of person who searching from his own postcode(Am I right). So what is next step.

I have two questions after this,
1. How will I calculate distances of cars closest to this postcode.
2. I dont want graphical map. I only want to show cars in a sequence that closest will show first and then next........ Do I need lattitude and longitude calcalations as it given in a link.


Thanks again.

I am not good in php but trying to learn. Sorry to ask if the above are basic questions.

djr33
10-04-2007, 11:00 PM
having any sort of relationship to a road is much more complex than this.
Just use google maps.

imi_99
10-06-2007, 05:58 AM
Just use google maps.

Does google allow to use their script to use in our website.

djr33
10-06-2007, 06:08 AM
Yes, it does, and you would have to look at google to find the specific TOS in regards to that usage.

carlocodamus
10-08-2007, 03:25 AM
hey im planning to install googlemaps on my website, is it possible to install it appearing insinde an iframe and they can browse the map from within my site(iframe )?? just curious. thanks!!
[SIGNATURE AGAINST TOS REMOVED BY MODS]

imi_99
10-08-2007, 06:06 PM
Yes, it does, and you would have to look at google to find the specific TOS in regards to that usage.

Thanks I will try to find that how much is it effective for my site.