📄 pushes.c
字号:
#include "g7to.h"
//
// data in a pushed route, each item separated from the others by either a ;
// except for the date string which is terminated by an !
//
// item example
// record type == W
// data type == 104 - if the input is a GPS this is the garmin record number
// from which the data came. If it's from a Lowrance:
// 10000 = tracks
// 20000 = events (icons # is added to 20000)
// 30000 = waypoints (waypoint # is added to 30000)
//
// waypoint ident == BELCTR
// waypoit comment == BELKNAP CRATER
// Route Name == MR Only in first waypoint record!!
// Date time string== Thu Aug 06 18:15:28 1998
// decimal latitude== 44.284081 N +, S -
// decimal long == 121.844693 W +, E -
// SA Object Code == 0
// SA Object Size == 0
// SA Object Color == 0
// SA Text Size == 0
// SA Text Color == 2
// SA Text Align == 2
// Garmin icon
// Symbol number == 18
// Garmin icon
// display format == 3
// record.class
// record.name (not the waypont name, some Garmin internal name)
// record.city
// record.state
// record.cc
// Route Line Color==
// Route Line Width==
// Route Line Style==
// nameonly == SA text format == 0
// via
// Example:
// Route waypoint record for first waypoint. Includes the route name
// W;0;126TRN;HWY 20-126;MR;Mon Jul 27 05:06:06 1998!44.421303;122.001853;0;0;0;0;2;2;18;3;0;1;0;0;0;
// Route waypoint record
// W;0;226TRN;HWY 20-126;Mon Jul 27 05:06:06 1998!44.471303;122.135187;0;0;0;0;2;2;18;3;0;1;0;0;0;
/* -------------------------------------------------------------------------- */
PROCX void push_route()
{
char push[MAX_LENGTH],tb[10];
INT i,hold,malbytes;
static last_route=-1;
if(last_route!=route_number) route_point=0;
last_route=route_number;
if(++route_point==1) {
for(hold=route_point+1;hold<=MAXPOINTS;hold++)
route_push[route_number][hold]=NULL;
strcat(Text,";");
strcat(Text,route_comment);
}
sprintf(push,"%s;%s!%lf;%lf;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%s;%s;%s;%s;%d;%d;%d;%d;%d;%d;",
Text,record.datetime,record.la,record.lo,
ObjCode, ObjSize, ObjColor,
TextSize, TextColor, TextAlign,
record.icon_smbl,record.icon_dspl,nameonly,record.class,
record.name,record.city,record.state,record.cc,
Route_LineColor,Route_LineWidth,Route_LineStyle,nameonly,via,record.color);
hold=opterr;
opterr=1;
if(route_number>MAXROUTES) Usage(43);
if(route_point>MAXPOINTS) Usage(44);
malbytes=strlen(push)+1;
if(D105orD106) malbytes=malbytes+strlen((char*)StreetPilotWptName) +
strlen((char*)StreetPilotLnk_ident)+60;
if((route_push[route_number][route_point]=calloc(malbytes,1)) == NULL) {
oomem("push_route");
byebye(8);
}
strcpy(route_push[route_number][route_point],push);
//
// SP route data should only be D106
//
if(D105orD106) {
sprintf(push,"%s;%s;",StreetPilotWptName,StreetPilotLnk_ident);
strcat(route_push[route_number][route_point],push);
sprintf(tb,"%d;",record.class);
strcat(route_push[route_number][route_point],tb);
for(i=0;i<13;i++) {
sprintf(tb,"%d;",record.subclass[i]);
strcat(route_push[route_number][route_point],tb);
}
}
route_points++;
opterr=hold;
} /* push_route */
/* -------------------------------------------------------------------------- */
PROCX void push_icon()
{
char push[MAX_LENGTH];
INT hold;
sprintf(push,"%s!%lf;%lf;%d;%d",
Text,record.la,record.lo,record.icon_smbl,ObjColor);
if(first_icon_push==1) {
first_icon_push=0;
if((icon_push=calloc(sizeof(char*)*maxiconptrs+1,1)) == NULL) {
oomem("push_icon");
byebye(8);
}
}
hold=opterr;
opterr=1;
if(++icons>maxiconptrs) Usage(42);
if((icon_push[icons]=calloc(strlen(push)+1,1)) == NULL) {
oomem("push_icon");
byebye(8);
}
strcpy(icon_push[icons],push);
opterr=hold;
} // void push_icon
/* -------------------------------------------------------------------------- */
PROCX void push_track()
{
char push[MAX_LENGTH];
INT hold;
sprintf(push,"%s!%lf;%lf;%d;%d;%d;%s;",
Text,record.la,record.lo,
LineColor, LineWidth, LineStyle,record.datetime);
if(maxtrkptrs>0) {
if(first_track_push==1) {
first_track_push=0;
if((track_push=calloc(sizeof(char*)*maxtrkptrs+1,1)) == NULL) {
oomem("push_track");
byebye(8);
}
}
hold=opterr;
opterr=1;
if(++tracks>maxtrkptrs) Usage(42);
if((track_push[tracks]=calloc(strlen(push)+1,1)) == NULL) {
oomem("push_track");
byebye(8);
}
strcpy(track_push[tracks],push);
opterr=hold;
}
else { // maxtrkptrs<=0;
tracks++;
fprintf(trks_out,"%s\n",push);
}
} /* push_track */
//
// data in a pushed waypoint, each item separated from the others by either a ;
// except for the date string which is terminated by an !
//
// item example
// record type == W
// data type == 104 - if the input is a GPS this is the garmin record number
// from which the data came otherwise, it's a 0
// waypoint name == BELCTR
// waypoit comment == BELKNAP CRATER
// Date time string== Thu Aug 06 18:15:28 1998
// decimal latitude== 44.284081 N +, S -
// decimal long == 121.844693 W +, E -
// SA Object Code == 0
// SA Object Size == 0
// SA Object Color == 0
// SA Text Size == 0
// SA Text Color == 2
// SA Text Align == 2
// Garmin icon
// Symbol number == 18
// Garmin icon
// display format == 3
// SA text format == 0
//
// Example:
// W;104;BELCTR;BELKNAP CRATER;Thu Aug 06 18:15:28 1998!44.284081;121.844693;0;0;0;0;2;2;18;3;0;
/* -------------------------------------------------------------------------- */
PROCX void push_waypoint()
{
char push[MAX_LENGTH];
INT hold,malbytes;
if(first_waypoint_push==1) {
first_waypoint_push=0;
if((waypoint_push=calloc(sizeof(char*)*MAXWAYP+1,1)) == NULL) {
oomem("push_waypoint");
byebye(8);
}
}
set_sign();
sprintf(push,"%s;%s!%lf;%lf;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%s;%s;%s;%s;%d;",
Text,record.datetime,record.la,record.lo,
ObjCode, ObjSize, ObjColor,
TextSize, TextColor, TextAlign,
record.icon_smbl,record.icon_dspl,nameonly,record.class,
record.name,record.city,record.state,record.cc,record.color);
hold=opterr;
opterr=1;
malbytes=strlen(push)+15;
if(D105orD106) malbytes+=strlen((char*)StreetPilotWptName)+5;
if(++waypoints>MAXWAYP) Usage(41);
if((waypoint_push[waypoints]=calloc(malbytes,1)) == NULL) {
oomem("push_waypoint");
byebye(8);
}
strcpy(waypoint_push[waypoints],push);
if(D105orD106) {
strcat(waypoint_push[waypoints],(char*)StreetPilotWptName);
strcat(waypoint_push[waypoints],";");
}
opterr=hold;
} /* push_waypoint */
/* -------------------------------------------------------------------------- */
PROCX void push_proximity()
{
char push[MAX_LENGTH];
INT hold;
if(first_proximity_push==1) {
first_proximity_push=0;
if((proximity_push=calloc(sizeof(char*)*MAXPROX+1,1)) == NULL) {
oomem("push_proximity");
byebye(8);
}
}
sprintf(push,"%s;%s!%lf;%lf;%lf;%d;%d;%d;%d;%d;%d;%d;%d;%d;",
Text,record.datetime,record.la,record.lo,record.ProxDist,
CirLineDraw, CirFillArea, CirLineColor,
CirLineWidth, CirFillColor, CirFillStyle,
record.icon_smbl,record.icon_dspl,nameonly);
hold=opterr;
opterr=1;
if(++proximityp>MAXPROX) Usage(40);
if((proximity_push[proximityp]=calloc(strlen(push)+1,1)) == NULL) {
oomem("push_proximity");
byebye(8);
}
strcpy(proximity_push[proximityp],push);
opterr=hold;
} /* push_proximity */
/* -------------------------------------------------------------------------- */
PROCX void push_record(char *in, INT convert)
{
char b[MAX_LENGTH],bb[100];
char *p;
if(in[0]=='D') {
strcpy(inputdatum,(char*)&in[2]);
trim(inputdatum);
if(strchr("0123456789",inputdatum[0]) != NULL) {
p=strtok(inputdatum," ");
if(*p==0) {
fprintf(stderr,"Datum '%s' not found. Using WGS-84.\n",p);
strcpy(inputdatum,"WGS-84");
}
else {
p=strtok(NULL," ");
if(*p==0) {
fprintf(stderr,"Datum '%s' not valid. Using WGS-84.\n",p);
strcpy(inputdatum,"WGS-84");
}
else {
strcpy(inputdatum,p);
}
}
}
set_datum(inputdatum,outputdatum);
trim(inputdatum);
return;
}
fill_record_from_text((unsigned char *)in,convert);
sprintf(Text,"%c;%d;%s;%s",record.type,datatype,
trim(record.ident),trim(record.comment));
strupr(Text);
trim(Text);
strcpy(b,Text);
switch(in[0]) {
case 'N': next_is_new=1;
no_N=0;
break;
case 'R': {
decode_route_start((unsigned char *)in);
break;
}
case 'E': {
in_route=0;
route_point=0;
break;
}
case 'I': {
record.icon_smbl=atoi((char*)&in[29]);
push_icon();
break;
}
case 'W':
case 'P':
set_record_icon();
//
// if a ';' exists on the line, assume that the first one is the
// delimiter between the waypoint comment and the icon type.
//
if((p=strchr(in,';')) != NULL) {
strcpy(bb,++p);
p=strtok3(bb,";");
if(p!=NULL)
record.icon_smbl=atoi(p);
p=strtok3(NULL,";");
if(p!=NULL)
record.icon_dspl=atoi(p);
p=strtok3(NULL,";");
if(p!=NULL)
via=atol(p);
}
if(in[0]=='W') {
if(in_route==1) {
push_route();
strcpy(Text,b); // restore Text
}
else { // not in a route
route_point=0;
}
//
// Always push a waypoint. Sorting/unique will remove the extra's
//
push_waypoint();
}
else { // in[0]=='P'
record.ProxDist=atof(strtok3(NULL,";"));
push_proximity();
strcpy(Text,b);
Text[0]='W';
push_waypoint();
}
break;
case 'T':if(next_is_new==1) {
next_is_new=0;
Text[0]='N';
}
if(no_N==1) { // if we get a 'T' record without
no_N=0; // first getting a 'N' record, fake a
Text[0]='N'; // 'N' record
}
push_track();
break;
}
} /* push_record */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -