📄 g7to.c
字号:
#define PROCX
#define PGMBETA ""
#define PGMVER "3.04.32"
#if __BORLANDC__
#define PGMSUF "_dos"
#else
#define PGMSUF "_win"
#endif
#include "g7to.h"
#define DISABLE 0
#define ENABLE 1
#define ChkFree(a) if((a)!=NULL)free(a)
//
// File types supported
//
#define NOFILE -2 // file not found
#define UNKNOWN 0 // Unknown file type
#define TEXT_IO 1 // text/gd7
#define GARMIN 2 // GPS i/o
#define SA3 3 // Street Atlas 3
#define ALMANAC_D 4 // Almanac data
#define NAVROUTE 5 // Navigate route
#define SA4 6 // Street Atlas 4
#define SA5 7 // Street Atlas 5
#define SA_GPL 8 // Street Atlas GPL files
#define SA6 9 // Street Atlas 6
#define FUGAWI_WPT 10 // Fugawi waypoint file
#define FUGAWI_TRK 11 // Fugawi track file
#define OZI_EVT 12 // OziExplorer events (Icons)
#define CSV_IN 14 // CSV input file
#define LOWRANCE 15 // GPS i/o
#define OZI_PLT 16 // OziExplorer track file
#define OZI_WPT 17 // OziExplorer waypoint file
#define OZI_RTE 18 // OziExplorer route file
//
// degree modes for input
//
#define UTMMODE 1
#define DMS 2
#define DMM 3
#define DDD 4
//
// SA sub type being read/written
//
#define NONE 0
#define SA_SYMBOL 1
#define SA_TRACK 2
#define SA_CIRCLE 3
//
// Garmin GPS input/commands
//
#define TRACKS 1
#define WAYPOINTS 2
#define ROUTES 3
#define ID 4
#define TIME 5
#define POSITION 6
#define ALMANAC 7
#define PROXIMITY 8
#define VOLTAGES 9
#define PVT 12
#define PPROTOCOLS 14
#define GERROR 99
#define LOWRERROR 99
//
// Lowrance GPS input/commands
//
#define TRACK1 1
#define TRACK2 2
#define LWRWPTS 3
#define LWRRTS 4
#define LWRICONS 5
#define LWRID 6
//
// Garmin offset for time
//
#define START 2447892L // Julian date for 00:00 12/31/1989
#define STARTLOWR 2448623L // Julian date for 00:00 01/01/1992
//
// Serial port constants
//
#define GARMIN_BAUD_RATE 9600
#define LOWR_BAUD_RATE 115200L
#if __BORLANDC__
#define COM_SETTINGS (BITS_8 | STOP_1 | NO_PARITY)
INT WinNT=0;
#else
#define NOPARITY 0
#define ODDPARITY 1
#define EVENPARITY 2
#define MARKPARITY 3
#define SPACEPARITY 4
#define ONESTOPBIT 0
#define ONE5STOPBITS 1
#define TWOSTOPBITS 2
#define BYTESIZE 8
#endif
//===============================================================================
//
//
extern struct sa3symbol {
unsigned long latR;
unsigned long lonR;
INT ItemNum;
unsigned INT Const;
unsigned char paramlen;
INT ObjCode;
INT ObjSize;
INT ObjColor;
INT TextSize;
INT TextColor;
INT TextAlign;
unsigned char TextLen;
unsigned char *Text;
double lat;
double lon;
} sa3symbol;
extern struct sa3mapnote {
unsigned long latR;
unsigned long lonR;
INT ItemNum;
unsigned INT Const;
unsigned char paramlen;
INT TextSize;
INT TextColor;
INT TextJustification;
INT TextXoffset;
INT TextYoffset;
unsigned char TextLen;
unsigned char *Text;
double lat;
double lon;
} sa3mapnote;
extern struct sa3text {
unsigned long latR;
unsigned long lonR;
INT ItemNum;
unsigned INT Const;
unsigned char paramlen;
INT TextSize;
INT TextColor;
unsigned char TextLen;
unsigned char *Text;
double lat;
double lon;
} sa3text;
extern struct sa4mapline {
unsigned long latR;
unsigned long lonR;
unsigned INT ItemNum;
unsigned INT Const1;
unsigned char paramlen;
INT LineColor;
INT LineWidth;
INT LineStyle;
INT Points;
double lat;
double lon;
} sa4mapline;
extern struct sa4maparea {
unsigned long latR;
unsigned long lonR;
unsigned INT ItemNum;
unsigned INT Const1;
unsigned char paramlen;
INT area_draw_line;
INT area_draw_fill;
INT LineColor;
INT LineWidth;
INT Const3;
INT area_fill_color;
INT area_fill_style;
INT Points;
double lat;
double lon;
} sa4maparea;
extern struct sa4mapcircle {
unsigned long latR;
unsigned long lonR;
unsigned INT ItemNum;
unsigned INT Const1;
unsigned char paramlen;
INT area_draw_line;
INT area_draw_fill;
INT LineColor;
INT LineWidth;
INT Const3;
INT area_fill_color;
INT area_fill_style;
INT const4;
unsigned long latCntr;
unsigned long lonCntr;
unsigned long latPnt;
unsigned long lonPnt;
} sa4mapcircle;
extern struct sa4route {
unsigned long startLo;
unsigned long startLa;
unsigned long startLo1;
unsigned long startLa1;
unsigned INT unk1;
unsigned INT unk2;
unsigned INT unk3;
unsigned INT unk4;
unsigned INT unk5;
unsigned INT unk6;
unsigned long st_name_l;
char *st_name;
unsigned long st_st_name_l;
char *st_st_name;
unsigned long finishLo;
unsigned long finishLa;
unsigned long finishLo1;
unsigned long finishLa1;
unsigned INT unk7;
unsigned INT unk8;
unsigned INT unk9;
unsigned INT unk10;
unsigned INT unk11;
unsigned INT unk12;
unsigned long fi_name_l;
char *fi_name;
unsigned long fi_st_name_l;
char *fi_st_name;
unsigned long NumObjs;
} sa4route;
extern struct sa4routepts {
unsigned long startLo;
unsigned long startLa;
unsigned long startLo1;
unsigned long startLa1;
unsigned long checksum;
unsigned INT unk3;
unsigned INT unk4;
unsigned INT unk5;
unsigned INT unk6;
unsigned long st_name_l;
char *st_name;
unsigned long st_st_name_l;
char *st_st_name;
} sa4routepts;
extern struct MapConstM {
unsigned INT a; unsigned INT b; unsigned INT c;
unsigned INT d; unsigned INT e; unsigned INT f;
unsigned INT g;
unsigned INT h; unsigned INT i; unsigned INT j;
unsigned INT k; unsigned INT l; unsigned INT m;
unsigned INT n; unsigned INT o; unsigned INT p;
unsigned INT q; unsigned INT r; unsigned INT s;
unsigned INT t; unsigned INT u; unsigned INT v;
} MapConstM;
extern struct MapConstM0 {
INT a; INT b; INT c; INT d; INT e;
INT f; INT g; INT h; INT i; INT j;
INT k; INT l; INT m; INT n; INT o;
INT p; INT q; INT r; INT s; INT t;
INT u; INT v;
} MapConstM0;
//===============================================================================
INT LwrStartPt=1; // Set to LEI wpt # where upload is to start
INT Lwrout=0; // set to 1 is Ozi is set for Lowrance units
INT Ozi_to_12=0; // set to 1 by command line '-1' when transfer to/from Ozi is
// from/to a Garmin 16 icon GPS (12, 12XL, GII+)
INT G45out=0; // set to 1 is Ozi is set for Garmin units
INT SendLowrInactives=0; // set to 1 if inactive waypoints are not to be sent
INT to_lowr_track=0; // set to 1 or 2 if all track points should be sent
// to track1 or to track2
//
// Program constants
//
static const double Degree=Pi/180.0;
char chch;
char debugin_name[MAX_LENGTH];
char ProgramName[MAX_LENGTH];
char outputdatum[150];
char inputdatum[150];
int NoM=1; // 1 indicates that a 'M' line has not been read yet
int DMSMode=DMM; // default to degrees minutes.mm on reads
int timeonsa3=0;
int ZeroTime=0; // if set to 1 time output to .txt files go as 'Sun Dec 31 00:00:00 1989'
// which is time==0 for Garmin units
int cycle_track_colors=0;
char commp[5]="COM1";
extern double UTMa_in,UTMf_in;
extern double UTMa,UTMf;
extern double UTMa_out,UTMf_out;
extern double LA,LO;
BYTE NumOfPlotTrails;
//Lowrance Product Info Structure
extern struct LowrID {
BYTE Reserved;
INT ProductID;
INT ProtocolVersion;
INT ScreenType;
INT ScreenWidth;
INT ScreenHeight;
INT NumOfWaypoints;
INT NumOfIcons;
INT NumOfRoutes;
INT NumOfWaypointsPerRoute;
BYTE NumOfPlotTrails;
BYTE NumOfIconSym;
BYTE ScreenRotateAngle;
long RunTime;
} LowrID;
INT datatype; // The type of data stored in the current record. This is based
// upon the record type used to store the data
//
// structure of record from g7to.h
//
//struct RECORD {
// char type; // Record Type W,T,R,D,P
// char ident[40]; // Record ident
// char ns; // N/S for latitude
// double la; // latitude in dd.ddddddd
// char ew; // E/W for longitude
// double lo; // longitude in dd.ddddddd
// INT monthn; // month number of record
// char day_week[4]; // day of week of record
// char datetime[25]; // date/time string as read
// INT dayofmonth; // day of month 1-31
// INT year; // 4 digit year of record
// INT ht,mt,st; // time of record
// char comment[40]; // Comment field 20 max for 45
// INT dla, mla; // Deg & Min for Lat
// INT dlo, mlo; // Deg & Min for Long
// INT tnthsla, tnthslo; // tenths of a minute*10000
// double minla,minlo; // Lat/Long minutes in decimal
// double secla,seclo; // Lat/Long seconds in decimal
// float ProxDist; // Proximity Distance
// short icon_smbl; // Garmin smbl coverted to SA
// short icon_dspl; // Display style. Consistant with
// // later garminunits, i.e.
//
// Program 12/II+ Ozi Display mode
// 3 0 N Symbol with Waypoint Name
// 1 1 S Symbol
// 5 2 C Symbol with Waypoint Comment
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -