Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to calculate the distance between Zip Codes?How to calculate the distance between Zip Codes?
Previous
 
Next
New Post
7/15/2007 1:16 AM
 

Hi,

I want to calculate the distance in miles between two zip codes. I will then  show something like UserName (45 miles away)

Do I use something like Google Maps API?
Do you know of any tutorials on how to do this?

Thanks,
John

 
New Post
7/15/2007 9:54 AM
 

I don't personally have any samples (anymore) but several years ago I was considering doing something like this for another application.  I can tell you the basic theory behind it and give some terms that you could Google:

Essentially, doing calculations between zipcodes is a rough estimate to their epicenter based on latitude and longitude.  If you wanted to perform the calculation directly in your DNN site you'd need a way to store the latitude and longitude for all of the zip codes and then use some nifty code to triangulate the distance.  An example of the calculations can be found on CodeProject while tutorials (and possibly some sample web services) can be found on ZipCodeWorld

Additionally, check out the following webservice at http://webservices.imacination.com/distance/ ; it seems to be free and provides that accomodation.  Another example http://teachatechie.com/GJTTWebservices/ZipCode.asmx

The problem with calling web services from within DNN is that it requires some additional permissions that may not work in a medium trust server.  If you are running your own server this isn't so much a problem but if you are running from a hosted server this can (and likely will) become an issue.

Hope that helps.


-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
New Post
7/15/2007 10:26 AM
 

 

We do this in an application where we maintain a fixed set of zipcodes.

We store the GEOCODE (Lat, Long) for each of the zip codes and then use the following function that calculates the distance between the two geocode locations.

ALTER Function

[dbo].[CalculateDistance](@Longitude1 Float, @Latitude1 Float, @Longitude2 Float, @Latitude2 Float)

Returns Float

AS

Begin

 

Declare @DeltaX Float

 

Declare @DeltaY Float

 

Declare @DeltaXMeters Float

 

Declare @DeltaYMeters Float

 

Declare @MetersPerDegreeLong Float

 

Declare @CenterY Float

 

Declare @gEARTH_CIRCUM_METRES Float

 

 

 

 

 

 

Set @gEARTH_CIRCUM_METRES = 6378007 * 2 * PI()Set @DeltaX = Abs(@Longitude2 - @Longitude1)Set @DeltaY = Abs(@Latitude2 - @Latitude1)Set @CenterY = (@Latitude1 + @Latitude2) / 2Set @MetersPerDegreeLong = (Cos(@CenterY * (PI()/ 180)) * @gEARTH_CIRCUM_METRES) / 360 --dbo.MetresPerDegreeLong(@CenterY)

 

 

 

 

Set @DeltaXMeters = @DeltaX * @MetersPerDegreeLongSet @DeltaYMeters = @DeltaY * 111113.519Return Sqrt(@DeltaXMeters * @DeltaXMeters + @DeltaYMeters * @DeltaYMeters) / 1609.344

End


Jim www.walkspoiled.com
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to calculate the distance between Zip Codes?How to calculate the distance between Zip Codes?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out