mirror of
https://agent.ghink.cloud/wb2osz/direwolf
synced 2025-04-08 15:48:35 +00:00
new file: A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf new file: A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf modified: APRStt-Implementation-Notes.pdf modified: CHANGES.txt new file: Makefile modified: Makefile.linux modified: Makefile.win deleted: Quick-Start-Guide-Windows.pdf modified: Raspberry-Pi-APRS-Tracker.pdf modified: Raspberry-Pi-APRS.pdf modified: User-Guide.pdf modified: aclients.c modified: aprs_tt.c modified: aprs_tt.h modified: atest.c modified: audio.c modified: audio.h modified: audio_win.c modified: ax25_pad.c modified: ax25_pad.h modified: beacon.c modified: beacon.h modified: config.c modified: config.h modified: decode_aprs.c modified: decode_aprs.h modified: demod.c modified: demod.h modified: demod_9600.c modified: demod_9600.h modified: demod_afsk.c modified: digipeater.c modified: digipeater.h modified: direwolf.c modified: direwolf.conf deleted: direwolf.desktop modified: direwolf.h new file: direwolf.spec new file: direwolf.txt new file: dlq.c new file: dlq.h modified: dsp.c new file: dtime_now.c new file: dtime_now.h modified: dtmf.c modified: dtmf.h new file: dwespeak.bat new file: dwespeak.sh modified: fsk_demod_state.h modified: gen_packets.c modified: gen_tone.c new file: geotranz/README-FIRST.txt new file: geotranz/error_string.c new file: geotranz/error_string.h new file: geotranz/mgrs.c new file: geotranz/mgrs.h new file: geotranz/polarst.c new file: geotranz/polarst.h new file: geotranz/readme.txt new file: geotranz/releasenotes.txt new file: geotranz/tranmerc.c new file: geotranz/tranmerc.h new file: geotranz/ups.c new file: geotranz/ups.h new file: geotranz/usng.c new file: geotranz/usng.h new file: geotranz/utm.c new file: geotranz/utm.h modified: hdlc_rec.c modified: hdlc_rec.h modified: hdlc_rec2.c modified: hdlc_rec2.h modified: hdlc_send.c modified: igate.c modified: igate.h modified: kiss_frame.c modified: kiss_frame.h modified: kissnet.c modified: latlong.c modified: latlong.h modified: ll2utm.c modified: log.c modified: log.h new file: man1/aclients.1 new file: man1/atest.1 new file: man1/decode_aprs.1 new file: man1/direwolf.1 new file: man1/gen_packets.1 new file: man1/ll2utm.1 new file: man1/log2gpx.1 new file: man1/text2tt.1 new file: man1/tt2text.1 new file: man1/utm2ll.1 modified: multi_modem.c modified: multi_modem.h new file: pfilter.c new file: pfilter.h modified: ptt.c modified: ptt.h deleted: pttest.c modified: rdq.c new file: recv.c new file: recv.h modified: redecode.c modified: redecode.h modified: rrbb.c modified: rrbb.h modified: server.c modified: server.h modified: telemetry.c modified: telemetry.h modified: textcolor.c modified: textcolor.h modified: tocalls.txt modified: tq.c modified: tq.h modified: tt_text.c modified: tt_text.h modified: tt_user.c modified: tt_user.h new file: ttcalc.c deleted: udp_test.c deleted: utm/LatLong-UTMconversion.c deleted: utm/LatLong-UTMconversion.h deleted: utm/README.txt deleted: utm/SwissGrid.cpp deleted: utm/UTMConversions.cpp deleted: utm/constants.h modified: utm2ll.c modified: version.h new file: xid.c modified: xmit.c modified: xmit.h
145 lines
3.0 KiB
C
145 lines
3.0 KiB
C
/* UTM to Latitude / Longitude conversion */
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
|
|
#include "utm.h"
|
|
#include "mgrs.h"
|
|
#include "usng.h"
|
|
#include "error_string.h"
|
|
|
|
|
|
#define D2R(d) ((d) * M_PI / 180.)
|
|
#define R2D(r) ((r) * 180. / M_PI)
|
|
|
|
|
|
|
|
|
|
static void usage();
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
{
|
|
double easting;
|
|
double northing;
|
|
double lat, lon;
|
|
char szone[100];
|
|
long lzone;
|
|
char *zlet;
|
|
char hemi;
|
|
long err;
|
|
char message[300];
|
|
|
|
|
|
if (argc == 4) {
|
|
|
|
// 3 command line arguments for UTM
|
|
|
|
strcpy (szone, argv[1]);
|
|
lzone = strtoul(szone, &zlet, 10);
|
|
|
|
if (*zlet == '\0') {
|
|
hemi = 'N';
|
|
}
|
|
else {
|
|
|
|
if (islower(*zlet)) {
|
|
*zlet = toupper(*zlet);
|
|
}
|
|
if (strchr ("CDEFGHJKLMNPQRSTUVWX", *zlet) == NULL) {
|
|
fprintf (stderr, "Latitudinal band must be one of CDEFGHJKLMNPQRSTUVWX.\n\n");
|
|
usage();
|
|
}
|
|
if (*zlet >= 'N') {
|
|
hemi = 'N';
|
|
}
|
|
else {
|
|
hemi = 'S';
|
|
}
|
|
}
|
|
|
|
easting = atof(argv[2]);
|
|
|
|
northing = atof(argv[3]);
|
|
|
|
err = Convert_UTM_To_Geodetic(lzone, hemi, easting, northing, &lat, &lon);
|
|
if (err == 0) {
|
|
lat = R2D(lat);
|
|
lon = R2D(lon);
|
|
|
|
printf ("from UTM, latitude = %.6f, longitude = %.6f\n", lat, lon);
|
|
}
|
|
else {
|
|
|
|
utm_error_string (err, message);
|
|
fprintf (stderr, "Conversion from UTM failed:\n%s\n\n", message);
|
|
|
|
}
|
|
}
|
|
else if (argc == 2) {
|
|
|
|
// One command line argument, USNG or MGRS.
|
|
|
|
// TODO: continue here.
|
|
|
|
|
|
err = Convert_USNG_To_Geodetic (argv[1], &lat, &lon);
|
|
if (err == 0) {
|
|
lat = R2D(lat);
|
|
lon = R2D(lon);
|
|
printf ("from USNG, latitude = %.6f, longitude = %.6f\n", lat, lon);
|
|
}
|
|
else {
|
|
usng_error_string (err, message);
|
|
fprintf (stderr, "Conversion from USNG failed:\n%s\n\n", message);
|
|
}
|
|
|
|
err = Convert_MGRS_To_Geodetic (argv[1], &lat, &lon);
|
|
if (err == 0) {
|
|
lat = R2D(lat);
|
|
lon = R2D(lon);
|
|
printf ("from MGRS, latitude = %.6f, longitude = %.6f\n", lat, lon);
|
|
}
|
|
else {
|
|
mgrs_error_string (err, message);
|
|
fprintf (stderr, "Conversion from MGRS failed:\n%s\n\n", message);
|
|
}
|
|
|
|
}
|
|
else {
|
|
usage();
|
|
}
|
|
|
|
exit (0);
|
|
}
|
|
|
|
|
|
static void usage (void)
|
|
{
|
|
fprintf (stderr, "UTM to Latitude / Longitude conversion\n");
|
|
fprintf (stderr, "\n");
|
|
fprintf (stderr, "Usage:\n");
|
|
fprintf (stderr, "\tutm2ll zone easting northing\n");
|
|
fprintf (stderr, "\n");
|
|
fprintf (stderr, "where,\n");
|
|
fprintf (stderr, "\tzone is UTM zone 1 thru 60 with optional latitudinal band.\n");
|
|
fprintf (stderr, "\teasting is x coordinate in meters\n");
|
|
fprintf (stderr, "\tnorthing is y coordinate in meters\n");
|
|
fprintf (stderr, "\n");
|
|
fprintf (stderr, "or:\n");
|
|
fprintf (stderr, "\tutm2ll x\n");
|
|
fprintf (stderr, "\n");
|
|
fprintf (stderr, "where,\n");
|
|
fprintf (stderr, "\tx is USNG or MGRS location.\n");
|
|
fprintf (stderr, "\n");
|
|
fprintf (stderr, "Examples:\n");
|
|
fprintf (stderr, "\tutm2ll 19T 306130 4726010\n");
|
|
fprintf (stderr, "\tutm2ll 19TCH06132600\n");
|
|
|
|
exit (1);
|
|
} |