Re: [IRCA] Kodis site
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [IRCA] Kodis site



Nick Hall-Patch wrote:
This site for finding direction and distance of all the AM/FM stations within a given radius from a given location,

http://www.radiostation.com/kodis/


Dunno about that, but if you're handy with C programming you might adapt this for your needs:



#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define RADIANS_PER_DEGREE 0.017453293
#define DEGREES_PER_RADIAN 57.295780
#define EARTH_RADIUS       3956.0
#define HOME_LAT           35.90318333
#define HOME_LON          -106.3123833


typedef struct { double distance; double bearing; } polar_coords;


typedef struct { double lat; double lon; } spherical_coords;

polar_coords get_geodelta(spherical_coords from, spherical_coords to)
{
polar_coords result;
spherical_coords delta;
double a, a1, a2, a3, a4, c;
// double PI = 4.0 * atan2(1.0,1.0);
printf("here: %f, %f\nthere: %f, %f\n",from.lat, from.lon, to.lat, to.lon);
delta.lat = (to.lat - from.lat) * RADIANS_PER_DEGREE;
delta.lon = (to.lon - from.lon) * RADIANS_PER_DEGREE;
printf("dlat: %f\ndlon: %f\n", delta.lat, delta.lon);
a1 = pow(sin(delta.lat/2.0), 2.0);
a2 = cos(from.lat * RADIANS_PER_DEGREE);
a3 = cos(to.lat * RADIANS_PER_DEGREE);
a4 = pow(sin(delta.lon/2.0), 2.0);
a = a1 + a2*a3*a4;
c = 2.0 * atan2(sqrt(a),sqrt(1.0-a));
//result.bearing =
// acos(sin(to.lat)-sin(from.lat)*cos(result.distance)/(sin(result.distance)*cos(from.lat)));


   printf("a1: %f\n", a1);
   printf("a2: %f\n", a2);
   printf("a3: %f\n", a3);
   printf("a4: %f\n", a4);
   printf("a: %f\n", a);
   printf("c: %f\n", c);
   //if(sin(delta.lon) < 0)
   //   result.bearing = 2.0*PI - result.bearing;
   result.distance = c * EARTH_RADIUS;

   return result;
}


main ()
{
polar_coords geodelta;
spherical_coords there = {36.821383333, -107.99945};
spherical_coords here = {HOME_LAT, HOME_LON};
geodelta = get_geodelta(here, there);
printf("distance: %f, bearing: %f\n", geodelta.distance, geodelta.bearing);
return 0;
}



-- Mike Westfall, N6KUY, WDX6O Los Alamos, NM (DM65uv) Online logbooks at http://dxlogbook.gentoo.net

_______________________________________________
IRCA mailing list
IRCA@xxxxxxxxxxxxxxxx
http://dallas.hard-core-dx.com/mailman/listinfo/irca

Opinions expressed in messages on this mailing list are those of the original contributors and do not necessarily reflect the opinion of the IRCA, its editors, publishing staff, or officers

For more information: http://www.ircaonline.org

To Post a message: irca@xxxxxxxxxxxxxxxx