static void psp_waypt_pr(const waypoint *wpt) { double lon, lat; char tbuf[64]; char c; static short int pindex = 0; char *shortname; char *description; if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { if (wpt->description) { if (global_opts.synthesize_shortnames) shortname = mkshort_from_wpt(mkshort_handle, wpt); else shortname = xstrdup(wpt->description); } else { /* no description available */ shortname = xstrdup(""); } } else{ shortname = xstrdup(wpt->shortname); } if (! wpt->description) { if (shortname) { description = xstrdup(shortname); } else { description = xstrdup(""); } } else{ description = xstrdup(wpt->description); } /* convert lat/long back to radians */ lat = RAD(wpt->latitude); lon = RAD(wpt->longitude); pindex++; /* 2 bytes - pin index */ gbfputint16(pindex, psp_file_out); /* 2 bytes - null bytes */ gbfputint16(0, psp_file_out); /* set the grid byte */ c = grid_byte(wpt->latitude, wpt->longitude); /* since the grid byte matches with what pocketstreets does to */ /* input files, our output appears identical to a pin file that */ /* has already been processed and corrected by pocketstreets. */ /* Due to the grid and signs, it'll look different than one that */ /* comes straight from S&T. */ /* the grid byte */ gbfwrite(&c, 1, 1, psp_file_out); /* 8 bytes - latitude/radians */ psp_fwrite_double(lat, psp_file_out); /* 8 bytes - longitude/radians */ psp_fwrite_double(lon, psp_file_out); /* 1 byte - pin properties */ c = 0x14; /* display pin name on, display notes on. 0x04 = no notes */ gbfwrite(&c, 1, 1, psp_file_out); memset(tbuf, '\0', sizeof(tbuf)); /* 3 unknown bytes */ gbfwrite(tbuf, 1, 3, psp_file_out); /* 1 icon byte 0x00 = PIN */ gbfwrite(tbuf, 1, 1, psp_file_out); /* 3 unknown bytes */ gbfwrite(tbuf, 1, 3, psp_file_out); /* 3 junk */ psp_write_str(shortname); psp_write_str(description); /* just for the hell of it, we'll scrap the third string. */ psp_write_str(""); xfree(shortname); xfree(description); }
// Called for each cache to write out the corresponding waypoint to be used by the GPS void CPocketStreetPushPinsWriter::OnCache(CGeoCache& Cache) { #ifndef M_PI #define M_PI 3.14159265358979323846 #endif AW_CONVERSION; char tbuf[64]; int i; /* convert lat/long back to radians */ double lat = (Cache.m_Lat * M_PI) / 180.0; double lon = (Cache.m_Long * M_PI) / 180.0; m_PIndex++; le_write16(tbuf, m_PIndex); /* 2 bytes - pin index */ fwrite(tbuf, 1, 2, m_fd); /* 2 bytes - null bytes */ memset(tbuf, '\0', sizeof(tbuf)); fwrite(tbuf, 1, 2, m_fd); /* set the grid byte */ char c = grid_byte(Cache.m_Lat, Cache.m_Long); /* since the grid byte matches with what pocketstreets does to */ /* input files, our output appears identical to a pin file that */ /* has already been processed and corrected by pocketstreets. */ /* Due to the grid and signs, it'll look different than one that */ /* comes straight from S&T. */ /* the grid byte */ fwrite(&c, 1, 1, m_fd); /* 8 bytes - latitude/radians */ psp_fwrite_double(lat, m_fd); /* 8 bytes - longitude/radians */ psp_fwrite_double(lon, m_fd); /* 1 byte - pin properties */ c = 0x14; /* display pin name on, display notes on. 0x04 = no notes */ fwrite(&c, 1, 1, m_fd); memset(tbuf, '\0', sizeof(tbuf)); /* 3 unknown bytes */ fwrite(tbuf, 1, 3, m_fd); char Icon[2] = {0,0}; /* Traditional is a red box with a flag Mystery Cache is the pushpin. Multi is the Flags Event is the bubble text icon. Virtual is the arrow pointing right. */ #define IconPin 0 #define IconBubble 1 #define IconRedBoxFlag 4 #define IconArrowToLeft 8 #define IconArrowToRight 9 #define IconArrowDown 10 #define IconFlags 18 #define IconLetter 29 switch (Cache.TypeLookup()) { case GT_Traditional: Icon[0] = IconRedBoxFlag; break; case GT_Multi: Icon[0] = IconFlags; break; case GT_Virtual: Icon[0] = IconArrowToRight; break; case GT_Webcam: Icon[0] = IconArrowDown; break; case GT_Unknown: Icon[0] = IconPin; break; case GT_LetterboxHybrid: Icon[0] = IconLetter; break; case GT_Event: Icon[0] = IconBubble; break; case GT_ProjectAPE: Icon[0] = IconRedBoxFlag; break; case GT_Locationless: Icon[0] = IconArrowToLeft; break; case GT_CITO: Icon[0] = IconBubble; break; case GT_Earthcache: Icon[0] = IconArrowToRight; break; } /* 1 icon byte 0x00 = PIN */ fwrite(&Icon, 1, 1, m_fd); /* 3 unknown bytes */ fwrite(tbuf, 1, 3, m_fd); /* 3 junk */ //--------------------------------- String Desc; Desc = Cache.m_Shortname; char* pDesc = w2a((TCHAR*) Desc.c_str()); c = strlen(pDesc); /* 1 string size */ fwrite(&c, 1, 1, m_fd); for (i = 0; pDesc[i]; i++) { fwrite(&pDesc[i], 1, 1, m_fd); /* char */ fwrite(&tbuf[0], 1, 1, m_fd); /* null */ } //--------------------------------- Desc = Cache.m_GsCacheType; Desc += _T(". "); Desc += Cache.m_GsCacheName; Desc += _T(" by "); Desc += Cache.m_GsCacheOwnerName; Desc += _T(". Rating: "); Desc += RatingToStringW(Cache.m_GsCacheDifficulty); Desc += _T("/"); Desc += RatingToStringW(Cache.m_GsCacheTerrain); TCHAR Buffer[20]; Cache.LastFoundText(Buffer); Desc += _T(". Last found: "); Desc += Buffer; pDesc = w2a((TCHAR*) Desc.c_str()); c = strlen(pDesc); /* 1 byte string size */ fwrite(&c, 1, 1, m_fd); for (i = 0; pDesc[i]; i++) { fwrite(&pDesc[i], 1, 1, m_fd); /* char */ fwrite(&tbuf[0], 1, 1, m_fd); /* null */ } //--------------------------------- // Scrap the last string c = strlen(tbuf); /* 1 byte string size */ fwrite(&c, 1, 1, m_fd); for (i = 0; tbuf[i]; i++) { fwrite(&tbuf[i], 1, 1, m_fd); /* char */ fwrite(&tbuf[0], 1, 1, m_fd); /* null */ } }