Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: postcode search

  1. #1
    Join Date
    Nov 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up postcode search

    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.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    S/he said post codes, not ZIP codes (and the URL is a .org.uk). Here 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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Nov 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    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

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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

    That work for you?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  7. #7
    Join Date
    Nov 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am looking for UK postcode. Anyone knows from where i can download free uk postcodes list. thanks

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I am looking for UK postcode. Anyone knows from where i can download free uk postcodes list. thanks
    I 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?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Nov 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    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.

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    having any sort of relationship to a road is much more complex than this.
    Just use google maps.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •