Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    UK
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    'Find Nearest Store'

    What I would like to do is someone able to put their postcode in and see where there nearest 'store' (well airfield) is. This will be done on UK postcodes hopefully. I have got three airfields that I want to list, is there a nice algorithm to compare two postcodes?
    Hopefully like http://www.dixons-group-plc.co.uk/we...insmap_dix.htm where you enter your postcode bit.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Probably. By comparing the coördinates of the citys with the airports. This implies you have the latitudes and longitudes of citys and airports in a database. You could then compare the length of the vectors (3) from the city to each airport. (of coarse, this is a lineair vector) I don't know if such data is available in db-format, but it'll surely exist.

    But i presume there are crostab tables available, that display the distances between each city (postalservices and traincompagnies in belgium used them) All you have to do then is take a section (3 x 'Number of cities') ans store that in a table.

    Or check up on some route-planners. They probably can supplie these data. (or could be integrated in your app to display route en distance to airport. for instance: search for an online route-planner that uses the querystring to submit to the searchpage, and then build your own querystring to the page they are submitting to)

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is an interesting project - you might want to look at my javascript post "DMS to Decimal Convertor" that has the code to convert Degrees/Minutes/Seconds to decmial longitude/latitude. This might not be helpful for this particular case, but you never know.

    I'd also look up "Great Circle Distance" and "Longitude Latitude Distance Calculation" on google, if you can use a "great circle" calculation like for this it should be more accurate, but probably not necessary if the airports are not very far apart, globally speaking. I stink at math, but the formulas didn't even look particularly intimidating to me. Haven't done anything with them yet, though.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    I stink at math
    You are bad at something? Really?

    Join the club though, I rule at physics but when I enter the math room door by brain ejects itself and waits until I come out again.
    Omnis mico antequam dominus Spookster!

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how far are your airports apart? are they liverpool, london and edinborough? depending on there location i have a plan

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #6
    Regular Coder
    Join Date
    Sep 2002
    Location
    UK
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No they are Goodwood (Chichester), White Waltham (Maidenhead) and Gloucester.

    Why what was the idea?

  • #7
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Data sources

    Your best bet if you would like to do this is to contact a company like Experian or CACI (they are geo-demographic companies).

    I've done a project like this with them in the past. You've got two basic options.

    1. Get them to supply you the data
    2. Purchase the server component from Experian.

    If you buy the data to code yourself you're looking at a pretty massive project/server. There are over 1.9million postcodes in the UK. Add to that the fact that the Post Office update the postal address file every 3 months with all the postcode changes it's a real headache.

    Buying the server component isn't cheap but then you just use the Experian data which is constantly updated and the coding is pretty simple.

    Hope this helps.

    dominicall
    dominicall - confusing himself more and more each day

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you divide the UK into three zones so the nearest apart is in the same zone as your area.
    If you look at post codes there are
    if you consider the following:
    Acrise Place Kent CT18
    East Lavington West Sussex GU28
    Edinburgh City of Edinburgh EH9
    so as i was saying you could look at the first bit of the postcode e.g. CT18 and compare it with a list of postcodes. So that if it matches on a list it will show the list header which is the airport.

    there is a list of all postcodes in the Uk available at http://www.brainstorm.co.uk/utils/post-codes.txt
    it only contains the first part though.

    So if you compare the first bit with the postcodes in the zones and it mathces your nearest airport is Blah.

    scroots
    its still a mamouth task.
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #9
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mammoth task...

    Yep - have to agree with scroots....

    Using scroots' method (i.e. postal districts) would certainly reduce the data volume and distance calculation time, but raises all sorts of other problems - mostly to do with size of the postal district.

    In some more remote parts of the country a postal district can quite large, whereas in a city like London they can be very small.

    Have a look at what solutions are available as hosted solutions - that might be the best bet.

    dominicall
    dominicall - confusing himself more and more each day

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    domincall you might have slightly the wrong end of the stick.
    Airport 1
    LW14
    TY7
    PL9E
    HKEL
    ...
    Airport 2
    FFNC
    5VNF
    HJR
    DEE2
    ...
    Airport 3
    ASE3
    AVF2
    TM3
    ...

    so if the postcode(or first part of it) was enterd as TM3 it would show as Airport 3.
    How has postcode area size have a problem? there are possibley a few postcode slap bang in the middle which would return two results.

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or in some cases only the first two letters of the postcode may be required as the post code PH*****refers to highland and kinross.

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #12
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Oops

    Yep - did get the wrond end of the stick

    Assumed that we were actually trying to calculate distances... which I guess would be technically the most accurate way to find the nearest...

    ... but given that there are only 3 airports then probably not a problem... if it was a store in every other town then might be a different proposition.

    Good spot scroots

    dominicall
    dominicall - confusing himself more and more each day

  • #13
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Leeus,

    don't lissen to them! Please, do it the hard way (writing a simple algorithm to compute the distance) and publish it here, so we can all use it for whatever app. This sort a thing is highly reusable.


    If you can supply the data (Degrees/Minutes/Seconds of all englich towns), then i'll write the algorithm.

  • #14
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    LOL raf

    Hi raf

    I agree with you - it is highly re-usable - but HUGE.

    If you want to be able to calculate distance accurately then it needs to be done at full postcode level (i.e. SE4 1PL). There are approximately 1.9 million unit postcodes in the UK.

    To calculate the distance, you therefore need to store both the postcodes and the degrees, minutes, seconds in the database. Believe me, it becomes HUGE.

    Then to calculate the distance you need to search the database for the postcodes of the starting and finishing positions and the run the calculation algorythm. The calculation itself is the easy bit - LOL.

    Taking it out of the context of the 3 airports scenario, if you want to enter 2 postcodes and get the distance between 2 user entered postcodes then the volume of the data store is massive and processing power to complete the data fetch and calculation in a 'user' reasonable time is also massive.

    I've been involved in a project before doing just this and in the end we decided to go for the paid-for hosted solution. Partly for time, partly for efficacy but mainly because we knew the continual updating of the Postal Address File (PAF File) was managed remotely by a company that specialises in geographic mapping and processing.

    Otherwise, you need to upload a new PAF File of 1.9 million records with co-ordinates at least every quarter (if not more often) and test to make sure everything is OK.

    However, if anyone does a quick and easy solution I'd be more than happy to 'borrow' it

    Not in any way wishing to rain on your parade - I tried the same approach and it just became too huge.

    dominicall
    dominicall - confusing himself more and more each day

  • #15
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well. Huge is good. I like huge. Kind a nice to say : “My database has 2 million records and I want to capitalize all cell’s …” :-)

    Serious: I’d have a go at it, if you can supply the data.
    Of coarse, not on a 2 mil records table. I’d set up a relational databasemodel that breaks down the computing process + create different processes.

    For instance: if someone wants to know the exact distance between to citys, then his request will be processed differently then if someone wants to know which is the nearest airport. The second question can be broken into different pieces. Nearest big city in more a less right direction, nearest airport to this big city. You see ? The computing is not completely correct, but the answer will be correct. What’s more: when you drive to that airport, you will probably use the same rout as was used in the computing. (You could even return multiple alternatives …)

    It would be an app with a sort of MDDB datacubes (preprocessed information) than can give the desired data really fast + some computing on this data.
    If the question can’t be answered by the MDDB model, then there will be used other processes, running on a relational or hierarchical database (the same one that was used to build the MDDB’s). And the computing should still be real fast.

    Of coarse, typing in two area codes and press submit, will create problems (like selecting on a 2 mil table).

    I wouldn’t take that option (since typo’s and stuff can create serious problems + response time would be to high). I’d break it down into : select state, district and at the lowest level you then select this 1 record out of a table with a few thousand records. Just retrieve the coordinates (possibly precomputed into decimal numbers) + same thing for other city. (with each selection, the cube that needs to be searched, is losing a dimension)
    From there on, its easy co compute the distance

    This way you can also choose how accurate the result needs to be, by selecting your own scale (postcode or city etc).

    To ensure re-usability, all data to the actual searching and computing pages will be in the querystring, so other app’s can link to it with the data in the url, and display the results in a frame on there page. (or send it back to one of there pages with the results in the querystring)


    Just some thoughts.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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