c# - Given coordinates, how do I get all the Zip Codes within a 10 mile radius? -


i have location (latitude & longitude). how can list of zipcodes either partially or within 10 mile radius of location?

the solution call known web service (google maps, bing maps, etc...) or local database solution (the client has sql server 2005) or algorithm.

i have seen similar question, answers there pretty pertain using sql server 2008 geography functionality unavailable me.

firstly, you'll need database of zipcodes , corresponding latitudes , longitudes. in australia, there few thousand of these (and information available), assume it's more difficult task in us.

secondly, given know are, , know radius looking for, can zipcodes fall within radius. simple written in php follows: (apologies it's not in c#)

function distancefromto($latitude1,$longitude1,$latitude2,$longitude2,$km){   $latitude1  = deg2rad($latitude1);   $longitude1 = deg2rad($longitude1);   $latitude2  = deg2rad($latitude2);   $longitude2 = deg2rad($longitude2);   $delta_latitude  = $latitude2  - $latitude1;   $delta_longitude = $longitude2 - $longitude1;   $temp = pow(sin($delta_latitude/2.0),2) + cos($latitude1) * cos($latitude2) * pow(sin($delta_longitude/2.0),2);   $earth_radius = 3956;   $distance = $earth_radius * 2 * atan2(sqrt($temp),sqrt(1-$temp));   if ($km)     $distance = $distance * 1.609344;   return $distance; } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -