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.
Results 1 to 3 of 3
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    converting numbers so they represent distance.

    I'm stuck here both in terms of how to think it through and then, how to write it

    edit: just had inspiration as I re-read this... is it as simple as finding out how many 'numbers' there are per kilometres and, then changing the line
    $distanceEastWest = ($baseEastings - $nearbyEastings); TO
    $distanceEastWest = ($baseEastings - $nearbyEastings / 10);

    ie, divide by 10 if there are ten to the Km?

    /edit:

    Code:
    my $clientGrid = "34567898";
     
    my ( $baseNorthings , $baseEastings ) = ($clientGrid =~ /(....)/g);
    baseNorthing is therefore 3456
    baseEasting is therefore 7898

    That bit is OK but then I use the code

    Code:
    my $nearbyEastings = "34567890";
    my $nearbyNorthings = "45678987";
    
    $distanceEastWest = ($baseEastings - $nearbyEastings);
    if ($baseEastings > $nearbyEastings) {
    print <<EOF;
    $business is $distanceEastWest West of $clientBusiness
    EOF
    } elsif ($baseEastings < $nearbyEastings) {
    print <<EOF;
    $business is $distanceEastWest East of $clientBusiness
    EOF
    } elsif ($baseNorthings == $nearbyNorthings) {
    print <<EOF;
    This $businessType is on the same Northing as $clientBusiness
    EOF
    }
    This simply ads and subtracts the portions of numbers and prints the numerical difference between them.

    I need to find out how to convert the difference between the numbers (not necessarily the numbers themselves), to be able to print
    This $businessType is XX kilometres East/West/North/South of $clientBusiness

    [/code]

    Please if any of you can give me a tip or hint, I'll be a happy teddy bear.

    Bazz
    Last edited by bazz; 07-02-2005 at 09:29 PM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,389
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    Bazz ...

    I can't find any examples at the moment, but what people are doing in the U.S. is actually entering GPS coordinates for businesses and locations.

    Using mathematics with the Longitude and Latitude to come up with an exact distance (in a straight line). A "fudge-factor" is added if the known distance is not a direct route, or several way-points are calculated.

    This is very similar to the U.S. zipcode database that also had GPS coordinates for geographical city centers.

    I'm guessing your businesses don't know their exact GPS location, but they can probably find out the coordinates for their city and that might be close enough.

    Just an idea ... -max-

    EDIT:
    Bazz ... I found this: http://www.zipcodeworld.com/samples/distance.pl.html


    .
    Last edited by mlseim; 07-02-2005 at 10:44 PM.

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Hey Max thanks.

    After I posted last night, I went back to the 'olde worlde' pen and paper type devices. I remembered some mathematics from an earlier era which has helped. GPS isn't guaranteed accurate yet in my country and whilst I don't know if it ever will be, I think that the solution I have found is sufficient for now, for what I am doing.

    Of course I have to contend too, with the reality that the southern 3/4 of this land mass doesn't use post/Zip codes and I need a consistent sytem.

    Ho Hum

    Bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

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