How do they do that? long/lat in database then measuring distances between

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jayne Wolps

    How do they do that? long/lat in database then measuring distances between

    Hello
    I wonder if anyone can help.

    I would like to know how certain sites:
    http://aboutbritain.com/ArundelCastle.htm, and
    http://travel.knowhere.co.uk/place/+bristol-0/ manage to put approx mile
    distances between their listed towns and attractions.
    You will see it on the knowhere.co.uk site on the right side where they list
    nearby towns and on aboutbritain.co m you will see it where they list other
    nearby attractions and hotels towards the bottom of the page.
    I guess they store longitude/latitude in their database so they can pinpoint
    each attraction/hotel ETC, but what then. How do they calculate distances
    between those hotels and attractions and other towns?

    Also, the database on my site has alot of places stored but with postcodes.
    Is there a way of converting postcodes into approximate long/lat positions?
    Like a universally available table or something?

    My programmer is back tomorrow from his holidays and I'm trying to gather as
    much information about 'how it's done' so I can get a similiar system
    implemented on my website. My new website will be describing thousands of
    British villages and storing them in a mySQL database and I'm looking at
    ways of listing the nearest attractions to them. The site uses alot of php.
    If my programmer does not contact me on his return (he often obsconds for
    lengthy periods) I will be looking for someone who can do this sort of work
    and other work. Must be reasonable! and reliable!

    If anyone can help I'd be most grateful.

    Kind Regards,
    Jayne Wolps


  • Kevin Thorpe

    #2
    Re: How do they do that? long/lat in database then measuring distancesbetwee n

    Jayne Wolps wrote:[color=blue]
    > Hello
    > I wonder if anyone can help.
    >
    > I would like to know how certain sites:
    > http://aboutbritain.com/ArundelCastle.htm, and
    > http://travel.knowhere.co.uk/place/+bristol-0/ manage to put approx mile
    > distances between their listed towns and attractions.
    > You will see it on the knowhere.co.uk site on the right side where they list
    > nearby towns and on aboutbritain.co m you will see it where they list other
    > nearby attractions and hotels towards the bottom of the page.
    > I guess they store longitude/latitude in their database so they can pinpoint
    > each attraction/hotel ETC, but what then. How do they calculate distances
    > between those hotels and attractions and other towns?[/color]

    Pythagoras comes to the rescue here:
    distance from (ax,ay) to (bx,by)
    = square root ( ((bx-ax)^2) + ((by-ay)^2) )
    [color=blue]
    > Also, the database on my site has alot of places stored but with postcodes.
    > Is there a way of converting postcodes into approximate long/lat positions?
    > Like a universally available table or something?[/color]

    This site has a table of postcode locations

    Comment

    • Chung Leong

      #3
      Re: How do they do that? long/lat in database then measuring distances between

      Uzytkownik "Kevin Thorpe" <kevin@pricetra k.com> napisal w wiadomosci
      news:403a34d8$0 $12601$afc38c87 @news.easynet.c o.uk...[color=blue]
      > Pythagoras comes to the rescue here:
      > distance from (ax,ay) to (bx,by)
      > = square root ( ((bx-ax)^2) + ((by-ay)^2) )[/color]

      I wonder if the sum of the difference in x and the difference in y wouldn't
      better approximates the distance people actually would need to travel,
      considering that city streets are usually arrange in a grid.


      Comment

      • Trevor Smith

        #4
        Re: How do they do that? long/lat in database then measuring distances between

        On Mon, 23 Feb 2004 17:16:23 +0000, Kevin Thorpe <kevin@pricetra k.com>
        wrote:
        [color=blue]
        >Jayne Wolps wrote:[color=green]
        >> Hello
        >> I wonder if anyone can help.
        >>
        >> I would like to know how certain sites:
        >> http://aboutbritain.com/ArundelCastle.htm, and
        >> http://travel.knowhere.co.uk/place/+bristol-0/ manage to put approx mile
        >> distances between their listed towns and attractions.
        >> You will see it on the knowhere.co.uk site on the right side where they list
        >> nearby towns and on aboutbritain.co m you will see it where they list other
        >> nearby attractions and hotels towards the bottom of the page.
        >> I guess they store longitude/latitude in their database so they can pinpoint
        >> each attraction/hotel ETC, but what then. How do they calculate distances
        >> between those hotels and attractions and other towns?[/color]
        >
        >Pythagoras comes to the rescue here:
        >distance from (ax,ay) to (bx,by)
        > = square root ( ((bx-ax)^2) + ((by-ay)^2) )
        >[color=green]
        >> Also, the database on my site has alot of places stored but with postcodes.
        >> Is there a way of converting postcodes into approximate long/lat positions?
        >> Like a universally available table or something?[/color]
        >
        >This site has a table of postcode locations
        >http://www.jibble.org/ukpostcodes/[/color]


        Jayne

        PostCodes won't help as they are not arranged in that way in the UK. I
        think a better and much more accurate way would be to use grid
        coordinates. The Ordinance Survey grid is arranged in Eastings and
        Northings and is measured in metres so a straightforward search in a
        database for all locations within a rectangle around your location is
        fairly easy. The distance can be calculated using simple trig. Lats
        and Longs could also be used but the maths get a bit tricky. You can
        also pass on the grid reference so that users can find the location on
        their map or provide a button to link to a mapping web site. If you
        want to add a map to your web pages, try http://www.map24.co.uk

        regards
        Trevor

        Comment

        • Centurion

          #5
          Re: How do they do that? long/lat in database then measuring distances between

          Kevin Thorpe wrote:
          [color=blue]
          > Jayne Wolps wrote:[color=green]
          >> Hello
          >> I wonder if anyone can help.
          >>
          >> I would like to know how certain sites:
          >> http://aboutbritain.com/ArundelCastle.htm, and
          >> http://travel.knowhere.co.uk/place/+bristol-0/ manage to put approx mile
          >> distances between their listed towns and attractions.[/color]
          >
          > Pythagoras comes to the rescue here:
          > distance from (ax,ay) to (bx,by)
          > = square root ( ((bx-ax)^2) + ((by-ay)^2) )
          >[color=green]
          >> Also, the database on my site has alot of places stored but with
          >> postcodes. Is there a way of converting postcodes into approximate
          >> long/lat positions? Like a universally available table or something?[/color]
          >
          > This site has a table of postcode locations
          > http://www.jibble.org/ukpostcodes/[/color]

          Note quite. Over VERY short distances (<50km or ~30mi) pythagoras is OK,
          but keep in mind LAT/LONG coordinate system is essentially a polar system
          in 3 dimensions (pythagoras is planar in 2 dimensions). Google the whole
          lat/long distance thing. There are plenty of sites showing the mathematics
          to achieve acurate distances between 2 lat/long's - I've seen the raw
          formulae and various implementations from MS-Excell to C/C++ and even PCM!

          James
          --
          Fortune cookie says:
          Oh yeah? Well, I remember when sex was dirty and the air was clean.

          Comment

          • R. Rajesh Jeba Anbiah

            #6
            Re: How do they do that? long/lat in database then measuring distances between

            "Jayne Wolps" <jaynewolps(nos pam)@hotmail.co m> wrote in message news:<c1cv1b$92 0$1@hercules.bt internet.com>.. .[color=blue]
            > Hello
            > I wonder if anyone can help.
            >
            > I would like to know how certain sites:
            > http://aboutbritain.com/ArundelCastle.htm, and
            > http://travel.knowhere.co.uk/place/+bristol-0/ manage to put approx mile
            > distances between their listed towns and attractions.
            > You will see it on the knowhere.co.uk site on the right side where they list
            > nearby towns and on aboutbritain.co m you will see it where they list other
            > nearby attractions and hotels towards the bottom of the page.
            > I guess they store longitude/latitude in their database so they can pinpoint
            > each attraction/hotel ETC, but what then. How do they calculate distances
            > between those hotels and attractions and other towns?[/color]

            - http://distance-calculation.com/Dist...alculation.asp
            - http://www.phparchitect.com/sample.p...show=316&mid=9

            HTH

            --
            "Success is not what you achieve, but it is what you die for"
            If you live in USA, please support John Edwards.
            Email: rrjanbiah-at-Y!com

            Comment

            • Kevin Thorpe

              #7
              Re: How do they do that? long/lat in database then measuring distancesbetwee n

              > Note quite. Over VERY short distances (<50km or ~30mi) pythagoras is OK,[color=blue]
              > but keep in mind LAT/LONG coordinate system is essentially a polar system
              > in 3 dimensions (pythagoras is planar in 2 dimensions). Google the whole
              > lat/long distance thing. There are plenty of sites showing the mathematics
              > to achieve acurate distances between 2 lat/long's - I've seen the raw
              > formulae and various implementations from MS-Excell to C/C++ and even PCM![/color]

              True. However, if you want the rough distance to the closest hotel etc
              then the difference between pythagoras and a spherical solution only
              becomes significant when you wouldn't want to go there anyway.

              To calculate distances for aeroplane flights I would use a sperical
              solution. For nearest hotel it isn't worth the cycles.

              Comment

              • Paul Brooks

                #8
                Re: How do they do that? long/lat in database then measuring distances between

                On Wed, 25 Feb 2004 09:56:30 +0000, Kevin Thorpe <kevin@pricetra k.com>
                wrote:
                [color=blue]
                >True. However, if you want the rough distance to the closest hotel etc
                >then the difference between pythagoras and a spherical solution only
                >becomes significant when you wouldn't want to go there anyway.[/color]

                Not quite correct. The latitude and longitude scales are in the same
                units, but actually use a different scale. This is almost the same at
                the equator, but diverges towards the poles. For the UK using
                pythagoras would give you a distance approx double the actual value.

                Paul Brooks

                Comment

                Working...