Determine Distance Between Any Two Locations

  • kgayda

    SSCrazy

    Points: 2157

    Comments posted to this topic are about the item Determine Distance Between Any Two Locations


    Karen Gayda
    MCP, MCSD, MCDBA

    gaydaware.com

  • hypo

    Newbie

    Points: 5

    Thanks alot for the clean and good function!!

    Kind regards,

    Wim

  • jgao

    Newbie

    Points: 7

    There is one issue in the CalcDistanceBetweenGeoLocations function. Sometime you will get an error, "A domain error occurred.", by passing in some specific parameters.

    So I added the following Code:

    --reset @Distance if it is out of the range of (-1,1)

    If @Distance>1

    set @Distance=1

    If @Distance<-1

    set @Distance=-1

    before

    --Get distance in miles

    SET @Distance = (DEGREES(ACOS(@Distance))) * 69.09

    Because ACOS can be only with a value from -1 through 1.

  • kgayda

    SSCrazy

    Points: 2157

    jgao,

    Thanks for pointing that out.


    Karen Gayda
    MCP, MCSD, MCDBA

    gaydaware.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply