⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 safiles.c

📁 这是经典的卫星编程应用程序
💻 C
📖 第 1 页 / 共 3 页
字号:
#include "g7to.h"

extern char chch;
char *Trailer1= "CDMLTypeSetting";


struct Const2 {
    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 a1; INT a2; INT a3; INT a4; INT a5; INT a6;
    INT a8; INT a9; INT aa; INT ab; INT ac; INT ad;
    INT ae; INT af; INT ag; INT ah; INT ai; INT aj;
    INT ak; INT al; INT am; INT an; INT ao; INT ap;
    INT aq; INT ar; INT as; INT at; INT au; INT av;
    INT aw; INT ax; INT ay; INT az; INT ba; INT bb;
    INT bc; INT bd;
    char qqa;
    char qqa1[9];
    char qq;
    char qq1[9];
    INT be; INT bf;
} Const2 = {
    0,0,0,0x3ff0,
    0,0,0,0,
    0,0,0,0,
    0,0,0,0x3ff0,
    0x7fff,
    1,1,0,0,10000,10000,
    1,1,6500,6500,9700,9700,
    1,1,200,200,9700,800,
    1,1,0,0,7500,10000,
    1,1,7500,0,10000,10000,
    1,1,200,200,7200,800,
    4,1,
    9,"chain.chn",
    9,"chain.chn",
    1,1
};
struct Const3 {
    INT a; INT b; INT c; INT d;
} Const3 = {
    0,5,0x200,0x766c
};

struct Const4 {
    INT a; INT b; INT c;
    INT d; INT e; INT f;
    INT i; INT h; INT g;
    INT j;
} Const4 = {
    1,0x3fff,0,
    3,0,1,
    1,0x3fff,0,
    0x102
};

struct Trailer {
    INT a; INT b; INT c;
    INT d; INT e; INT f;
    INT i; INT h;
} Trailer = {
    3,0,1,
    1,0x3fff,0,
    0x100,0
};

struct Trailersa6 {
    unsigned INT a1; unsigned INT b1; unsigned INT c1; unsigned INT d1;
	unsigned INT k;
} Trailersa6 = {
    0x7fb1, 0x0539, 0x0000, 0x0000, 0 
};

struct Trailer1a {
    unsigned INT a1; unsigned INT b1; unsigned INT c1; unsigned INT d1;
    unsigned INT a2; unsigned INT b2; unsigned INT c2; unsigned INT d2;
    unsigned INT a3; unsigned INT b3; unsigned INT c3; unsigned INT d3;
    unsigned INT a4;
} Trailer1a = {
    0x7fb1, 0x0539, 0x540b, 0x7079,
    0x2065, 0x6964, 0x6c61, 0x676f,
    0x0004, 0x0000, 0xffff, 0x0002,
    0x000f
};
//struct Trailer2 {
//  unsigned INT aa; unsigned INT cc; unsigned INT ee;
//  unsigned INT a1; unsigned INT c1; unsigned INT e1;
//  unsigned INT a2; unsigned INT c2; unsigned INT e2;
//  unsigned INT a3; unsigned INT c3; unsigned INT e3;
//  unsigned INT a4; unsigned INT c4; unsigned INT e4;
//  unsigned INT a5; unsigned INT c5; unsigned INT e5;
//  unsigned INT a6; unsigned INT c6; unsigned INT e6;
//  unsigned INT a7; unsigned INT c7; unsigned INT e7;
//  unsigned INT a8; unsigned INT c8; unsigned INT e8;
//  unsigned INT a9; unsigned INT c9; unsigned INT e9;
//  unsigned INT a0; unsigned INT c0; unsigned INT e0;
//  unsigned INT bb; unsigned INT dd; unsigned INT fe;
//  unsigned INT b1; unsigned INT d1; unsigned INT f1;
//  unsigned INT b2; unsigned INT d2; unsigned INT f2;
//  unsigned INT b3; unsigned INT d3; unsigned INT f3;
//  unsigned INT b4; unsigned INT d4; unsigned INT f4;
//  unsigned INT b5; unsigned INT d5; unsigned INT f5;
//  unsigned INT b6; unsigned INT d6; unsigned INT f6;
//  unsigned INT b7; unsigned INT d7; unsigned INT f7;
//  unsigned INT b8; unsigned INT d8;
//} Trailer2 = {
//  0x3C00, 0x0, 0x8001,
//  0x3C10, 0x0, 0x8001,
//  0x3C20, 0x0, 0x8001,
//  0x3C30, 0x0, 0x8001,
//  0x3C40, 0x0, 0x8001,
//  0x3C50, 0x0, 0x8001,
//  0x3C60, 0x0, 0x8001,
//  0x3C80, 0x0, 0x8001,
//  0x3C90, 0x0, 0x8001,
//  0x3CA0, 0x0, 0x8001,
//  0x3CB0, 0x0, 0x8001,
//  0x3CC0, 0x0, 0x8001,
//  0x3CE0, 0x0, 0x8001,
//  0x3CF0, 0x0, 0x8001,
//  0x3D00, 0x0, 0x8001,
//  0x3D20, 0x0, 0x8001,
//  0x3D70, 0x0, 0x8001,
//  0x4400, 0x0, 0x8001,
//  0x4800, 0x0, 0x8001,
//  0x4C00, 0x0
//};

int MyColor=0;

//
// Trailer from Brent that appears to work as well as the trailer
//  above
unsigned INT TrailerX[5]={ 0x7fb1,0x0539,0,0,0};

struct Trailer1x {
    unsigned INT a1; unsigned INT b1; unsigned INT c1; unsigned INT d1;
    unsigned INT a2; unsigned INT b2; unsigned INT c2; unsigned INT d2;
    unsigned INT a3; unsigned INT b3; unsigned INT c3;
} Trailer1x = {
    0x3C00, 0x0000, 0x8001, 0x4400,
    0x0000, 0x8001, 0x4800, 0x0000,
    0x8001, 0x4C00, 0x0000
};
//
// 
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;

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;

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;

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;

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;

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;

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;

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;

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 = {
	0x0003,0x0000,0x0001,
	0x0001,0x3FFF,0x0000,
	0x0102,
	0x0000,0x000A,0x0000,
	0x0001,0x0001,0x7FFF,
	0x0000,0x000A,0x0000,
	0x0001,0x0001,0x7FFF,
	0x0000,0x8E7F,0x009F    // 0x8E7E for SA5, 0x8E7F for SA6
};

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 = {
	0x0000,0x0000,0x0000,0x0000,0x0000,
	0x0000,0x0000,0x0000,0x0000,0x0000,
	0x0000,0x0000,0x0000,0x0000,0x0000,
	0x0000,0x0000,0x0000,0x0000,0x0000,
	0x0000,0x0000
};

/* -------------------------------------------------------------------------- */
PROCX void get_name_desc(char *buffer,INT rc,INT ict,int SAobj)
{
	char name[MAX_LENGTH], desc[MAX_LENGTH];
	char b[MAX_LENGTH],*p;
	INT i=0;
/*
 * if there's one ';' assume the format is 'name;desc'
 *   II+ icon style is tacked on to the end, i.e. 'name;desc;style'
 *   where style is a number representing the value from the GPS
 *
 * if rc==1 then we have to look for a route comment:
 *     'name;desc;style;route_comment' or
 *     'name;desc;route_comment'
 *
 * if ict==1 then the text passed in is assumed to have ';icon type;icon style'
 *    at the end rather than just ';icon style'.  This is to accomodate
 *    the text stored in SA4 mapnotes and maptext entries.
 *
 *    however, if the file was written by W+ icon type and icon style may
 *    be missing.
 */
 	strcpy(b,buffer);
	if(strrchr(b,';') != NULL) i=1;
	if(strlen(b)>0) {
		strcpy(name,strtok3(b,";"));
		if(i) {
			p=strtok3(NULL,";");
			if(p==NULL)
				strcpy(desc," ");
			else
				strcpy(desc,p);

			record.icon_dspl=0;
			p=strtok3(NULL,";"); // get next element
			if(p != NULL && strlen(p)) {
				if(ict==1) {
					record.icon_smbl=atoi(p);
					p=strtok3(NULL,";");
				}
// get icon_dspl
				if(p != NULL && strlen(p)) {
					record.icon_dspl=atoi(p);
				}
				else record.icon_dspl=1;
				if(rc==1) {
					p=strtok3(NULL,";");
					if(p==NULL) strcpy(route_comment," ");
					else strcpy(route_comment,p);
					trim(route_comment);
				}
			}
			else {
				if(SAobj==0) set_record_icon(); // symbol already set correctly
				else record.icon_dspl=1;
			}
		}
		else strcpy(desc," ");
	}
	else {
		strcpy(name," ");
		strcpy(desc," ");
	}
	if(strlen(name)>15) {
		strcpy(b,&name[15]);
		strcat(b," ");
		strcat(b,desc);
		strcpy(desc,b);
	}
	strupr(name);
	strupr(desc);
	if(strlen(name)>15) name[15]=0;
//	fixname(1,(unsigned char*)name);
	sprintf(record.ident,"%-15s",name);
	record.ident[15]=0;
	if(strlen(desc) > 0) {
		strncpy(record.comment,desc,39);
		record.comment[39]=0;
	}
	else
		strcpy(record.comment," ");
	trim(record.ident);
	trim(record.comment);
} /* get_name_desc */

/* -------------------------------------------------------------------------- */
PROCX void output_sa3hdr()
{
	unsigned char a;
	char  buffer[80];

	if(open_output("wb")==0) return;
/* 
 * write sa3 header info
 */
 	if(s4o || s5o || s6o) {
		Id=0x102;
		Const2.bc = 6;
		Const2.qq1[0]=Const2.qqa1[0]='C';
	}
	fwrite(&Id,2,1,out);
	fwrite(&Const1,4,1,out);
#if __BORLANDC__
	strcpy(buffer,"g7to_dos");
#else
	strcpy(buffer,"g7to_win");
#endif
//	strcat(buffer,PGMVER);
	a=(unsigned char)strlen(buffer);
	fwrite(&a,1,1,out);
	fwrite(buffer,a,1,out);
	if(setlat!=1000.0) LatConst=to_diskLL(setlat);
	fwrite(&LatConst,4,1,out);
	if(setlon!=1000.0) LonConst=to_diskLL(-setlon);
	fwrite(&LonConst,4,1,out);
	if(setmag) MagC=setmag;
	fwrite(&MagC,2,1,out);
	fwrite(&Const2,134,1,out);
	fwrite(&Mapfeatures,2,1,out);
	fwrite(&Const3,8,1,out);
 	fwrite(&ShowGrids,2,1,out);
	if(s6o) Const4.j=0x102;
	else Const4.j=0x100;
	fwrite(&Const4,20,1,out);
} /* output_sa3hdr */

/* -------------------------------------------------------------------------- */
PROCX INT read_sa3_header(FILE *in, char* fname_in)
{
 	fread(&Id,2,1,in);
	if(Id!=0x100 && Id!=0x102) {
		fprintf(stderr,"File %s is not a valid DeLorme .SA file\n",fname_in);
		fclose(in);
		return -1;
	}
 	fread(&Const1,4,1,in);
/*
 * get map title length
 */
 	fread(&MtLen,1,1,in);
/*
 * get map title
 */
	ChkFree(MapTitle);
 	if((MapTitle=(char *)malloc(MtLen+1)) == NULL) oomem("read_sa3_header");
 	fread(MapTitle,MtLen,1,in);

	MapTitle[MtLen]=0;
/*
 * get map center co-ords
 */
 	fread(&LatConst,4,1,in);
	LatC=fm_diskLL(LatConst);
 	fread(&LonConst,4,1,in);
	LonC=fm_diskLL(LonConst);
	fread(&MagC,2,1,in);
 	fread(&Const2,134,1,in);
 	fread(&Mapfeatures,2,1,in);
 	fread(&Const3,8,1,in);
 	fread(&ShowGrids,2,1,in);
	fread(&Const4,20,1,in);
	fread(&NumObjs,2,1,in);
	return(NumObjs);
} /* read_sa3_header */

/* -------------------------------------------------------------------------- */
/*
 * output a proximity waypoint from a gardown or text file to
 *  a SA file.
 */
PROCX void sa4out_p(void)
{
    INT ItemType;

    sa4mapcircle.ItemNum=sa3number++;

    sa4mapcircle.latR=to_diskLL(record.la);
    sa4mapcircle.lonR=to_diskLL(-record.lo);
    sa4mapcircle.Const1=0x8000;
    sa4mapcircle.paramlen=0;
    sa4mapcircle.area_draw_line=CirLineDraw;
    sa4mapcircle.area_draw_fill=CirFillArea;
    sa4mapcircle.LineColor=CirLineColor;
    sa4mapcircle.LineWidth=CirLineWidth;
    sa4mapcircle.Const3=0;
    sa4mapcircle.area_fill_color=CirFillColor;
    sa4mapcircle.area_fill_style=CirFillStyle;
    sa4mapcircle.const4=2;
    sa4mapcircle.latCntr=sa4mapcircle.latR;
    sa4mapcircle.lonCntr=sa4mapcircle.lonR;
/*
 * meters to nm to deg lat  30.9...=1855.422236*60.0
 */
    sa4mapcircle.latPnt=to_diskLL(record.la+(double)record.ProxDist/111325.3342);
    sa4mapcircle.lonPnt=sa4mapcircle.lonR;
    ItemType=9;
    fwrite(&ItemType,2,1,out);
    fwrite(&sa4mapcircle,45,1,out);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -