📄 garmin.c
字号:
strncpad(D155_Wpt->name, record.name, 30);
}
if(strlen(record.city)) {
strncpad(D155_Wpt->city, record.city, 24);
}
if(strlen(record.state)) {
strncpad(D155_Wpt->state, record.state, 2);
}
D155_Wpt->alt = record.alt;
if(strlen(record.cc)) {
strncpad(D155_Wpt->cc, record.cc, 2);
}
D155_Wpt->class = record.class; // 4;// user defined class == 4
D155_Wpt->smbl = record.icon_smbl;
D155_Wpt->dspl = record.icon_dspl;
mlen=sizeof(D155_Wpt_Type);
break;
}
} // switch(wpt_type)
if(prox==1) {
switch(ProxDataRecord) {
case 101:
case 102:
case 107:
case 152: break;
case 400: D400_Prx_Wpt = (D400_Prx_Wpt_Type *) D100_Wpt;
D400_Prx_Wpt->dst = record.ProxDist;
mlen=sizeof(D400_Prx_Wpt_Type);
break;
case 403: D403_Prx_Wpt = (D403_Prx_Wpt_Type *) D103_Wpt;
D403_Prx_Wpt->dst = record.ProxDist;
mlen=sizeof(D403_Prx_Wpt_Type);
break;
case 450: D450_Prx_Wpt = (D450_Prx_Wpt_Type *) D150_Wpt;
D450_Prx_Wpt->dst = record.ProxDist;
mlen=sizeof(D450_Prx_Wpt_Type);
break;
default: fprintf(stderr,"Unknown Proximity Protocol %d\n",ProxDataRecord);
} // switch(ProxDataRecord)
}
//-----------------------------------------------------------
if (in_route) /* type == ROUTE */
message[0] = Pid_Rte_Wpt_Data;
else {
if(prox) message[0] = Pid_Prx_Wpt_Data;
else message[0] = Pid_Wpt_Data;
}
message[1]=mlen;
SendGarminMessage(message, (short)(message[1]+2),msgtype);
getGarminMessage(1);
} /* doSWaypoint */
/* -------------------------------------------------------------------------- */
//
// This routine is common to almost all waypoint data records of all Garmin Units.
// The only formats not using the basic D100 format are D105,106 and D150
//
/* -------------------------------------------------------------------------- */
PROCX void readD100(BYTE * aa, INT wpt)
{
D100_Wpt = (D100_Wpt_Type*)aa;
record.la = toDegrees(D100_Wpt->posn.lat);
record.lo = toDegrees(D100_Wpt->posn.lon);
set_ns();
/*
* waypoint name
*/
strncpy(record.ident,D100_Wpt->ident,6);
record.ident[6]=0; trim(record.ident);
/*
* Comment, up to 40 characters
*/
strncpy(record.comment,D100_Wpt->cmnt,40);
record.comment[40]=0; trim(record.comment);
/*
* Date/Time Always unused in D104, so set it to system time
*/
settime_record(0);
//
// process rest of records
//
switch(wpt) {
case 100:
case 400: break;
case 101:
D101_Wpt=(D101_Wpt_Type *)aa;
record.ProxDist = D101_Wpt->dst;
record.icon_smbl= D101_Wpt->smbl;
break;
case 102:
D102_Wpt=(D102_Wpt_Type *)aa;
record.ProxDist = D102_Wpt->dst;
record.icon_smbl= D102_Wpt->smbl;
break;
case 103:
case 403:
D103_Wpt=(D103_Wpt_Type *)aa;
record.icon_smbl = D103_Wpt->smbl;
record.icon_dspl = D103_Wpt->dspl;
//
// Translate from GPS 12 & II+ Icons
//
// Program 12/II+ Display mode
// 3 0 Symbol with Waypoint Name
// 1 1 Symbol
// 5 2 Symbol with Waypoint Comment
//
switch(record.icon_dspl){
case 0: record.icon_dspl=3;break;
case 2: record.icon_dspl=5;break;
}
break;
case 104:
D104_Wpt=(D104_Wpt_Type *)aa;
record.ProxDist = D104_Wpt->dst;
record.icon_smbl = D104_Wpt->smbl;
record.icon_dspl = D104_Wpt->dspl;
break;
case 107:
D107_Wpt=(D107_Wpt_Type *)aa;
record.ProxDist = D107_Wpt->dst;
record.icon_smbl = D107_Wpt->smbl;
record.icon_dspl = D107_Wpt->dspl;
switch(record.icon_dspl){
case 0: record.icon_dspl=3;break;
case 2: record.icon_dspl=5;break;
}
record.ProxDist = D107_Wpt->dst;
record.color = D107_Wpt->color;
switch(record.color) {
case 0: break; // no change
case 1: break; // no change
case 2:
record.color=3;
break;
case 3:
record.color=2;
break;
}
break;
case 151:
D151_Wpt=(D151_Wpt_Type *)aa;
record.ProxDist = D151_Wpt->dst;
strncpy(record.name, D151_Wpt->name, 30);
strncpy(record.city, D151_Wpt->city, 24);
strncpy(record.state, D151_Wpt->state, 2);
record.alt = D151_Wpt->alt;
strncpy(record.cc, D151_Wpt->cc,2);
record.class = D150_Wpt->class;
break;
case 152:
D152_Wpt=(D152_Wpt_Type *)aa;
record.ProxDist = D152_Wpt->dst;
strncpy(record.name, D152_Wpt->name, 30);
strncpy(record.city, D152_Wpt->city, 24);
strncpy(record.state, D152_Wpt->state, 2);
record.alt = D152_Wpt->alt;
strncpy(record.cc, D152_Wpt->cc,2);
record.class = D152_Wpt->class;
break;
case 154:
D154_Wpt=(D154_Wpt_Type *)aa;
record.ProxDist = D154_Wpt->dst;
strncpy(record.name, D154_Wpt->name, 30);
strncpy(record.city, D154_Wpt->city, 24);
strncpy(record.state, D154_Wpt->state, 2);
record.alt = D154_Wpt->alt;
strncpy(record.cc, D154_Wpt->cc,2);
record.class = D154_Wpt->class;
record.icon_smbl = D154_Wpt->smbl;
break;
case 155:
D155_Wpt=(D155_Wpt_Type *)aa;
record.ProxDist = D155_Wpt->dst;
strncpy(record.name, D155_Wpt->name, 30);
strncpy(record.city, D155_Wpt->city, 24);
strncpy(record.state, D155_Wpt->state, 2);
record.alt = D155_Wpt->alt;
strncpy(record.cc, D155_Wpt->cc,2);
record.class = D155_Wpt->class;
record.icon_smbl = D155_Wpt->smbl;
record.icon_dspl = D155_Wpt->dspl;
break;
default: fprintf(stderr,"Unknown Data protocol in readD100\n");
return;
} // switch(wpt)
record.name[30]=0; trim(record.name);
record.city[24]=0; trim(record.city);
record.state[2]=0; trim(record.state);
record.cc[2]=0; trim(record.cc);
} // readD100
/* -------------------------------------------------------------------------- */
PROCX void readD105(BYTE * aa)
{
D105_Wpt=(D105_Wpt_Type *)aa;
/*
* Date/Time Not used in D105, so set it to system time
*/
settime_record(0);
SPWptNo++; // starts at 1
record.la = toDegrees(D105_Wpt->posn.lat);
record.lo = toDegrees(D105_Wpt->posn.lon);
set_ns();
record.icon_smbl=D105_Wpt->smbl;
memset(StreetPilotWptName,0,MAX_LENGTH);
memset(record.comment,0,40);
memset(record.ident,0,6);
strncpy((char*) StreetPilotWptName, D105_Wpt->wpt_ident,255);
strncpy(record.comment,(char*)StreetPilotWptName,40);
sprintf(record.ident,"SPW%03d",SPWptNo);
} // readD105
// 7.5.6. D105_Wpt_Type
//typedef struct
//{
// Semicircle_Type posn; // position
// Symbol_Type smbl; // symbol id
// char wpt_ident[1]; // null-terminated string -- length isn't
// // really specified, I added 1 for a place
// // holder for the decode of D105 waypoints
//} D105_Wpt_Type;
// 7.5.7. D106_Wpt_Type
// Example products: StreetPilot (route waypoints).
//typedef struct
//{
// byte class; // class
// byte subclass[13]; // subclass
// Semicircle_Type posn; // position
// Symbol_Type smbl; // symbol id
// char wpt_ident[1]; // null-terminated string -- length isn't
// // really specified, I added 10 for a place
// // holder for the decode of D106 waypoints
///* char lnk_ident[]; null-terminated string */
//} D106_Wpt_Type;
/* -------------------------------------------------------------------------- */
PROCX void readD106(BYTE *aa)
{
unsigned char *p;
INT i;
D106_Wpt=(D106_Wpt_Type *)aa;
/*
* Date/Time Not unused in D106, so set it to system time
*/
settime_record(0);
SPWptNo++; // starts at 1
record.la = toDegrees(D106_Wpt->posn.lat);
record.lo = toDegrees(D106_Wpt->posn.lon);
set_ns();
record.icon_smbl=D106_Wpt->smbl;
memset(StreetPilotWptName,0,MAX_LENGTH);
memset(StreetPilotLnk_ident,0,MAX_LENGTH);
memset(record.comment,0,40);
memset(record.ident,0,6);
strncpy((char*) StreetPilotWptName, D106_Wpt->wpt_ident,255);
strncpy(record.comment,(char*)StreetPilotWptName,40);
sprintf(record.ident,"SPW%03d",SPWptNo);
record.class = D106_Wpt->class;
for(i=0;i<13;i++) record.subclass[i]=D106_Wpt->subclass[i];
strncpy((char*)StreetPilotWptName, D106_Wpt->wpt_ident,255);
p=(unsigned char *)&D106_Wpt->wpt_ident;
while(*p)
p++; // look for null of string
p++; // skip over null
strncpy((char*)StreetPilotLnk_ident,(char*) p, 255);
} // readD106
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
// D108_Wpt_Type
// Example products: eMap
//typedef struct // size
//{
// byte wpt_class; // class (see below) 1
// byte color; // color (see below) 1
// byte dspl; // display options (see below) 1
// byte attr; // attributes (see below) 1
// Symbol_Type smbl; // waypoint symbol 2
// byte subclass[18]; // subclass 18
// Semicircle_Type posn; // 32 bit semicircle 8
// float alt; // altitude in meters 4
// float dpth; // depth in meters 4
// float dist; // proximity distance in meters 4
// char state[2]; // state 2
// char cc[2]; // country code 2
// char ident[]; variable length string 1-51
// char comment[]; waypoint user comment 1-51
// char facility[]; facility name 1-31
// char city[]; city name 1-25
// char addr[]; address number 1-51
// char cross_road[]; intersecting road label 1-51
//} D108_Wpt_Type;
//enum
//{
// USER_WPT = 0x00, // User waypoint
// AVTN_APT_WPT = 0x40, // Aviation Airport waypoint
// AVTN_INT_WPT = 0x41, // Aviation Intersection waypoint
// AVTN_NDB_WPT = 0x42, // Aviation NDB waypoint
// AVTN_VOR_WPT = 0x43, // Aviation VOR waypoint
// AVTN_ARWY_WPT = 0x44, // Aviation Airport Runway waypoint
// AVTN_AINT_WPT = 0x45, // Aviation Airport Intersection
// AVTN_ANDB_WPT = 0x46, // Aviation Airport NDB waypoint
// MAP_PNT_WPT = 0x80, // Map Point waypoint
// MAP_AREA_WPT = 0x81, // Map Area waypoint
// MAP_INT_WPT = 0x82, // Map Intersection waypoint
// MAP_ADRS_WPT = 0x83, // Map Address waypoint
// MAP_LABEL_WPT = 0x84, // Map Label Waypoint
// MAP_LINE_WPT = 0x85, // Map Line Waypoint
//};
//The "color" member can be one of the following values:
//enum { Black,
// Dark_Red,
// Dark_Green,
// Dark_Yellow,
// Dark_Blue,
// Dark_Magenta,
// Dark_Cyan,
// Light_Gray,
// Dark_Gray,
// Red,
// Green,
// Yellow,
// Blue,
// Magenta,
// Cyan,
// White,
// Default_Color = 0xFF
//};
// The enumerated values for the "dspl" member of the D108_Wpt_Type are the
// same as the the "dspl" member of the D103_Wpt_Type.
// The "attr" member should be set to a value of 0x60.
// The "subclass" member of the D108_Wpt_Type is used for map waypoints
// only, and should be set to 0x0000 0x00000000 0xFFFFFFFF 0xFFFFFFFF
// 0xFFFFFFFF for other classes of waypoints.
// The "alt" and "dpth" members may or may not be supported on a given
// unit. A value of 1.0e25 in either of these fields indicates that this
// parameter is not supported or is unknown for this waypoint.
/* -------------------------------------------------------------------------- */
//
// in points to a string which contains null terminated values.
//
PROCX void SplitOutD108Data(char *in, char *a, char *b, char *c, char *d, char *e, char *f)
{
int done;
char *p;
p=a;
done =0;
while(!done) {
if(*in==0) done=1;
*p++ = *in++;
} //!done
p=b;
done =0;
while(!done) {
if(*in==0) done=1;
*p++ = *in++;
} //!done
p=c;
done =0;
while(!done) {
if(*in==0) done=1;
*p++ = *in++;
} //!done
p=d;
done =0;
while(!done) {
if(*in==0) done=1;
*p++ = *in++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -